summaryrefslogtreecommitdiffstats
path: root/loader2
diff options
context:
space:
mode:
authorJeremy Katz <katzj@redhat.com>2002-12-03 18:02:11 +0000
committerJeremy Katz <katzj@redhat.com>2002-12-03 18:02:11 +0000
commit00a83be9766ea0990ff209620300f094747a26f7 (patch)
treecc23b0b5ba08acf3b56d5224b6c359e624c1a367 /loader2
parent5f86a917d7a2017881f64e21638c595abaac50a8 (diff)
downloadanaconda-00a83be9766ea0990ff209620300f094747a26f7.tar.gz
anaconda-00a83be9766ea0990ff209620300f094747a26f7.tar.xz
anaconda-00a83be9766ea0990ff209620300f094747a26f7.zip
add a data structure to hold loader data and pass it around lots of places
kickstart basically works now. need to hook up sources other than nfs for installing and getting kickstart file from other than floppy and file
Diffstat (limited to 'loader2')
-rw-r--r--loader2/Makefile4
-rw-r--r--loader2/cdinstall.c1
-rw-r--r--loader2/cdinstall.h17
-rw-r--r--loader2/hdinstall.h7
-rw-r--r--loader2/kbd.c11
-rw-r--r--loader2/kbd.h2
-rw-r--r--loader2/lang.c11
-rw-r--r--loader2/lang.h4
-rw-r--r--loader2/loader.c190
-rw-r--r--loader2/loader.h24
-rw-r--r--loader2/method.h12
-rw-r--r--loader2/modstubs.c5
-rw-r--r--loader2/modstubs.h3
-rw-r--r--loader2/net.c280
-rw-r--r--loader2/net.h13
-rw-r--r--loader2/nfsinstall.c91
-rw-r--r--loader2/urlinstall.c1
17 files changed, 454 insertions, 222 deletions
diff --git a/loader2/Makefile b/loader2/Makefile
index 5655c5f48..1af95a3da 100644
--- a/loader2/Makefile
+++ b/loader2/Makefile
@@ -2,10 +2,10 @@ include ../Makefile.inc
# JKFIXME: this should go somewhere common. I need to know about diet in
# a few locations. and we should really just always use diet
-# should we use diet on this arch?
ifeq (i386, $(ARCH))
USEDIET=1
endif
+# should we use diet on this arch?
ifeq (ppc, $(ARCH))
USEDIET=1
endif
@@ -23,7 +23,7 @@ HWOBJS = pcmcia.o usb.o firewire.o
METHOBJS = method.o cdinstall.o hdinstall.o nfsinstall.o urlinstall.o
OBJS = log.o moduleinfo.o loadermisc.o modules.o moduledeps.o windows.o \
lang.o kbd.o modules.o modstubs.o driverdisk.o \
- md5.o mediacheck.o \
+ md5.o mediacheck.o kickstart.o \
$(HWOBJS) $(METHOBJS)
LOADEROBJS = loader.o loader-pcmcia.o
NETOBJS = net.o urls.o telnet.o telnetd.o
diff --git a/loader2/cdinstall.c b/loader2/cdinstall.c
index 5a4b4b0fb..38ad03dc7 100644
--- a/loader2/cdinstall.c
+++ b/loader2/cdinstall.c
@@ -362,6 +362,7 @@ char * findRedHatCD(char * location,
/* look for a Red Hat CD and mount it. if we have problems, ask */
char * mountCdromImage(struct installMethod * method,
char * location, struct knownDevices * kd,
+ struct loaderData_s * loaderData,
moduleInfoSet modInfo, moduleList modLoaded,
moduleDeps * modDepsPtr, int flags) {
diff --git a/loader2/cdinstall.h b/loader2/cdinstall.h
index fe49437d9..f7693ab6c 100644
--- a/loader2/cdinstall.h
+++ b/loader2/cdinstall.h
@@ -5,15 +5,16 @@
#include "modules.h"
char * mountCdromImage(struct installMethod * method,
- char * location, struct knownDevices * kd,
- moduleInfoSet modInfo, moduleList modLoaded,
- moduleDeps * modDepsPtr, int flags);
+ char * location, struct knownDevices * kd,
+ struct loaderData_s * loaderData,
+ moduleInfoSet modInfo, moduleList modLoaded,
+ moduleDeps * modDepsPtr, int flags);
char * findRedHatCD(char * location,
- struct knownDevices * kd,
- moduleInfoSet modInfo,
- moduleList modLoaded,
- moduleDeps modDeps,
- int flags);
+ struct knownDevices * kd,
+ moduleInfoSet modInfo,
+ moduleList modLoaded,
+ moduleDeps modDeps,
+ int flags);
#endif
diff --git a/loader2/hdinstall.h b/loader2/hdinstall.h
index 578fd94b7..5e945cbdd 100644
--- a/loader2/hdinstall.h
+++ b/loader2/hdinstall.h
@@ -3,8 +3,9 @@
char * mountHardDrive(struct installMethod * method,
- char * location, struct knownDevices * kd,
- moduleInfoSet modInfo, moduleList modLoaded,
- moduleDeps * modDepsPtr, int flags);
+ char * location, struct knownDevices * kd,
+ struct loaderData_s * loaderData,
+ moduleInfoSet modInfo, moduleList modLoaded,
+ moduleDeps * modDepsPtr, int flags);
#endif
diff --git a/loader2/kbd.c b/loader2/kbd.c
index e3149a29b..94fc6c073 100644
--- a/loader2/kbd.c
+++ b/loader2/kbd.c
@@ -192,3 +192,14 @@ int chooseKeyboard(char ** keymap, char ** kbdtypep, int flags) {
return rc;
}
+
+void setKickstartKeyboard(struct loaderData_s * loaderData, int argc,
+ char ** argv, int * flagsPtr) {
+ if (argc < 2) {
+ logMessage("no argument passed to keyboard kickstart command");
+ return;
+ }
+
+ loaderData->kbd = argv[1];
+ loaderData->kbd_set = 1;
+}
diff --git a/loader2/kbd.h b/loader2/kbd.h
index 35867c9bb..90a4f88b1 100644
--- a/loader2/kbd.h
+++ b/loader2/kbd.h
@@ -2,5 +2,7 @@
#define H_KBD
int chooseKeyboard(char ** keymap, char ** kbdtypep, int flags);
+void setKickstartKeyboard(struct loaderData_s * loaderData, int argc,
+ char ** argv, int * flagsPtr);
#endif
diff --git a/loader2/lang.c b/loader2/lang.c
index 47aa15d7e..3291f69dc 100644
--- a/loader2/lang.c
+++ b/loader2/lang.c
@@ -326,3 +326,14 @@ int chooseLanguage(char ** lang, int flags) {
return 0;
}
+void setKickstartLanguage(struct loaderData_s * loaderData, int argc,
+ char ** argv, int * flagsPtr) {
+ if (argc < 2) {
+ logMessage("no argument passed to lang kickstart command");
+ return;
+ }
+
+ loaderData->lang = argv[1];
+ loaderData->lang_set = 1;
+
+}
diff --git a/loader2/lang.h b/loader2/lang.h
index 405f955f8..808c8cc0e 100644
--- a/loader2/lang.h
+++ b/loader2/lang.h
@@ -1,6 +1,8 @@
#ifndef _LANG_H_
#define _LANG_H_
+#include "loader.h"
+
#define _(x) translateString (x)
#define N_(foo) (foo)
@@ -14,5 +16,7 @@ char * translateString(char * str);
void setLanguage (char * key, int flags);
int getLangInfo(struct langInfo **langs, int flags);
+void setKickstartLanguage(struct loaderData_s * loaderData, int argc,
+ char ** argv, int * flagsPtr);
#endif /* _LANG_H_ */
diff --git a/loader2/loader.c b/loader2/loader.c
index a57dcc670..f8e9539ce 100644
--- a/loader2/loader.c
+++ b/loader2/loader.c
@@ -45,6 +45,7 @@
#include "log.h"
#include "lang.h"
#include "kbd.h"
+#include "kickstart.h"
#include "windows.h"
/* module stuff */
@@ -83,24 +84,26 @@ static int newtRunning = 0;
#endif
#ifdef INCLUDE_NETWORK
char * mountNfsImage(struct installMethod * method,
- char * location, struct knownDevices * kd,
- moduleInfoSet modInfo, moduleList modLoaded,
- moduleDeps * modDepsPtr, int flags);
+ char * location, struct knownDevices * kd,
+ struct loaderData_s * loaderData,
+ moduleInfoSet modInfo, moduleList modLoaded,
+ moduleDeps * modDepsPtr, int flags);
char * mountUrlImage(struct installMethod * method,
- char * location, struct knownDevices * kd,
- moduleInfoSet modInfo, moduleList modLoaded,
- moduleDeps * modDepsPtr, int flags);
+ char * location, struct knownDevices * kd,
+ struct loaderData_s * loaderData,
+ moduleInfoSet modInfo, moduleList modLoaded,
+ moduleDeps * modDepsPtr, int flags);
#endif
static struct installMethod installMethods[] = {
#if defined(INCLUDE_LOCAL)
- { N_("Local CDROM"), 0, CLASS_CDROM, mountCdromImage },
- { N_("Hard drive"), 0, CLASS_HD, mountHardDrive },
+ { N_("Local CDROM"), "cdrom", 0, CLASS_CDROM, mountCdromImage },
+ { N_("Hard drive"), "hd", 0, CLASS_HD, mountHardDrive },
#endif
#if defined(INCLUDE_NETWORK)
- { N_("NFS image"), 1, CLASS_NETWORK, mountNfsImage },
- { "FTP", 1, CLASS_NETWORK, mountUrlImage },
- { "HTTP", 1, CLASS_NETWORK, mountUrlImage },
+ { N_("NFS image"), "nfs", 1, CLASS_NETWORK, mountNfsImage },
+ { "FTP", "ftp", 1, CLASS_NETWORK, mountUrlImage },
+ { "HTTP", "http", 1, CLASS_NETWORK, mountUrlImage },
#endif
};
static int numMethods = sizeof(installMethods) / sizeof(struct installMethod);
@@ -454,7 +457,8 @@ static void ideSetup(moduleList modLoaded, moduleDeps modDeps,
/* parses /proc/cmdline for any arguments which are important to us.
* NOTE: in test mode, can specify a cmdline with --cmdline
*/
-static int parseCmdLineFlags(int flags, char * cmdLine, char * extraArgs[]) {
+static int parseCmdLineFlags(int flags, struct loaderData_s * loaderData,
+ char * cmdLine, char * extraArgs[]) {
int fd;
char buf[500];
int len;
@@ -517,12 +521,48 @@ static int parseCmdLineFlags(int flags, char * cmdLine, char * extraArgs[]) {
else if (!strncasecmp(argv[i], "debug=", 6))
setLogLevel(strtol(argv[i] + 6, (char **)NULL, 10));
/*JKFIXME: add back kickstart stuff */
- else if (!strncasecmp(argv[i], "ksdevice=", 9))
- /* JKFIXME: *ksDevice = argv[i] + 9; */
- argv[i] + 9;
+ else if (!strncasecmp(argv[i], "ksdevice=", 9)) {
+ loaderData->netDev = strdup(argv[i] + 9);
+ loaderData->netDev_set = 1;
+ }
+ /* JKFIXME: this isn't quite right... */
+ else if (!strcasecmp(argv[i], "ks") || !strncasecmp(argv[i], "ks=", 3))
+ loaderData->ksFile = strdup(argv[i]);
else if (!strncasecmp(argv[i], "display=", 8))
setenv("DISPLAY", argv[i] + 8, 1);
- /* JKFIXME: handle lang= somehow */
+ else if (!strncasecmp(argv[i], "lang=", 5)) {
+ loaderData->lang = strdup(argv[i] + 5);
+ loaderData->lang_set = 1;
+ } else if (!strncasecmp(argv[i], "keymap=", 7)) {
+ loaderData->kbd = strdup(argv[i] + 7);
+ loaderData->kbd_set = 1;
+ } else if (!strncasecmp(argv[i], "method=", 7)) {
+ char * c;
+ loaderData->method = strdup(argv[i] + 7);
+
+ c = loaderData->method;
+ /* : will let us delimit real information on the method */
+ if ((c = strtok(c, ":"))) {
+ c = strtok(NULL, ":");
+ /* JKFIXME: handle other methods too, and not here... */
+ if (!strcmp(loaderData->method, "nfs")) {
+ loaderData->methodData = calloc(sizeof(struct nfsInstallData *), 1);
+ ((struct nfsInstallData *)loaderData->methodData)->host = c;
+ if ((c = strtok(NULL, ":"))) {
+ ((struct nfsInstallData *)loaderData->methodData)->directory = c;
+ }
+ }
+ }
+ } else if (!strncasecmp(argv[i], "ip=", 3)) {
+ loaderData->ip = strdup(argv[i] + 3);
+ /* JKFIXME: ??? */
+ loaderData->ipinfo_set = 1;
+ } else if (!strncasecmp(argv[i], "netmask=", 8))
+ loaderData->netmask = strdup(argv[i] + 8);
+ else if (!strncasecmp(argv[i], "gateway=", 8))
+ loaderData->gateway = strdup(argv[i] + 8);
+ else if (!strncasecmp(argv[i], "dns=", 4))
+ loaderData->dns = strdup(argv[i] + 4);
else if (numExtraArgs < (MAX_EXTRA_ARGS - 1)) {
/* go through and append args we just want to pass on to */
/* the anaconda script, but don't want to represent as a */
@@ -642,6 +682,7 @@ static void checkForRam(int flags) {
/* fsm for the basics of the loader. */
static char *doLoaderMain(char * location,
+ struct loaderData_s * loaderData,
struct knownDevices * kd,
moduleInfoSet modInfo,
moduleList modLoaded,
@@ -656,18 +697,19 @@ static char *doLoaderMain(char * location,
char * installNames[10]; /* 10 install methods will be enough for anyone */
int numValidMethods = 0;
int validMethods[10];
- int methodNum;
+ int methodNum = -1;
- char *lang = NULL;
- char * keymap = NULL;
char * kbdtype = NULL;
- /* JKFIXME: if this were the old code, we'd do checking about local
- * vs network install methods here. do we still want to do that or
- * just nuke that code? */
- for (i = 0; i < numMethods; i++) {
+ for (i = 0; i < numMethods; i++, numValidMethods++) {
installNames[numValidMethods] = _(installMethods[i].name);
- validMethods[numValidMethods++] = i;
+ validMethods[numValidMethods] = i;
+
+ /* have we preselected this to be our install method? */
+ if (loaderData->method &&
+ !strcmp(loaderData->method, installMethods[i].shortname)) {
+ methodNum = numValidMethods;
+ }
}
installNames[numValidMethods] = NULL;
@@ -677,7 +719,6 @@ static char *doLoaderMain(char * location,
* text mode. */
/* JKFIXME: what should we do about rescue mode here? */
if (!FL_ASKMETHOD(flags) && !FL_KICKSTART(flags)) {
- /* JKFIXME: this might not work right... */
url = findRedHatCD(location, kd, modInfo, modLoaded, * modDepsPtr, flags);
if (url) return url;
}
@@ -689,13 +730,30 @@ static char *doLoaderMain(char * location,
while (step != STEP_DONE) {
switch(step) {
case STEP_LANG:
- chooseLanguage(&lang, flags);
- /* JKFIXME: default lang stuff so that we only sometimes pass lang? */
+ if (loaderData->lang && (loaderData->lang_set == 1)) {
+ setLanguage(loaderData->lang, flags);
+ } else {
+ chooseLanguage(&loaderData->lang, flags);
+ }
step = STEP_KBD;
dir = 1;
break;
case STEP_KBD:
- rc = chooseKeyboard(&keymap, &kbdtype, flags);
+ if (loaderData->kbd && (loaderData->kbd_set == 1)) {
+ /* JKFIXME: this is broken -- we should tell of the
+ * failure; best by pulling code out in kbd.c to use */
+ if (isysLoadKeymap(loaderData->kbd)) {
+ logMessage("requested keymap %s is not valid, asking", loaderData->kbd);
+ loaderData->kbd = NULL;
+ loaderData->kbd_set = 0;
+ break;
+ }
+ rc = LOADER_NOOP;
+ } else {
+ /* JKFIXME: should handle kbdtype, too probably... but it
+ * just matters for sparc */
+ rc = chooseKeyboard(&loaderData->kbd, &kbdtype, flags);
+ }
if (rc == LOADER_NOOP) {
if (dir == -1)
step = STEP_LANG;
@@ -715,15 +773,19 @@ static char *doLoaderMain(char * location,
break;
case STEP_METHOD:
- rc = newtWinMenu(FL_RESCUE(flags) ? _("Rescue Method") :
- _("Installation Method"),
- FL_RESCUE(flags) ?
- _("What type of media contains the rescue "
- "image?") :
- _("What type of media contains the packages to "
- "be installed?"),
- 30, 10, 20, 6, installNames, &methodNum,
- _("OK"), _("Back"), NULL);
+ if (loaderData->method && (methodNum != -1)) {
+ rc = 1;
+ } else {
+ rc = newtWinMenu(FL_RESCUE(flags) ? _("Rescue Method") :
+ _("Installation Method"),
+ FL_RESCUE(flags) ?
+ _("What type of media contains the rescue "
+ "image?") :
+ _("What type of media contains the packages to "
+ "be installed?"),
+ 30, 10, 20, 6, installNames, &methodNum,
+ _("OK"), _("Back"), NULL);
+ }
if (rc && rc != 1) {
step = STEP_KBD;
dir = -1;
@@ -766,7 +828,7 @@ static char *doLoaderMain(char * location,
logMessage("starting to STEP_URL");
url = installMethods[validMethods[methodNum]].mountImage(
installMethods + validMethods[methodNum],
- location, kd, modInfo, modLoaded,
+ location, kd, loaderData, modInfo, modLoaded,
modDepsPtr, flags);
logMessage("got url %s", url);
if (!url) {
@@ -808,6 +870,8 @@ int main(int argc, char ** argv) {
char * anacondaArgs[50];
int useRHupdates = 0;
+ struct loaderData_s loaderData;
+
char * cmdLine = NULL;
char * ksFile = NULL;
int testing = 0;
@@ -828,22 +892,19 @@ int main(int argc, char ** argv) {
secondStageModuleLocation = malloc(sizeof(struct moduleBallLocation));
secondStageModuleLocation->path = strdup("/mnt/runtime/modules/modules.cgz");
-
-
- /* JKFIXME: need to do multiplex command stuff for insmod, etc here */
if (!strcmp(argv[0] + strlen(argv[0]) - 6, "insmod"))
- return ourInsmodCommand(argc, argv);
+ return ourInsmodCommand(argc, argv);
if (!strcmp(argv[0] + strlen(argv[0]) - 8, "modprobe"))
- return ourInsmodCommand(argc, argv);
+ return ourInsmodCommand(argc, argv);
if (!strcmp(argv[0] + strlen(argv[0]) - 5, "rmmod"))
- return combined_insmod_main(argc, argv);
-
+ return combined_insmod_main(argc, argv);
+
/* The fstat checks disallows serial console if we're running through
a pty. This is handy for Japanese. */
fstat(0, &sb);
if (major(sb.st_rdev) != 3 && major(sb.st_rdev) != 136) {
- if (ioctl (0, TIOCLINUX, &twelve) < 0)
- flags |= LOADER_FLAGS_SERIAL;
+ if (ioctl (0, TIOCLINUX, &twelve) < 0)
+ flags |= LOADER_FLAGS_SERIAL;
}
/* now we parse command line options */
@@ -873,10 +934,12 @@ int main(int argc, char ** argv) {
openLog(FL_TESTING(flags));
if (!FL_TESTING(flags))
- openlog("loader", 0, LOG_LOCAL0);
+ openlog("loader", 0, LOG_LOCAL0);
+
+ memset(&loaderData, 0, sizeof(loaderData));
extraArgs[0] = NULL;
- flags = parseCmdLineFlags(flags, cmdLine, extraArgs);
+ flags = parseCmdLineFlags(flags, &loaderData, cmdLine, extraArgs);
if (FL_SERIAL(flags) && !getenv("DISPLAY"))
flags |= LOADER_FLAGS_TEXT;
@@ -936,11 +999,21 @@ int main(int argc, char ** argv) {
busProbe(modInfo, modLoaded, modDeps, probeOnly, &kd, flags);
- /* JKFIXME: all sorts of crap to handle kickstart sources now... */
+ /* JKFIXME: loaderData->ksFile is set to the arg from the command line,
+ * and then getKickstartFile() changes it and sets FL_KICKSTART.
+ * kind of weird. */
+ if (loaderData.ksFile) {
+ logMessage("getting kickstart file");
+ getKickstartFile(&loaderData, &flags);
+ if (FL_KICKSTART(flags) &&
+ (ksReadCommands(loaderData.ksFile) != LOADER_ERROR)) {
+ setupKickstart(&loaderData, &flags);
+ }
+ }
/* JKFIXME: telnetd */
- url = doLoaderMain("/mnt/source", &kd, modInfo, modLoaded, &modDeps, flags);
+ url = doLoaderMain("/mnt/source", &loaderData, &kd, modInfo, modLoaded, &modDeps, flags);
if (!FL_TESTING(flags)) {
unlink("/usr");
@@ -1078,19 +1151,16 @@ int main(int argc, char ** argv) {
if (FL_KICKSTART(flags)) {
*argptr++ = "--kickstart";
- *argptr++ = ksFile;
+ *argptr++ = loaderData.ksFile;
}
- /* JKFIXME: obviously this needs to come back... */
-#if 0
- if (!lang)
- lang = getenv ("LC_ALL");
-
- if (lang && !defaultLang && !FL_NOPASS(flags)) {
+ if (loaderData.lang && (loaderData.lang_set == 1) &&
+ !FL_NOPASS(flags)) {
*argptr++ = "--lang";
- *argptr++ = lang;
+ *argptr++ = loaderData.lang;
}
-
+
+#if 0
if (keymap && !FL_NOPASS(flags)) {
*argptr++ = "--keymap";
*argptr++ = keymap;
diff --git a/loader2/loader.h b/loader2/loader.h
index 720e70e48..a282f637b 100644
--- a/loader2/loader.h
+++ b/loader2/loader.h
@@ -1,3 +1,6 @@
+#ifndef LOADER_H
+#define LOADER_H
+
#define LOADER_OK 0
#define LOADER_BACK 1
#define LOADER_NOOP 2
@@ -75,3 +78,24 @@ int setupRamdisk(void);
#else
#define RAMDISK_DEVICE "/dev/ram2"
#endif
+
+
+/* JKFIXME: I don't like all of the _set attribs, but without them,
+ * we can't tell if it was explicitly set by kickstart/cmdline or
+ * if we just got it going through the install. */
+struct loaderData_s {
+ char * lang;
+ int lang_set;
+ char * kbd;
+ int kbd_set;
+ char * netDev;
+ int netDev_set;
+ char * ip, * netmask, *gateway, *dns, *hostname;
+ int noDns;
+ int ipinfo_set;
+ char * ksFile;
+ char * method;
+ void * methodData;
+};
+
+#endif
diff --git a/loader2/method.h b/loader2/method.h
index 39e1047d7..af7df03b9 100644
--- a/loader2/method.h
+++ b/loader2/method.h
@@ -4,13 +4,16 @@
#include "../isys/probe.h"
#include "modules.h"
#include "moduledeps.h"
+#include "loader.h"
struct installMethod {
char * name;
+ char * shortname;
int network;
enum deviceClass deviceType; /* for pcmcia */
char * (*mountImage)(struct installMethod * method,
char * location, struct knownDevices * kd,
+ struct loaderData_s * loaderData,
moduleInfoSet modInfo, moduleList modLoaded,
moduleDeps * modDepsPtr, int flags);
};
@@ -33,4 +36,13 @@ int copyFileAndLoopbackMount(int fd, char * dest, int flags,
void copyUpdatesImg(char * path);
int copyDirectory(char * from, char * to);
+
+/* JKFIXME: nfs specific */
+struct nfsInstallData {
+ char * host;
+ char * directory;
+};
+void setKickstartNfs(struct loaderData_s * loaderData, int argc,
+ char ** argv, int * flagsPtr);
+
#endif
diff --git a/loader2/modstubs.c b/loader2/modstubs.c
index 79de5f323..9e3f71f2a 100644
--- a/loader2/modstubs.c
+++ b/loader2/modstubs.c
@@ -24,12 +24,11 @@
#include <sys/utsname.h>
#include <sys/wait.h>
+#include "modstubs.h"
+
#include "../isys/cpio.h"
#include "../isys/stubs.h"
-/* hack */
-int combined_insmod_main(int argc, char ** argv);
-
int ourInsmodCommand(int argc, char ** argv) {
char * file;
char finalName[100];
diff --git a/loader2/modstubs.h b/loader2/modstubs.h
index a03c17aea..0ea68bd12 100644
--- a/loader2/modstubs.h
+++ b/loader2/modstubs.h
@@ -5,4 +5,7 @@ int ourInsmodCommand(int argc, char ** argv);
int rmmod(char * modName);
int insmod(char * modName, char * path, char ** args);
+/* hack */
+int combined_insmod_main(int argc, char ** argv);
+
#endif
diff --git a/loader2/net.c b/loader2/net.c
index ebbbbe116..362d6bada 100644
--- a/loader2/net.c
+++ b/loader2/net.c
@@ -19,8 +19,6 @@
*
*/
-/* JKFIXME: clean this file up to get rid of crappy __standalone__ defines */
-
#include <arpa/inet.h>
#include <errno.h>
#include <popt.h>
@@ -168,6 +166,68 @@ static int getDnsServers(struct networkDeviceConfig * cfg) {
return LOADER_OK;
}
+void setupNetworkDeviceConfig(struct networkDeviceConfig * cfg,
+ struct loaderData_s * loaderData) {
+ struct in_addr addr;
+
+ if (loaderData->ipinfo_set == 0) {
+ return;
+ }
+
+ if (loaderData->ip) {
+ /* this is how we specify dhcp */
+ if (!strncmp(loaderData->ip, "dhcp", 4)) {
+ char * chptr;
+ /* JKFIXME: this soooo doesn't belong here. and it needs to
+ * be broken out into a function too */
+ logMessage("sending dhcp request through device %s", loaderData->netDev);
+ winStatus(50, 3, _("Dynamic IP"),
+ _("Sending request for IP information for %s"),
+ loaderData->netDev, 0);
+
+ chptr = pumpDhcpRun(loaderData->netDev, 0, 0, NULL, &cfg->dev, NULL);
+ newtPopWindow();
+ if (chptr) {
+ logMessage("pump told us: %s", chptr);
+ return;
+ }
+
+ cfg->isDynamic = 1;
+ } else if (inet_aton(loaderData->ip, &addr)) {
+ cfg->dev.ip = addr;
+ cfg->dev.set |= PUMP_INTFINFO_HAS_IP;
+ cfg->isDynamic = 0;
+ }
+ cfg->preset = 1;
+ }
+
+ if (loaderData->netmask && (inet_aton(loaderData->netmask, &addr))) {
+ cfg->dev.netmask = addr;
+ cfg->dev.set |= PUMP_INTFINFO_HAS_NETMASK;
+ }
+
+ if (loaderData->gateway && (inet_aton(loaderData->gateway, &addr))) {
+ cfg->dev.gateway = addr;
+ cfg->dev.set |= PUMP_NETINFO_HAS_GATEWAY;
+ }
+
+ if (loaderData->dns && (inet_aton(loaderData->dns, &addr))) {
+ cfg->dev.dnsServers[0] = addr;
+ cfg->dev.numDns = 1;
+ cfg->dev.set |= PUMP_NETINFO_HAS_DNS;
+ }
+
+ if (loaderData->hostname) {
+ logMessage("setting specified hostname of %s", loaderData->hostname);
+ cfg->dev.hostname = strdup(loaderData->hostname);
+ cfg->dev.set |= PUMP_NETINFO_HAS_HOSTNAME;
+ }
+
+ cfg->noDns = loaderData->noDns;
+
+ logMessage("we set up ip information via kickstart");
+}
+
int readNetConfig(char * device, struct networkDeviceConfig * cfg, int flags) {
newtComponent text, f, okay, back, answer, dhcpCheckbox;
newtGrid grid, subgrid, buttons;
@@ -178,6 +238,18 @@ int readNetConfig(char * device, struct networkDeviceConfig * cfg, int flags) {
char dhcpChoice;
char * chptr;
+ /* JKFIXME: this is horribly inconsistent -- all of the other loaderData
+ * gets acted on even if I'm not in kickstart... */
+ if (FL_KICKSTART(flags) && !FL_TESTING(flags) && cfg->preset) {
+ logMessage("doing kickstart... setting it up");
+ configureNetwork(cfg);
+ findHostAndDomain(cfg, flags);
+
+ if (!cfg->noDns)
+ writeResolvConf(cfg);
+ return 0;
+ }
+
/* JKFIXME: I do NOT like this crap */
#if !defined(__s390__) && !defined(__s390x__)
text = newtTextboxReflowed(-1, -1,
@@ -515,147 +587,93 @@ int findHostAndDomain(struct networkDeviceConfig * dev, int flags) {
return 0;
}
-/* JKFIXME: kickstart not implemented yet */
-#if 0
-int kickstartNetwork(char ** devicePtr, struct networkDeviceConfig * netDev,
- char * bootProto, int flags) {
- char ** ksArgv;
- int ksArgc;
- int netSet, rc;
- char * arg, * chptr;
- char * kshostname=NULL;
+void setKickstartNetwork(struct loaderData_s * loaderData, int argc,
+ char ** argv, int * flagsPtr) {
+ char * arg, * bootProto, * device;
+ int noDns = 0, rc;
poptContext optCon;
- struct in_addr * parseAddress;
- int noDns = 0;
- char * device;
+
struct poptOption ksOptions[] = {
- { "bootproto", '\0', POPT_ARG_STRING, &bootProto, 0 },
- { "device", '\0', POPT_ARG_STRING, devicePtr, 0 },
- { "gateway", '\0', POPT_ARG_STRING, NULL, 'g' },
- { "ip", '\0', POPT_ARG_STRING, NULL, 'i' },
- { "nameserver", '\0', POPT_ARG_STRING, NULL, 'n' },
- { "netmask", '\0', POPT_ARG_STRING, NULL, 'm' },
- { "nodns", '\0', POPT_ARG_NONE, &noDns, 0 },
- { "hostname", '\0', POPT_ARG_STRING, NULL, 'h'},
- { 0, 0, 0, 0, 0 }
+ { "bootproto", '\0', POPT_ARG_STRING, &bootProto, 0 },
+ { "device", '\0', POPT_ARG_STRING, &device, 0 },
+ { "gateway", '\0', POPT_ARG_STRING, NULL, 'g' },
+ { "ip", '\0', POPT_ARG_STRING, NULL, 'i' },
+ { "nameserver", '\0', POPT_ARG_STRING, NULL, 'n' },
+ { "netmask", '\0', POPT_ARG_STRING, NULL, 'm' },
+ { "nodns", '\0', POPT_ARG_NONE, &noDns, 0 },
+ { "hostname", '\0', POPT_ARG_STRING, NULL, 'h'},
+ { 0, 0, 0, 0, 0 }
};
-
- if (!bootProto) {
- if (ksGetCommand(KS_CMD_NETWORK, NULL, &ksArgc, &ksArgv)) {
- /* This is for compatibility with RH 5.0 */
- ksArgv = alloca(sizeof(*ksArgv) * 1);
- ksArgv[0] = "network";
- ksArgc = 1;
- }
-
- optCon = poptGetContext(NULL, ksArgc, (const char **) ksArgv, ksOptions, 0);
- while ((rc = poptGetNextOpt(optCon)) >= 0) {
- parseAddress = NULL;
- netSet = 0;
-
- arg = (char *) poptGetOptArg(optCon);
-
- switch (rc) {
- case 'g':
- parseAddress = &netDev->dev.gateway;
- netSet = PUMP_NETINFO_HAS_GATEWAY;
- break;
-
- case 'i':
- parseAddress = &netDev->dev.ip;
- netSet = PUMP_INTFINFO_HAS_IP;
- break;
-
- case 'n':
- parseAddress = &netDev->dev.dnsServers[netDev->dev.numDns++];
- netSet = PUMP_NETINFO_HAS_DNS;
- break;
-
- case 'm':
- parseAddress = &netDev->dev.netmask;
- netSet = PUMP_INTFINFO_HAS_NETMASK;
- break;
-
- case 'h':
- if (kshostname)
- free(kshostname);
- kshostname = strdup(arg);
- logMessage("netDev->dev.hostname = %s", kshostname);
- break;
- }
-
- if (parseAddress && !inet_aton(arg, parseAddress)) {
- logMessage("bad ip number in network command: %s", arg);
- return -1;
- }
-
- netDev->dev.set |= netSet;
+
+ logMessage("kickstartNetwork");
+ optCon = poptGetContext(NULL, argc, (const char **) argv,
+ ksOptions, 0);
+ while ((rc = poptGetNextOpt(optCon)) >= 0) {
+ arg = (char *) poptGetOptArg(optCon);
+
+ switch (rc) {
+ case 'g':
+ loaderData->gateway = strdup(arg);
+ break;
+ case 'i':
+ loaderData->ip = strdup(arg);
+ break;
+ case 'n':
+ loaderData->dns = strdup(arg);
+ break;
+ case 'm':
+ loaderData->netmask = strdup(arg);
+ break;
+ case 'h':
+ if (loaderData->hostname)
+ free(loaderData->hostname);
+ loaderData->hostname = strdup(arg);
+ break;
}
+ }
- if (rc < -1) {
- newtWinMessage(_("kickstart"), _("OK"),
- _("bad argument to kickstart network command %s: %s"),
+ if (rc < -1) {
+ newtWinMessage(_("Kickstart Error"), _("OK"),
+ _("Bad argument to kickstart network command %s: %s"),
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
poptStrerror(rc));
- } else {
- poptFreeContext(optCon);
- }
- }
-
- device = *devicePtr;
-
- if (!bootProto)
- bootProto = "dhcp";
-
- if (!strcmp(bootProto, "dhcp") || !strcmp(bootProto, "bootp")) {
- logMessage("sending dhcp request through device %s", device);
- winStatus(50, 3, _("Dynamic IP"),
- _("Sending request for IP information..."),
- 0);
-
- chptr = pumpDhcpRun(device, 0, 0, NULL, &netDev->dev, NULL);
- newtPopWindow();
- if (chptr) {
- logMessage("pump told us: %s", chptr);
- return -1;
- }
- netDev->isDynamic = 1;
- } else if (!strcmp(bootProto, "static")) {
- strcpy(netDev->dev.device, device);
- } else if (!strcmp(bootProto, "query")) {
- strcpy(netDev->dev.device, device);
- readNetConfig("eth0", netDev, flags);
} else {
- newtWinMessage(_("kickstart"), _("OK"),
- _("Bad bootproto %s specified in network command"),
- bootProto);
- return -1;
+ poptFreeContext(optCon);
}
- fillInIpInfo(netDev);
- configureNetwork(netDev);
-
- logMessage("nodns is %d", noDns);
-
- if (kshostname) {
- logMessage("setting ks specified hostname of %s", kshostname);
- netDev->dev.hostname=strdup(kshostname);
- netDev->dev.set |= PUMP_NETINFO_HAS_HOSTNAME;
+ /* if they've specified dhcp/bootp or haven't specified anything,
+ * use dhcp for the interface */
+ if (!strncmp(bootProto, "dhcp", 4) || !strncmp(bootProto, "bootp", 4) ||
+ (!bootProto && !loaderData->ip)) {
+ loaderData->ip = strdup("dhcp");
+ loaderData->ipinfo_set = 1;
+ } else if (loaderData->ip) {
+ /* JKFIXME: this assumes a bit... */
+ loaderData->ipinfo_set = 1;
}
- if (!noDns)
- findHostAndDomain(netDev, flags);
+ /* now make sure the specified bootproto is valid */
+ if (bootProto && strcmp(bootProto, "dhcp") && strcmp(bootProto, "bootp") &&
+ strcmp(bootProto, "static") && strcmp(bootProto, "query")) {
+ newtWinMessage(_("Kickstart Error"), _("OK"),
+ _("Bad bootproto %s specified in network command"),
+ bootProto);
+ }
+
+ if (device) {
+ loaderData->netDev = strdup(device);
+ loaderData->netDev_set = 1;
+ }
- writeResolvConf(netDev);
+ if (noDns) {
+ loaderData->noDns = 1;
+ }
- return 0;
}
-#endif /* 0 for no kickstart right now */
-
-
-int chooseNetworkInterface(struct knownDevices * kd, char ** devNamePtr,
+int chooseNetworkInterface(struct knownDevices * kd,
+ struct loaderData_s * loaderData,
int flags) {
int i, rc;
int deviceNums = 0;
@@ -669,6 +687,12 @@ int chooseNetworkInterface(struct knownDevices * kd, char ** devNamePtr,
continue;
devices[deviceNums++] = kd->known[i].name;
+
+ /* this device has been set and we don't really need to ask
+ * about it again... */
+ if (loaderData->netDev && (loaderData->netDev_set == 1) &&
+ !strcmp(loaderData->netDev, kd->known[i].name))
+ return LOADER_NOOP;
}
devices[deviceNums] = NULL;
@@ -682,7 +706,7 @@ int chooseNetworkInterface(struct knownDevices * kd, char ** devNamePtr,
/* JKFIXME: if we only have one interface and it doesn't have link,
* do we go ahead? */
if (deviceNums == 1) {
- *devNamePtr = devices[0];
+ loaderData->netDev = devices[0];
return LOADER_NOOP;
}
@@ -698,7 +722,7 @@ int chooseNetworkInterface(struct knownDevices * kd, char ** devNamePtr,
if (rc == 2)
return LOADER_BACK;
- *devNamePtr = devices[deviceNum];
+ loaderData->netDev = devices[deviceNum];
return LOADER_OK;
}
diff --git a/loader2/net.h b/loader2/net.h
index a7040f137..de1070901 100644
--- a/loader2/net.h
+++ b/loader2/net.h
@@ -1,12 +1,15 @@
#ifndef H_LOADER_NET
#define H_LOADER_NET
+#include "loader.h"
#include "pump.h"
#include "../isys/probe.h"
struct networkDeviceConfig {
struct pumpNetIntf dev;
int isDynamic;
+ int noDns;
+ int preset;
};
int readNetConfig(char * device, struct networkDeviceConfig * dev,
@@ -18,10 +21,14 @@ int findHostAndDomain(struct networkDeviceConfig * dev, int flags);
int writeResolvConf(struct networkDeviceConfig * net);
extern char *netServerPrompt;
int nfsGetSetup(char ** hostptr, char ** dirptr);
-int kickstartNetwork(char ** devicePtr, struct networkDeviceConfig * netDev,
- char * bootProto, int flags);
void initLoopback(void);
-int chooseNetworkInterface(struct knownDevices * kd, char ** devNamePtr,
+int chooseNetworkInterface(struct knownDevices * kd,
+ struct loaderData_s * loaderData,
int flags);
+void setupNetworkDeviceConfig(struct networkDeviceConfig * cfg,
+ struct loaderData_s * loaderData);
+
+void setKickstartNetwork(struct loaderData_s * loaderData, int argc,
+ char ** argv, int * flagsPtr);
#endif
diff --git a/loader2/nfsinstall.c b/loader2/nfsinstall.c
index 3ca1b2e4a..8f3a54180 100644
--- a/loader2/nfsinstall.c
+++ b/loader2/nfsinstall.c
@@ -18,6 +18,7 @@
#include <fcntl.h>
#include <newt.h>
+#include <popt.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -69,6 +70,7 @@ int nfsGetSetup(char ** hostptr, char ** dirptr) {
char * mountNfsImage(struct installMethod * method,
char * location, struct knownDevices * kd,
+ struct loaderData_s * loaderData,
moduleInfoSet modInfo, moduleList modLoaded,
moduleDeps * modDepsPtr, int flags) {
static struct networkDeviceConfig netDev;
@@ -90,17 +92,21 @@ char * mountNfsImage(struct installMethod * method,
memset(&netDev, 0, sizeof(netDev));
netDev.isDynamic = 1;
+ setupNetworkDeviceConfig(&netDev, loaderData);
+
/* JKFIXME: ASSERT -- we have a network device when we get here */
while (stage != NFS_STAGE_DONE) {
switch (stage) {
case NFS_STAGE_IFACE:
logMessage("going to pick interface");
- rc = chooseNetworkInterface(kd, &devName, flags);
+ rc = chooseNetworkInterface(kd, loaderData, flags);
if ((rc == LOADER_BACK) || (rc == LOADER_ERROR) ||
((dir == -1) && (rc == LOADER_NOOP))) return NULL;
stage = NFS_STAGE_IP;
dir = 1;
+ logMessage("using interface %s", loaderData->netDev);
+ devName = loaderData->netDev;
break;
case NFS_STAGE_IP:
@@ -116,42 +122,60 @@ char * mountNfsImage(struct installMethod * method,
case NFS_STAGE_NFS:
logMessage("going to do nfsGetSetup");
- if (nfsGetSetup(&host, &directory) == LOADER_BACK) {
+ /* JKFIXME: this is a hack to get kickstart up quicker */
+ if (loaderData->method &&
+ !strncmp(loaderData->method, "nfs", 3) &&
+ loaderData->methodData) {
+ host = ((struct nfsInstallData *)loaderData->methodData)->host;
+ directory = ((struct nfsInstallData *)loaderData->methodData)->directory;
+
+ logMessage("host is %s, dir is %s", host, directory);
+
+ if (!host || !directory) {
+ logMessage("missing host or directory specification");
+ free(loaderData->method);
+ loaderData->method = NULL;
+ break;
+ }
+ } else if (nfsGetSetup(&host, &directory) == LOADER_BACK) {
stage = NFS_STAGE_IP;
dir = -1;
break;
- } else {
- stage = NFS_STAGE_MOUNT;
- dir = 1;
- break;
}
+
+ stage = NFS_STAGE_MOUNT;
+ dir = 1;
+ break;
case NFS_STAGE_MOUNT: {
int foundinvalid = 0;
char * buf;
+ fullPath = alloca(strlen(host) + strlen(directory) + 2);
+ sprintf(fullPath, "%s:%s", host, directory);
+
+ logMessage("mounting nfs path %s", fullPath);
+
if (FL_TESTING(flags)) {
stage = NFS_STAGE_DONE;
dir = 1;
break;
}
- fullPath = alloca(strlen(host) + strlen(directory) + 2);
- sprintf(fullPath, "%s:%s", host, directory);
-
- logMessage("mounting nfs path %s", fullPath);
-
stage = NFS_STAGE_NFS;
if (!doPwMount(fullPath, "/mnt/source", "nfs", 1, 0, NULL, NULL)) {
- logMessage("mounted %s on /mnt/source", fullPath);
+ logMessage("mounted %s on /mnt/source", fullPath);
if (!access("/mnt/source/RedHat/base/stage2.img", R_OK)) {
- logMessage("can access stage2.img");
+ logMessage("can access stage2.img");
rc = mountStage2("/mnt/source/RedHat/base/stage2.img");
- logMessage("after mountStage2, rc is %d", rc);
+ logMessage("after mountStage2, rc is %d", rc);
if (rc) {
umount("/mnt/source");
- if (rc == -1) { foundinvalid = 1; logMessage("not the right one"); }
+ if (rc == -1) {
+ foundinvalid = 1;
+ logMessage("not the right one");
+ }
} else {
stage = NFS_STAGE_DONE;
url = "nfs://mnt/source/.";
@@ -194,6 +218,10 @@ char * mountNfsImage(struct installMethod * method,
newtWinMessage(_("Error"), _("OK"),
_("That directory could not be mounted from "
"the server."));
+ if (loaderData->method) {
+ free(loaderData->method);
+ loaderData->method = NULL;
+ }
break;
}
}
@@ -209,3 +237,36 @@ char * mountNfsImage(struct installMethod * method,
return url;
}
+
+
+void setKickstartNfs(struct loaderData_s * loaderData, int argc,
+ char ** argv, int * flagsPtr) {
+ char * host, * dir;
+ poptContext optCon;
+ int rc;
+ struct poptOption ksNfsOptions[] = {
+ { "server", '\0', POPT_ARG_STRING, &host, 0 },
+ { "dir", '\0', POPT_ARG_STRING, &dir, 0 },
+ { 0, 0, 0, 0, 0 }
+ };
+
+ logMessage("kickstartFromNfs");
+ optCon = poptGetContext(NULL, argc, (const char **) argv, ksNfsOptions, 0);
+ if ((rc = poptGetNextOpt(optCon)) < -1) {
+ newtWinMessage(_("Kickstart Error"), _("OK"),
+ _("Bad argument to NFS kickstart method "
+ "command %s: %s"),
+ poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
+ poptStrerror(rc));
+ return;
+ }
+
+ loaderData->method = strdup("nfs");
+ loaderData->methodData = calloc(sizeof(struct nfsInstallData *), 1);
+ if (host)
+ ((struct nfsInstallData *)loaderData->methodData)->host = host;
+ if (dir)
+ ((struct nfsInstallData *)loaderData->methodData)->directory = dir;
+
+ logMessage("results of nfs, host is %s, dir is %s", host, dir);
+}
diff --git a/loader2/urlinstall.c b/loader2/urlinstall.c
index 3e338aa43..b2b743763 100644
--- a/loader2/urlinstall.c
+++ b/loader2/urlinstall.c
@@ -144,6 +144,7 @@ static char * getLoginName(char * login, struct iurlinfo ui) {
char * mountUrlImage(struct installMethod * method,
char * location, struct knownDevices * kd,
+ struct loaderData_s * loaderData,
moduleInfoSet modInfo, moduleList modLoaded,
moduleDeps * modDeps, int flags) {
int rc;