diff options
author | Erik Troan <ewt@redhat.com> | 1999-09-18 16:12:05 +0000 |
---|---|---|
committer | Erik Troan <ewt@redhat.com> | 1999-09-18 16:12:05 +0000 |
commit | ecbf41b007a8e95394e67d56051b0fcaf9af572c (patch) | |
tree | e74b9c1cc668f11ed1a054f7caf2ef7651e1dcab /loader | |
parent | e6f692d2ca3c95d0b86253a473c0acf21ce69bcb (diff) | |
download | anaconda-ecbf41b007a8e95394e67d56051b0fcaf9af572c.tar.gz anaconda-ecbf41b007a8e95394e67d56051b0fcaf9af572c.tar.xz anaconda-ecbf41b007a8e95394e67d56051b0fcaf9af572c.zip |
first pass at supporting driver disks -- NOT done yet
Diffstat (limited to 'loader')
-rw-r--r-- | loader/devices.c | 182 | ||||
-rw-r--r-- | loader/loader.c | 53 | ||||
-rw-r--r-- | loader/modules.c | 7 | ||||
-rw-r--r-- | loader/modules.h | 3 | ||||
-rw-r--r-- | loader/pcmcia.c | 6 |
5 files changed, 167 insertions, 84 deletions
diff --git a/loader/devices.c b/loader/devices.c index 543ee6eb1..0468c36de 100644 --- a/loader/devices.c +++ b/loader/devices.c @@ -1,14 +1,18 @@ #include <alloca.h> #include <ctype.h> +#include <fcntl.h> #include <newt.h> #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <unistd.h> #include "devices.h" +#include "isys/imount.h" #include "../isys/isys.h" #include "lang.h" #include "loader.h" +#include "misc.h" #include "modules.h" static int getModuleArgs(struct moduleInfo * mod, char *** argPtr) { @@ -21,6 +25,7 @@ static int getModuleArgs(struct moduleInfo * mod, char *** argPtr) { char ** args; int argc; int rc; + char * text; entries = alloca(sizeof(*entries) * (mod->numArgs + 2)); values = alloca(sizeof(*values) * (mod->numArgs + 2)); @@ -51,11 +56,14 @@ static int getModuleArgs(struct moduleInfo * mod, char *** argPtr) { entries[i].text = (void *) entries[i].value = NULL; - rc = newtWinEntries(_("Module Parameters"), _("This module can take " - "parameters which affects its operation. If you don't " - "know what parameters to supply, just skip this " - "screen by pressing the \"OK\" button now."), - 40, 5, 15, 20, entries, _("OK"), _("Back"), NULL); + text = _("This module can take parameters which affects its " + "operation. If you don't know what parameters to supply, " + "just skip this screen by pressing the \"OK\" button " + "now."); + + rc = newtWinEntries(_("Module Parameters"), text, + 40, 5, 15, 20, entries, _("OK"), + _("Back"), NULL); if (rc == 2) { for (i = 0; i < numArgs; i++) @@ -109,50 +117,144 @@ static int getModuleArgs(struct moduleInfo * mod, char *** argPtr) { return 0; } +#define CDD_MOUNT_FAILED 1 +#define CDD_BAD_DISK 2 +static int copyDriverDisk(moduleInfoSet modInfo, moduleList modLoaded, + moduleDeps modDeps, int flags) { + char * files[] = { "modules.cgz", "modinfo", "modules.dep", NULL }; + char * dirName; + char ** file; + int badDisk = 0; + static int diskNum = 0; + char from[200], to[200]; + + mlLoadModule("vfat", NULL, modLoaded, modDeps, NULL, flags); + + devMakeInode("fd0", "/tmp/fd0"); + + if (doPwMount("/tmp/fd0", "/tmp/drivers", "vfat", 1, 0, NULL, NULL)) + return CDD_BAD_DISK; + + if (access("/tmp/drivers/rhdd-6.1", R_OK)) + badDisk = 1; + + dirName = malloc(80); + sprintf(dirName, "/tmp/DD-%d", diskNum); + mkdir(dirName, 0755); + for (file = files; *file; file++) { + sprintf(from, "/tmp/drivers/%s", *file); + sprintf(to, "%s/%s", dirName, *file); + + if (copyFile(from, to)) + badDisk = 1; + } + + umount("/tmp/drivers"); + + if (badDisk) { + return CDD_BAD_DISK; + } + + sprintf(from, "%s/modinfo", dirName); + isysReadModuleInfo(from, modInfo, dirName); + sprintf(from, "%s/modules.dep", dirName); + mlLoadDeps(&modDeps, from); + + diskNum++; + + return 0; +} + +static int setupDriverDisk(moduleInfoSet modInfo, moduleList modLoaded, + moduleDeps modDeps, int flags) { + int rc; + + rc = newtWinChoice(_("Devices"), _("OK"), _("Back"), + _("Insert your driver disk and press \"OK\" to continue.")); + + if (rc == 2) return LOADER_BACK; + + rc = copyDriverDisk(modInfo, modLoaded, modDeps, flags); + + if (rc == CDD_MOUNT_FAILED) + newtWinMessage(_("Error"), _("OK"), _("Failed to mount floppy disk.")); + else if (rc) + newtWinMessage(_("Error"), _("OK"), + _("The floppy disk you inserted is not a valid driver disk " + "for this release of Red Hat Linux.")); + + return 0; +} + static int pickModule(moduleInfoSet modInfo, enum driverMajor type, - moduleList modLoaded, struct moduleInfo * suggestion, - struct moduleInfo ** modp, int * specifyParams) { + moduleList modLoaded, moduleDeps modDeps, + struct moduleInfo * suggestion, + struct moduleInfo ** modp, int * specifyParams, + int flags) { int i; - newtComponent form, text, listbox, answer, checkbox, ok, back; + newtComponent form, text, listbox, checkbox, ok, back; newtGrid buttons, grid, subgrid; char specifyParameters = *specifyParams ? '*' : ' '; - - text = newtTextboxReflowed(-1, -1, _("Which driver should I try?"), - 20, 0, 10, 0); - listbox = newtListbox(-1, -1, 6, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); - - for (i = 0; i < modInfo->numModules; i++) { - if (modInfo->moduleList[i].major == type && - !mlModuleInList(modInfo->moduleList[i].moduleName, modLoaded)) { - newtListboxAppendEntry(listbox, modInfo->moduleList[i].description, - (void *) i); - if (modp && (modInfo->moduleList + i) == *modp) - newtListboxSetCurrentByKey(listbox, (void *) i); + struct newtExitStruct es; + + do { + if (FL_EXPERT(flags) || FL_NOPROBE(flags)) { + text = newtTextboxReflowed(-1, -1, _("Which driver should I try?. " + "If the driver you need does not appear in this list, and " + "you have a separate driver disk, please press F2."), + 30, 0, 10, 0); + } else { + text = newtTextboxReflowed(-1, -1, _("Which driver should I try?"), + 20, 0, 10, 0); } - } - buttons = newtButtonBar(_("OK"), &ok, _("Back"), &back, NULL); - checkbox = newtCheckbox(-1, -1, _("Specify module parameters"), - specifyParameters, NULL, &specifyParameters); - subgrid = newtGridVStacked(NEWT_GRID_COMPONENT, listbox, - NEWT_GRID_COMPONENT, checkbox, NULL); - grid = newtGridBasicWindow(text, subgrid, buttons); + listbox = newtListbox(-1, -1, 6, + NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); - newtGridWrappedWindow(grid, _("Devices")); + buttons = newtButtonBar(_("OK"), &ok, _("Back"), &back, NULL); + checkbox = newtCheckbox(-1, -1, _("Specify module parameters"), + specifyParameters, NULL, &specifyParameters); - form = newtForm(NULL, NULL, 0); - newtGridAddComponentsToForm(grid, form, 1); + form = newtForm(NULL, NULL, 0); - answer = newtRunForm(form); - newtPopWindow(); + if (FL_EXPERT(flags) || FL_NOPROBE(flags)) + newtFormAddHotKey(form, NEWT_KEY_F2); - i = (int) newtListboxGetCurrent(listbox); + for (i = 0; i < modInfo->numModules; i++) { + if (modInfo->moduleList[i].major == type && + !mlModuleInList(modInfo->moduleList[i].moduleName, modLoaded)) { + newtListboxAppendEntry(listbox, + modInfo->moduleList[i].description, + (void *) i); + if (modp && (modInfo->moduleList + i) == *modp) + newtListboxSetCurrentByKey(listbox, (void *) i); + } + } - newtGridFree(grid, 1); - newtFormDestroy(form); + subgrid = newtGridVStacked(NEWT_GRID_COMPONENT, listbox, + NEWT_GRID_COMPONENT, checkbox, NULL); + grid = newtGridBasicWindow(text, subgrid, buttons); + newtGridAddComponentsToForm(grid, form, 1); + newtGridWrappedWindow(grid, _("Devices")); + + newtFormRun(form, &es); + + i = (int) newtListboxGetCurrent(listbox); + + newtGridFree(grid, 1); + newtFormDestroy(form); + newtPopWindow(); + + if (es.reason == NEWT_EXIT_COMPONENT && es.u.co == back) { + return LOADER_BACK; + } else if (es.reason == NEWT_EXIT_HOTKEY && es.u.key == NEWT_KEY_F2) { + setupDriverDisk(modInfo, modLoaded, modDeps, flags); + continue; + } else { + break; + } + } while (1); - if (answer == back) return LOADER_BACK; - *specifyParams = (specifyParameters != ' '); *modp = modInfo->moduleList + i; @@ -171,8 +273,8 @@ int devDeviceMenu(enum driverMajor type, moduleInfoSet modInfo, while (stage != S_DONE) { switch (stage) { case S_MODULE: - if ((rc = pickModule(modInfo, type, modLoaded, mod, &mod, - &specifyArgs))) + if ((rc = pickModule(modInfo, type, modLoaded, modDeps, mod, &mod, + &specifyArgs, flags))) return LOADER_BACK; stage = S_ARGS; break; @@ -196,7 +298,7 @@ int devDeviceMenu(enum driverMajor type, moduleInfoSet modInfo, scsiWindow(mod->moduleName); sleep(1); } - rc = mlLoadModule(mod->moduleName, modLoaded, modDeps, args, + rc = mlLoadModule(mod->moduleName, mod->path, modLoaded, modDeps, args, FL_TESTING(flags)); if (mod->major == DRIVER_SCSI) newtPopWindow(); diff --git a/loader/loader.c b/loader/loader.c index f9c1b995a..f93c8e566 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -48,6 +48,7 @@ #include "lang.h" #include "loader.h" #include "log.h" +#include "misc.h" #include "modules.h" #include "net.h" #include "pcmcia.h" @@ -345,7 +346,7 @@ int busProbe(moduleInfoSet modInfo, moduleList modLoaded, moduleDeps modDeps, printf("%s\n", modList[i]->moduleName); } else { if (modList[i]->major == DRIVER_NET) { - mlLoadModule(modList[i]->moduleName, modLoaded, + mlLoadModule(modList[i]->moduleName, NULL, modLoaded, modDeps, NULL, flags); } } @@ -356,8 +357,8 @@ int busProbe(moduleInfoSet modInfo, moduleList modLoaded, moduleDeps modDeps, startNewt(flags); scsiWindow(modList[i]->moduleName); - mlLoadModule(modList[i]->moduleName, modLoaded, modDeps, - NULL, flags); + mlLoadModule(modList[i]->moduleName, NULL, modLoaded, + modDeps, NULL, flags); sleep(1); newtPopWindow(); } @@ -540,7 +541,7 @@ static char * mountHardDrive(struct installMethod * method, char * url = NULL; int numPartitions; - mlLoadModule("vfat", modLoaded, modDeps, NULL, flags); + mlLoadModule("vfat", NULL, modLoaded, modDeps, NULL, flags); while (!done) { numPartitions = 0; @@ -828,7 +829,7 @@ static char * mountNfsImage(struct installMethod * method, break; } - mlLoadModule("nfs", modLoaded, modDeps, NULL, flags); + mlLoadModule("nfs", NULL, modLoaded, modDeps, NULL, flags); fullPath = alloca(strlen(host) + strlen(dir) + 2); sprintf(fullPath, "%s:%s", host, dir); @@ -1142,7 +1143,7 @@ logMessage("got device command"); else optv = NULL; - rc = mlLoadModule(device, modLoaded, modDeps, optv, flags); + rc = mlLoadModule(device, NULL, modLoaded, modDeps, optv, flags); if (optv) free(optv); if (rc) @@ -1277,7 +1278,7 @@ static char * setupKickstart(char * location, struct knownDevices * kd, #ifdef INCLUDE_NETWORK if (ksType == KS_CMD_NFS) { - mlLoadModule("nfs", modLoaded, modDeps, NULL, flags); + mlLoadModule("nfs", NULL, modLoaded, modDeps, NULL, flags); fullPath = alloca(strlen(host) + strlen(dir) + 2); sprintf(fullPath, "%s:%s", host, dir); @@ -1387,28 +1388,6 @@ struct moduleDependency_s { char ** deps; }; -static int copyFile(char * source, char * dest) { - int infd = -1, outfd = -1; - char buf[4096]; - int i; - - outfd = open(dest, O_CREAT | O_RDWR, 0666); - infd = open(source, O_RDONLY); - - if (infd < 0) { - logMessage("failed to open %s: %s", source, strerror(errno)); - } - - while ((i = read(infd, buf, sizeof(buf))) > 0) { - if (write(outfd, buf, i) != i) break; - } - - close(infd); - close(outfd); - - return 0; -} - int kickstartFromHardDrive(char * location, moduleList modLoaded, moduleDeps modDeps, char * source, int flags) { @@ -1416,7 +1395,7 @@ int kickstartFromHardDrive(char * location, char * fileName; char * fullFn; - mlLoadModule("vfat", modLoaded, modDeps, NULL, flags); + mlLoadModule("vfat", NULL, modLoaded, modDeps, NULL, flags); fileName = strchr(source, '/'); *fileName = '\0'; @@ -1446,7 +1425,7 @@ int kickstartFromHardDrive(char * location, int kickstartFromFloppy(char * location, moduleList modLoaded, moduleDeps modDeps, int flags) { - mlLoadModule("vfat", modLoaded, modDeps, NULL, flags); + mlLoadModule("vfat", NULL, modLoaded, modDeps, NULL, flags); if (devMakeInode("fd0", "/tmp/fd0")) return 1; @@ -1537,7 +1516,7 @@ int main(int argc, char ** argv) { arg = FL_TESTING(flags) ? "./module-info" : "/modules/module-info"; modInfo = isysNewModuleInfoSet(); - if (isysReadModuleInfo(arg, modInfo)) { + if (isysReadModuleInfo(arg, modInfo, NULL)) { fprintf(stderr, "failed to read %s\n", arg); sleep(5); exit(1); @@ -1553,7 +1532,7 @@ int main(int argc, char ** argv) { #ifdef __sparc__ /* XXX: sparc -BOOT kernels should compile openprom in. */ if (!FL_TESTING(flags)) - insmod ("openprom", NULL); + insmod ("openprom", NULL, NULL); #endif if (FL_KSFLOPPY(flags)) { @@ -1625,7 +1604,7 @@ int main(int argc, char ** argv) { mlLoadDeps(&modDeps, "/modules/modules.dep"); modInfo = isysNewModuleInfoSet(); - if (isysReadModuleInfo(arg, modInfo)) { + if (isysReadModuleInfo(arg, modInfo, NULL)) { fprintf(stderr, "failed to read %s\n", arg); sleep(5); exit(1); @@ -1649,9 +1628,9 @@ int main(int argc, char ** argv) { } } - mlLoadModule("raid0", modLoaded, modDeps, NULL, flags); - mlLoadModule("raid1", modLoaded, modDeps, NULL, flags); - mlLoadModule("raid5", modLoaded, modDeps, NULL, flags); + mlLoadModule("raid0", NULL, modLoaded, modDeps, NULL, flags); + mlLoadModule("raid1", NULL, modLoaded, modDeps, NULL, flags); + mlLoadModule("raid5", NULL, modLoaded, modDeps, NULL, flags); stopNewt(); closeLog(); diff --git a/loader/modules.c b/loader/modules.c index 7d32e2877..57b2fa11b 100644 --- a/loader/modules.c +++ b/loader/modules.c @@ -164,7 +164,7 @@ int mlLoadDeps(moduleDeps * moduleDepListPtr, const char * path) { return 0; } -int mlLoadModule(char * modName, moduleList modLoaded, +int mlLoadModule(char * modName, char * path, moduleList modLoaded, moduleDeps modDeps, char ** args, int flags) { moduleDeps dep; char ** nextDep, ** argPtr; @@ -182,7 +182,7 @@ int mlLoadModule(char * modName, moduleList modLoaded, if (dep && dep->deps) { nextDep = dep->deps; while (*nextDep) { - mlLoadModule(*nextDep, modLoaded, modDeps, NULL, flags); + mlLoadModule(*nextDep, NULL, modLoaded, modDeps, NULL, flags); nextDep++; } @@ -201,12 +201,13 @@ int mlLoadModule(char * modName, moduleList modLoaded, rc = 0; } else { logMessage("going to insmod %s", fileName); - rc = insmod(fileName, args); + rc = insmod(fileName, path, args); } if (!rc) { modLoaded->mods[modLoaded->numModules].name = strdup(modName); modLoaded->mods[modLoaded->numModules].weLoaded = 1; + modLoaded->mods[modLoaded->numModules].path = path; if (args) { for (i = 0, arg = args; *arg; arg++, i++); diff --git a/loader/modules.h b/loader/modules.h index a4afcd423..f8a494014 100644 --- a/loader/modules.h +++ b/loader/modules.h @@ -8,6 +8,7 @@ struct loadedModuleInfo { char * name; char ** args; int weLoaded; + char * path; }; struct moduleList_s { @@ -19,7 +20,7 @@ int mlReadLoadedList(moduleList * list); void mlFreeList(moduleList list); int mlLoadDeps(moduleDeps * moduleDepList, const char * path); moduleDeps mlNewDeps(void); -int mlLoadModule(char * modName, moduleList modLoaded, +int mlLoadModule(char * modName, char * path, moduleList modLoaded, moduleDeps modDeps, char ** args, int flags); char ** mlGetDeps(moduleDeps modDeps, const char * modName); int mlModuleInList(const char * modName, moduleList list); diff --git a/loader/pcmcia.c b/loader/pcmcia.c index 61418a1bd..294629224 100644 --- a/loader/pcmcia.c +++ b/loader/pcmcia.c @@ -55,15 +55,15 @@ void startPcmcia(moduleList modLoaded, moduleDeps modDeps, int flags) { logMessage("need to load %s", pcic); - if (mlLoadModule("pcmcia_core", modLoaded, modDeps, NULL, flags)) { + if (mlLoadModule("pcmcia_core", NULL, modLoaded, modDeps, NULL, flags)) { logMessage("failed to load pcmcia_core"); return; } - if (mlLoadModule(pcic, modLoaded, modDeps, NULL, flags)) { + if (mlLoadModule(pcic, NULL, modLoaded, modDeps, NULL, flags)) { logMessage("failed to load pcic"); return; } - if (mlLoadModule("ds", modLoaded, modDeps, NULL, flags)) { + if (mlLoadModule("ds", NULL, modLoaded, modDeps, NULL, flags)) { logMessage("failed to load ds"); return; } |