diff options
-rw-r--r-- | loader/cdrom.c | 6 | ||||
-rw-r--r-- | loader/cdrom.h | 2 | ||||
-rw-r--r-- | loader/devices.c | 109 | ||||
-rw-r--r-- | loader/devices.h | 4 | ||||
-rw-r--r-- | loader/loader.c | 155 | ||||
-rw-r--r-- | loader/loader.h | 2 | ||||
-rw-r--r-- | loader/modules.c | 108 |
7 files changed, 260 insertions, 126 deletions
diff --git a/loader/cdrom.c b/loader/cdrom.c index 482c05212..e4470c651 100644 --- a/loader/cdrom.c +++ b/loader/cdrom.c @@ -44,7 +44,7 @@ static int setupCDdevicePanel(int * type) { } int setupCDdevice(struct knownDevices * kd, moduleInfoSet modInfo, - moduleList modLoaded, moduleDeps modDeps, int flags) { + moduleList modLoaded, moduleDeps * modDepsPtr, int flags) { int type = 0, rc = 0; int i; int done = 0; @@ -56,7 +56,7 @@ int setupCDdevice(struct knownDevices * kd, moduleInfoSet modInfo, switch (type) { case CD_SCSI: - rc = devDeviceMenu(DRIVER_SCSI, modInfo, modLoaded, modDeps, + rc = devDeviceMenu(DRIVER_SCSI, modInfo, modLoaded, modDepsPtr, flags, NULL); if (!rc) { kdFindScsiList(kd); @@ -67,7 +67,7 @@ int setupCDdevice(struct knownDevices * kd, moduleInfoSet modInfo, break; case CD_OTHER: - rc = devDeviceMenu(DRIVER_CDROM, modInfo, modLoaded, modDeps, + rc = devDeviceMenu(DRIVER_CDROM, modInfo, modLoaded, modDepsPtr, flags, &devName); if (!rc) { for (i = 0; transTable[i].modname; i++) { diff --git a/loader/cdrom.h b/loader/cdrom.h index 44c92e18c..96f962a1f 100644 --- a/loader/cdrom.h +++ b/loader/cdrom.h @@ -7,6 +7,6 @@ #include "modules.h" int setupCDdevice(struct knownDevices * kd, moduleInfoSet modInfo, - moduleList modLoaded, moduleDeps modDeps, int flags); + moduleList modLoaded, moduleDeps * modDepsPtr, int flags); #endif diff --git a/loader/devices.c b/loader/devices.c index 4ce27dd3d..0d2db111b 100644 --- a/loader/devices.c +++ b/loader/devices.c @@ -120,46 +120,47 @@ static int getModuleArgs(struct moduleInfo * mod, char *** argPtr) { return 0; } -int devCopyDriverDisk(moduleInfoSet modInfo, moduleList modLoaded, +int devInitDriverDisk(moduleInfoSet modInfo, moduleList modLoaded, moduleDeps *modDepsPtr, int flags, char * mntPoint) { - char * files[] = { "pcitable", "modules.cgz", "modinfo", "modules.dep", - NULL }; - char * dirName; - char ** file; int badDisk = 0; - static int diskNum = 0; - char from[200], to[200]; + char from[200]; + struct stat sb; + char * diskName; + int fd; + char * fileCheck[] = { "rhdd-6.1", "modinfo", "modules.dep", "pcitable", + NULL }; + char ** fnPtr; + + for (fnPtr = fileCheck; *fnPtr; fnPtr++) { + sprintf(from, "%s/%s", mntPoint, *fnPtr); + if (access(from, R_OK)) { + logMessage("cannot find %s; bad driver disk", from); + badDisk = 1; + } + } sprintf(from, "%s/rhdd-6.1", mntPoint); - if (access(from, R_OK)) + stat(from, &sb); + if (!sb.st_size) badDisk = 1; - dirName = malloc(80); - sprintf(dirName, "/tmp/DD-%d", diskNum); - mkdir(dirName, 0755); - for (file = files; *file; file++) { - sprintf(from, "%s/%s", mntPoint, *file); - sprintf(to, "%s/%s", dirName, *file); - - if (copyFile(from, to)) - badDisk = 1; - } + if (badDisk) return 1; - umount("/tmp/drivers"); + diskName = malloc(sb.st_size + 1); + fd = open(from, O_RDONLY); + read(fd, diskName, sb.st_size); + if (diskName[sb.st_size - 1] == '\n') + sb.st_size--; + diskName[sb.st_size] = '\0'; + close(fd); - if (badDisk) { - return 1; - } + sprintf(from, "%s/modinfo", mntPoint); + fd = isysReadModuleInfo(from, modInfo, diskName); - sprintf(from, "%s/modinfo", dirName); - isysReadModuleInfo(from, modInfo, dirName); - sprintf(from, "%s/modules.dep", dirName); + sprintf(from, "%s/modules.dep", mntPoint); mlLoadDeps(modDepsPtr, from); - sprintf(from, "%s/pcitable", dirName); - badDisk = pciReadDrivers(from); - logMessage("read %s, rc %d", from, badDisk); - - diskNum++; + sprintf(from, "%s/pcitable", mntPoint); + pciReadDrivers(from); return 0; } @@ -177,6 +178,7 @@ int devLoadDriverDisk(moduleInfoSet modInfo, moduleList modLoaded, if (rc == 2) return LOADER_BACK; } + ejectFloppy(); rc = newtWinChoice(_("Devices"), _("OK"), cancelNotBack ? _("Cancel") : _("Back"), _("Insert your driver disk and press \"OK\" to continue.")); @@ -191,15 +193,17 @@ int devLoadDriverDisk(moduleInfoSet modInfo, moduleList modLoaded, if (doPwMount("/tmp/fd0", "/tmp/drivers", "vfat", 1, 0, NULL, NULL)) if (doPwMount("/tmp/fd0", "/tmp/drivers", "ext2", 1, 0, NULL, NULL)) newtWinMessage(_("Error"), _("OK"), - _("Failed to mount floppy disk.")); + _("Failed to mount driver disk.")); - if (devCopyDriverDisk(modInfo, modLoaded, modDepsPtr, + if (devInitDriverDisk(modInfo, modLoaded, modDepsPtr, flags, "/tmp/drivers")) newtWinMessage(_("Error"), _("OK"), _("The floppy disk you inserted is not a valid driver disk " "for this release of Red Hat Linux.")); else done = 1; + + umount("/tmp/drivers"); } while (!done); return 0; @@ -219,7 +223,7 @@ static int sortDrivers(const void * a, const void * b) { } static int pickModule(moduleInfoSet modInfo, enum driverMajor type, - moduleList modLoaded, moduleDeps modDeps, + moduleList modLoaded, moduleDeps * modDepsPtr, struct moduleInfo * suggestion, struct moduleInfo ** modp, int * specifyParams, int flags) { @@ -229,21 +233,22 @@ static int pickModule(moduleInfoSet modInfo, enum driverMajor type, char specifyParameters = *specifyParams ? '*' : ' '; struct newtExitStruct es; struct sortModuleList * sortedOrder; - int numSorted = 0; - - sortedOrder = alloca(sizeof(*sortedOrder) * modInfo->numModules); + int numSorted; - for (i = 0; i < modInfo->numModules; i++) { - if (modInfo->moduleList[i].major == type && - !mlModuleInList(modInfo->moduleList[i].moduleName, modLoaded)) { - sortedOrder[numSorted].index = i; - sortedOrder[numSorted++].modInfo = modInfo; - } - } + do { + sortedOrder = malloc(sizeof(*sortedOrder) * modInfo->numModules); + numSorted = 0; + + for (i = 0; i < modInfo->numModules; i++) { + if (modInfo->moduleList[i].major == type && + !mlModuleInList(modInfo->moduleList[i].moduleName, modLoaded)) { + sortedOrder[numSorted].index = i; + sortedOrder[numSorted++].modInfo = modInfo; + } + } - qsort(sortedOrder, numSorted, sizeof(*sortedOrder), sortDrivers); + qsort(sortedOrder, numSorted, sizeof(*sortedOrder), sortDrivers); - do { if (FL_MODDISK(flags)) { text = newtTextboxReflowed(-1, -1, _("Which driver should I try?. " "If the driver you need does not appear in this list, and " @@ -290,10 +295,12 @@ static int pickModule(moduleInfoSet modInfo, enum driverMajor type, newtFormDestroy(form); newtPopWindow(); + free(sortedOrder); + 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) { - devLoadDriverDisk(modInfo, modLoaded, &modDeps, flags, 0); + devLoadDriverDisk(modInfo, modLoaded, modDepsPtr, flags, 0); continue; } else { break; @@ -307,7 +314,7 @@ static int pickModule(moduleInfoSet modInfo, enum driverMajor type, } int devDeviceMenu(enum driverMajor type, moduleInfoSet modInfo, - moduleList modLoaded, moduleDeps modDeps, int flags, + moduleList modLoaded, moduleDeps * modDepsPtr, int flags, char ** moduleName) { struct moduleInfo * mod = NULL; enum { S_MODULE, S_ARGS, S_DONE } stage = S_MODULE; @@ -318,8 +325,8 @@ int devDeviceMenu(enum driverMajor type, moduleInfoSet modInfo, while (stage != S_DONE) { switch (stage) { case S_MODULE: - if ((rc = pickModule(modInfo, type, modLoaded, modDeps, mod, &mod, - &specifyArgs, flags))) + if ((rc = pickModule(modInfo, type, modLoaded, modDepsPtr, mod, + &mod, &specifyArgs, flags))) return LOADER_BACK; stage = S_ARGS; break; @@ -343,8 +350,8 @@ int devDeviceMenu(enum driverMajor type, moduleInfoSet modInfo, scsiWindow(mod->moduleName); sleep(1); } - rc = mlLoadModule(mod->moduleName, mod->path, modLoaded, modDeps, args, - modInfo, flags); + rc = mlLoadModule(mod->moduleName, mod->locationID, modLoaded, *modDepsPtr, + args, modInfo, flags); if (mod->major == DRIVER_SCSI) newtPopWindow(); if (args) { diff --git a/loader/devices.h b/loader/devices.h index ee8af98e5..9f0e50cf2 100644 --- a/loader/devices.h +++ b/loader/devices.h @@ -5,11 +5,11 @@ #include "modules.h" int devDeviceMenu(enum driverMajor type, moduleInfoSet modInfo, - moduleList modLoaded, moduleDeps modDeps, int flags, + moduleList modLoaded, moduleDeps * modDepsPtr, int flags, char ** moduleName); int devLoadDriverDisk(moduleInfoSet modInfo, moduleList modLoaded, moduleDeps *modDepsPtr, int flags, int cancelNotBack); -int devCopyDriverDisk(moduleInfoSet modInfo, moduleList modLoaded, +int devInitDriverDisk(moduleInfoSet modInfo, moduleList modLoaded, moduleDeps *modDepsPtr, int flags, char * mntPoint); #endif diff --git a/loader/loader.c b/loader/loader.c index a2ed3058d..fbf4d4995 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -73,28 +73,28 @@ struct installMethod { char * (*mountImage)(struct installMethod * method, char * location, struct knownDevices * kd, moduleInfoSet modInfo, moduleList modLoaded, - moduleDeps modDeps, int flags); + moduleDeps * modDepsPtr, int flags); }; #ifdef INCLUDE_LOCAL static char * mountCdromImage(struct installMethod * method, char * location, struct knownDevices * kd, moduleInfoSet modInfo, moduleList modLoaded, - moduleDeps modDeps, int flags); + moduleDeps * modDepsPtr, int flags); static char * mountHardDrive(struct installMethod * method, char * location, struct knownDevices * kd, moduleInfoSet modInfo, moduleList modLoaded, - moduleDeps modDeps, int flags); + moduleDeps * modDepsPtr, int flags); #endif #ifdef INCLUDE_NETWORK static char * mountNfsImage(struct installMethod * method, char * location, struct knownDevices * kd, moduleInfoSet modInfo, moduleList modLoaded, - moduleDeps modDeps, int flags); + moduleDeps * modDepsPtr, int flags); static char * mountUrlImage(struct installMethod * method, char * location, struct knownDevices * kd, moduleInfoSet modInfo, moduleList modLoaded, - moduleDeps modDeps, int flags); + moduleDeps * modDepsPtr, int flags); #endif static struct installMethod installMethods[] = { @@ -115,6 +115,18 @@ static int numMethods = sizeof(installMethods) / sizeof(struct installMethod); static int newtRunning = 0; int continuing = 0; +void ejectFloppy(void) { +#if defined(__sparc__) || defined(__ia64__) + int fd; + + logMessage("ejecting floppy"); + + fd = open("/dev/fd0", O_RDONLY); + ioctl(fd, FDEJCET, 1); + close(fd); +#endif +} + void doSuspend(void) { newtFinished(); exit(1); @@ -236,7 +248,8 @@ static int detectHardware(moduleInfoSet modInfo, } int addDeviceManually(moduleInfoSet modInfo, moduleList modLoaded, - moduleDeps modDeps, struct knownDevices * kd, int flags) { + moduleDeps * modDepsPtr, struct knownDevices * kd, + int flags) { char * pristineItems[] = { N_("SCSI"), N_("Network") }; char * items[3]; int i, rc; @@ -260,14 +273,15 @@ int addDeviceManually(moduleInfoSet modInfo, moduleList modLoaded, else type = DRIVER_SCSI; - rc = devDeviceMenu(type, modInfo, modLoaded, modDeps, flags, NULL); + rc = devDeviceMenu(type, modInfo, modLoaded, modDepsPtr, flags, NULL); } while (rc); return 0; } int manualDeviceCheck(moduleInfoSet modInfo, moduleList modLoaded, - moduleDeps modDeps, struct knownDevices * kd, int flags) { + moduleDeps * modDepsPtr, struct knownDevices * kd, + int flags) { int i, rc; char buf[2000]; struct moduleInfo * mi; @@ -323,7 +337,7 @@ int manualDeviceCheck(moduleInfoSet modInfo, moduleList modLoaded, if (answer != add) break; - addDeviceManually(modInfo, modLoaded, modDeps, kd, flags); + addDeviceManually(modInfo, modLoaded, modDepsPtr, kd, flags); } else { rc = newtWinChoice(_("Devices"), _("Done"), _("Add Device"), _("I don't have any special device drivers loaded for " @@ -331,7 +345,7 @@ int manualDeviceCheck(moduleInfoSet modInfo, moduleList modLoaded, if (rc != 2) break; - addDeviceManually(modInfo, modLoaded, modDeps, kd, flags); + addDeviceManually(modInfo, modLoaded, modDepsPtr, kd, flags); } } @@ -360,7 +374,8 @@ 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, modList[i]->path, + mlLoadModule(modList[i]->moduleName, + modList[i]->locationID, modLoaded, modDeps, NULL, modInfo, flags); } } @@ -371,8 +386,9 @@ int busProbe(moduleInfoSet modInfo, moduleList modLoaded, moduleDeps modDeps, startNewt(flags); scsiWindow(modList[i]->moduleName); - mlLoadModule(modList[i]->moduleName, modList[i]->path, - modLoaded, modDeps, NULL, modInfo, flags); + mlLoadModule(modList[i]->moduleName, + modList[i]->locationID, modLoaded, modDeps, + NULL, modInfo, flags); sleep(1); newtPopWindow(); } @@ -540,7 +556,7 @@ static char * setupHardDrive(char * device, char * type, char * dir, static char * mountHardDrive(struct installMethod * method, char * location, struct knownDevices * kd, moduleInfoSet modInfo, moduleList modLoaded, - moduleDeps modDeps, int flags) { + moduleDeps * modDepsPtr, int flags) { int rc; int fd; int i, j; @@ -562,7 +578,7 @@ static char * mountHardDrive(struct installMethod * method, static int ufsloaded; #endif - mlLoadModule("vfat", NULL, modLoaded, modDeps, NULL, modInfo, flags); + mlLoadModule("vfat", NULL, modLoaded, *modDepsPtr, NULL, modInfo, flags); while (!done) { numPartitions = 0; @@ -580,7 +596,7 @@ static char * mountHardDrive(struct installMethod * method, case BALKAN_PART_UFS: if (!ufsloaded) { ufsloaded = 1; - mlLoadModule("ufs", NULL, modLoaded, modDeps, NULL, modInfo, flags); + mlLoadModule("ufs", NULL, modLoaded, *modDeps, NULL, modInfo, flags); } /* FALLTHROUGH */ #endif @@ -611,7 +627,7 @@ static char * mountHardDrive(struct installMethod * method, "additional devices?")); if (rc == 2) return NULL; - devDeviceMenu(DRIVER_SCSI, modInfo, modLoaded, modDeps, flags, + devDeviceMenu(DRIVER_SCSI, modInfo, modLoaded, modDepsPtr, flags, NULL); kdFindScsiList(kd); @@ -680,7 +696,7 @@ static char * mountHardDrive(struct installMethod * method, if (es.reason == NEWT_EXIT_COMPONENT && es.u.co == back) { return NULL; } else if (es.reason == NEWT_EXIT_HOTKEY && es.u.key == NEWT_KEY_F2) { - devDeviceMenu(DRIVER_SCSI, modInfo, modLoaded, modDeps, flags, + devDeviceMenu(DRIVER_SCSI, modInfo, modLoaded, modDepsPtr, flags, NULL); kdFindScsiList(kd); continue; @@ -720,7 +736,7 @@ static char * mountHardDrive(struct installMethod * method, static char * setupCdrom(struct installMethod * method, char * location, struct knownDevices * kd, moduleInfoSet modInfo, moduleList modLoaded, - moduleDeps modDeps, int flags, int probeQuickly, + moduleDeps * modDepsPtr, int flags, int probeQuickly, int needRedHatCD) { int i; int rc; @@ -757,7 +773,7 @@ static char * setupCdrom(struct installMethod * method, "the Red Hat CD and press \"OK\" to retry.")); if (rc == 2) return NULL; } else { - rc = setupCDdevice(kd, modInfo, modLoaded, modDeps, flags); + rc = setupCDdevice(kd, modInfo, modLoaded, modDepsPtr, flags); if (rc == LOADER_BACK) return NULL; } } while (1); @@ -773,18 +789,19 @@ static char * setupCdrom(struct installMethod * method, static char * mountCdromImage(struct installMethod * method, char * location, struct knownDevices * kd, moduleInfoSet modInfo, moduleList modLoaded, - moduleDeps modDeps, int flags) { - return setupCdrom(method, location, kd, modInfo, modLoaded, modDeps, + moduleDeps * modDepsPtr, int flags) { + return setupCdrom(method, location, kd, modInfo, modLoaded, modDepsPtr, flags, 0, 1); } int kickstartFromCdrom(char * ksFile, char * fromFile, struct knownDevices * kd, moduleInfoSet modInfo, moduleList modLoaded, - moduleDeps modDeps, int flags) { + moduleDeps * modDepsPtr, int flags) { char * fullFn; - if (!setupCdrom(NULL, NULL, kd, modInfo, modLoaded, modDeps, flags, 1, 0)) { + if (!setupCdrom(NULL, NULL, kd, modInfo, modLoaded, modDepsPtr, + flags, 1, 0)) { logMessage("kickstart failed to find CD device"); return 1; } @@ -803,7 +820,8 @@ int kickstartFromCdrom(char * ksFile, char * fromFile, static int ensureNetDevice(struct knownDevices * kd, moduleInfoSet modInfo, moduleList modLoaded, - moduleDeps modDeps, int flags, char ** devNamePtr) { + moduleDeps * modDepsPtr, int flags, + char ** devNamePtr) { int i, rc; char * devName = NULL; @@ -819,7 +837,7 @@ static int ensureNetDevice(struct knownDevices * kd, /* It seems like expert mode should do something here? */ if (!devName) { - rc = devDeviceMenu(DRIVER_NET, modInfo, modLoaded, modDeps, flags, + rc = devDeviceMenu(DRIVER_NET, modInfo, modLoaded, modDepsPtr, flags, NULL); if (rc) return rc; kdFindNetList(kd); @@ -853,7 +871,7 @@ static int ensureNetDevice(struct knownDevices * kd, static char * mountNfsImage(struct installMethod * method, char * location, struct knownDevices * kd, moduleInfoSet modInfo, moduleList modLoaded, - moduleDeps modDeps, int flags) { + moduleDeps * modDepsPtr, int flags) { static struct networkDeviceConfig netDev; char * devName; int i, rc; @@ -866,7 +884,7 @@ static char * mountNfsImage(struct installMethod * method, memset(&netDev, 0, sizeof(netDev)); - i = ensureNetDevice(kd, modInfo, modLoaded, modDeps, flags, &devName); + i = ensureNetDevice(kd, modInfo, modLoaded, modDepsPtr, flags, &devName); if (i) return NULL; while (stage != NFS_STAGE_DONE) { @@ -893,7 +911,8 @@ static char * mountNfsImage(struct installMethod * method, break; } - mlLoadModule("nfs", NULL, modLoaded, modDeps, NULL, modInfo, flags); + mlLoadModule("nfs", NULL, modLoaded, *modDepsPtr, NULL, modInfo, + flags); fullPath = alloca(strlen(host) + strlen(dir) + 2); sprintf(fullPath, "%s:%s", host, dir); @@ -943,7 +962,7 @@ static char * mountNfsImage(struct installMethod * method, static char * mountUrlImage(struct installMethod * method, char * location, struct knownDevices * kd, moduleInfoSet modInfo, moduleList modLoaded, - moduleDeps modDeps, int flags) { + moduleDeps * modDepsPtr, int flags) { int i, rc; int stage = URL_STAGE_IP; char * devName; @@ -958,7 +977,7 @@ static char * mountUrlImage(struct installMethod * method, initLoopback(); - i = ensureNetDevice(kd, modInfo, modLoaded, modDeps, flags, &devName); + i = ensureNetDevice(kd, modInfo, modLoaded, modDepsPtr, flags, &devName); if (i) return NULL; memset(&ui, 0, sizeof(ui)); @@ -1058,7 +1077,7 @@ static char * doMountImage(char * location, struct knownDevices * kd, moduleInfoSet modInfo, moduleList modLoaded, - moduleDeps modDeps, + moduleDeps * modDepsPtr, char ** lang, char ** keymap, char ** kbdtype, @@ -1137,7 +1156,7 @@ static char * doMountImage(char * location, Red Hat CD. If there is one there, just die happy */ if (!networkAvailable && !FL_EXPERT(flags)) { # endif - url = setupCdrom(NULL, location, kd, modInfo, modLoaded, modDeps, + url = setupCdrom(NULL, location, kd, modInfo, modLoaded, modDepsPtr, flags, 1, 1); if (url) return url; } @@ -1203,7 +1222,7 @@ static char * doMountImage(char * location, case STEP_URL: url = installMethods[validMethods[methodNum]].mountImage( installMethods + validMethods[methodNum], location, - kd, modInfo, modLoaded, modDeps, flags); + kd, modInfo, modLoaded, modDepsPtr, flags); if (!url) { step = STEP_METHOD; dir = -1; @@ -1222,7 +1241,7 @@ static char * doMountImage(char * location, } static int kickstartDevices(struct knownDevices * kd, moduleInfoSet modInfo, - moduleList modLoaded, moduleDeps modDeps, + moduleList modLoaded, moduleDeps * modDepsPtr, int flags) { char ** ksArgv = NULL; int ksArgc, rc; @@ -1269,14 +1288,15 @@ static int kickstartDevices(struct knownDevices * kd, moduleInfoSet modInfo, } if (!strcmp(fsType, "vfat")) - mlLoadModule("vfat", NULL, modLoaded, modDeps, NULL, modInfo, flags); + mlLoadModule("vfat", NULL, modLoaded, *modDepsPtr, NULL, + modInfo, flags); if (doPwMount(fs, "/tmp/drivers", fsType, 1, 0, NULL, NULL)) { logMessage("failed to mount %s", fs); break; } - if (devCopyDriverDisk(modInfo, modLoaded, &modDeps, flags, + if (devInitDriverDisk(modInfo, modLoaded, modDepsPtr, flags, "/tmp/drivers")) { logMessage("driver information missing!"); } @@ -1316,7 +1336,7 @@ static int kickstartDevices(struct knownDevices * kd, moduleInfoSet modInfo, else optv = NULL; - rc = mlLoadModule(device, mi->path, modLoaded, modDeps, + rc = mlLoadModule(device, mi->locationID, modLoaded, * modDepsPtr, optv, modInfo, flags); if (optv) free(optv); @@ -1335,7 +1355,7 @@ static int kickstartDevices(struct knownDevices * kd, moduleInfoSet modInfo, static char * setupKickstart(char * location, struct knownDevices * kd, moduleInfoSet modInfo, moduleList modLoaded, - moduleDeps modDeps, int * flagsPtr) { + moduleDeps * modDepsPtr, int * flagsPtr) { char ** ksArgv; char * device = NULL; int ksArgc; @@ -1376,7 +1396,7 @@ static char * setupKickstart(char * location, struct knownDevices * kd, }; #endif - kickstartDevices(kd, modInfo, modLoaded, modDeps, flags); + kickstartDevices(kd, modInfo, modLoaded, modDepsPtr, flags); if (0) { #ifdef INCLUDE_NETWORK @@ -1452,7 +1472,7 @@ static char * setupKickstart(char * location, struct knownDevices * kd, #ifdef INCLUDE_NETWORK if (ksType == KS_CMD_NFS) { - mlLoadModule("nfs", NULL, modLoaded, modDeps, NULL, modInfo, flags); + mlLoadModule("nfs", NULL, modLoaded, *modDepsPtr, NULL, modInfo, flags); fullPath = alloca(strlen(host) + strlen(dir) + 2); sprintf(fullPath, "%s:%s", host, dir); @@ -1470,8 +1490,8 @@ static char * setupKickstart(char * location, struct knownDevices * kd, #ifdef INCLUDE_LOCAL if (ksType == KS_CMD_CDROM) { - imageUrl = setupCdrom(NULL, location, kd, modInfo, modLoaded, modDeps, - flags, 1, 1); + imageUrl = setupCdrom(NULL, location, kd, modInfo, modLoaded, + modDepsPtr, flags, 1, 1); } else if (ksType == KS_CMD_HD) { char * fsType; logMessage("partname is %s", partname); @@ -1519,7 +1539,7 @@ static char * setupKickstart(char * location, struct knownDevices * kd, } #endif - kickstartDevices(kd, modInfo, modLoaded, modDeps, flags); + kickstartDevices(kd, modInfo, modLoaded, modDepsPtr, flags); return imageUrl; } @@ -1598,8 +1618,8 @@ static int parseCmdLineFlags(int flags, char * cmdLine, char ** ksSource) { } #ifdef INCLUDE_NETWORK -int kickstartFromNfs(char * location, moduleList modLoaded, moduleDeps modDeps, - int flags, char * ksSource) { +int kickstartFromNfs(char * location, moduleList modLoaded, + moduleDeps * modDepsPtr, int flags, char * ksSource) { struct networkDeviceConfig netDev; char * file, * fullFn; char * ksPath; @@ -1650,7 +1670,7 @@ int kickstartFromNfs(char * location, moduleList modLoaded, moduleDeps modDeps, logMessage("ks server: %s file: %s", ksPath, file); - mlLoadModule("nfs", NULL, modLoaded, modDeps, NULL, NULL, flags); + mlLoadModule("nfs", NULL, modLoaded, *modDepsPtr, NULL, NULL, flags); if (doPwMount(ksPath, "/tmp/nfskd", "nfs", 1, 0, NULL, NULL)) { logMessage("failed to mount %s", ksPath); @@ -1668,15 +1688,15 @@ int kickstartFromNfs(char * location, moduleList modLoaded, moduleDeps modDeps, #endif int kickstartFromHardDrive(char * location, - moduleList modLoaded, moduleDeps modDeps, + moduleList modLoaded, moduleDeps * modDepsPtr, char * source, int flags) { char * device; char * fileName; char * fullFn; - mlLoadModule("vfat", NULL, modLoaded, modDeps, NULL, NULL, flags); + mlLoadModule("vfat", NULL, modLoaded, *modDepsPtr, NULL, NULL, flags); #ifdef __sparc__ - mlLoadModule("ufs", NULL, modLoaded, modDeps, NULL, NULL, flags); + mlLoadModule("ufs", NULL, modLoaded, *modDepsPtr, NULL, NULL, flags); #endif fileName = strchr(source, '/'); @@ -1706,8 +1726,8 @@ int kickstartFromHardDrive(char * location, } int kickstartFromFloppy(char * location, moduleList modLoaded, - moduleDeps modDeps, int flags) { - mlLoadModule("vfat", NULL, modLoaded, modDeps, NULL, NULL, flags); + moduleDeps * modDepsPtr, int flags) { + mlLoadModule("vfat", NULL, modLoaded, *modDepsPtr, NULL, NULL, flags); if (devMakeInode("fd0", "/tmp/fd0")) return 1; @@ -1820,7 +1840,7 @@ int copyDirectory(char * from, char * to) { } void loadUpdates(struct knownDevices *kd, moduleList modLoaded, - moduleDeps modDeps, int flags) { + moduleDeps * modDepsPtr, int flags) { int done = 0; int rc; @@ -1858,7 +1878,7 @@ void loadUpdates(struct knownDevices *kd, moduleList modLoaded, /* Don't load the large ufs module if it will not be needed to save some memory on lowmem SPARCs. */ void loadUfs(struct knownDevices *kd, moduleList modLoaded, - moduleDeps modDeps, int flags) { + moduleDeps * modDepsPtr, int flags) { int i, j, fd, rc; struct partitionTable table; int ufsloaded = 0; @@ -1874,7 +1894,7 @@ void loadUfs(struct knownDevices *kd, moduleList modLoaded, for (j = 0; j < table.maxNumPartitions; j++) { if (table.parts[j].type == BALKAN_PART_UFS) { if (!ufsloaded) - mlLoadModule("ufs", NULL, modLoaded, modDeps, NULL, NULL, flags); + mlLoadModule("ufs", NULL, modLoaded, *modDeps, NULL, NULL, flags); ufsloaded = 1; } } @@ -1887,7 +1907,7 @@ void loadUfs(struct knownDevices *kd, moduleList modLoaded, } } #else -#define loadUfs(kd,modLoaded,modDeps,flags) do { } while (0) +#define loadUfs(kd,modLoaded,modDepsPtr,flags) do { } while (0) #endif int main(int argc, char ** argv) { @@ -1974,6 +1994,7 @@ int main(int argc, char ** argv) { arg = FL_TESTING(flags) ? "./module-info" : "/modules/module-info"; modInfo = isysNewModuleInfoSet(); + if (isysReadModuleInfo(arg, modInfo, NULL)) { fprintf(stderr, "failed to read %s\n", arg); sleep(5); @@ -1990,7 +2011,7 @@ int main(int argc, char ** argv) { if (FL_KSFLOPPY(flags)) { startNewt(flags); ksFile = "/tmp/ks.cfg"; - kickstartFromFloppy(ksFile, modLoaded, modDeps, flags); + kickstartFromFloppy(ksFile, modLoaded, &modDeps, flags); flags |= LOADER_FLAGS_KICKSTART; } @@ -2004,7 +2025,7 @@ int main(int argc, char ** argv) { if (!continuing) { winStatus(40, 3, _("PC Card"), _("Initializing PC Card Devices...")); - startPcmcia(modLoaded, modDeps, modInfo, flags); + startPcmcia(modLoaded, &modDeps, modInfo, flags); newtPopWindow(); } #endif @@ -2026,7 +2047,7 @@ int main(int argc, char ** argv) { } if (FL_KSHD(flags)) { ksFile = "/tmp/ks.cfg"; - kickstartFromHardDrive(ksFile, modLoaded, modDeps, ksSource, flags); + kickstartFromHardDrive(ksFile, modLoaded, &modDeps, ksSource, flags); flags |= LOADER_FLAGS_KICKSTART; } else if (FL_KSFILE(flags)) { ksFile = ksSource; @@ -2036,7 +2057,7 @@ int main(int argc, char ** argv) { #ifdef INCLUDE_LOCAL if (FL_KSCDROM(flags)) { ksFile = "/tmp/ks.cfg"; - kickstartFromCdrom(ksFile, ksSource, &kd, modInfo, modLoaded, modDeps, + kickstartFromCdrom(ksFile, ksSource, &kd, modInfo, modLoaded, &modDeps, flags); flags |= LOADER_FLAGS_KICKSTART; } @@ -2046,19 +2067,19 @@ int main(int argc, char ** argv) { if (FL_KICKSTART(flags) && !ksFile) { ksFile = "/tmp/ks.cfg"; startNewt(flags); - kickstartFromNfs(ksFile, modLoaded, modDeps, flags, ksSource); + kickstartFromNfs(ksFile, modLoaded, &modDeps, flags, ksSource); } #endif if (ksFile) { startNewt(flags); ksReadCommands(ksFile); - url = setupKickstart("/mnt/source", &kd, modInfo, modLoaded, modDeps, + url = setupKickstart("/mnt/source", &kd, modInfo, modLoaded, &modDeps, &flags); } if (!url) { - url = doMountImage("/mnt/source", &kd, modInfo, modLoaded, modDeps, + url = doMountImage("/mnt/source", &kd, modInfo, modLoaded, &modDeps, &lang, &keymap, &kbdtype, flags); } @@ -2108,7 +2129,7 @@ int main(int argc, char ** argv) { /* merge in any new pci ids */ pciReadDrivers("/modules/pcitable"); - modInfo = isysNewModuleInfoSet(); + /*modInfo = isysNewModuleInfoSet();*/ if (isysReadModuleInfo(arg, modInfo, NULL)) { fprintf(stderr, "failed to read %s\n", arg); sleep(5); @@ -2122,13 +2143,13 @@ int main(int argc, char ** argv) { if (((access("/proc/bus/pci/devices", X_OK) && access("/proc/openprom", X_OK)) || FL_ISA(flags) || FL_NOPROBE(flags)) && !ksFile) { - manualDeviceCheck(modInfo, modLoaded, modDeps, &kd, flags); + manualDeviceCheck(modInfo, modLoaded, &modDeps, &kd, flags); } if (FL_UPDATES(flags)) - loadUpdates(&kd, modLoaded, modDeps, flags); + loadUpdates(&kd, modLoaded, &modDeps, flags); - loadUfs(&kd, modLoaded, modDeps, flags); + loadUfs(&kd, modLoaded, &modDeps, flags); if (!FL_TESTING(flags)) { int fd; diff --git a/loader/loader.h b/loader/loader.h index 177304f2e..9f87fd6d7 100644 --- a/loader/loader.h +++ b/loader/loader.h @@ -32,3 +32,5 @@ #define FL_UPDATES(a) ((a) & LOADER_FLAGS_UPDATES) #define FL_KSFILE(a) ((a) & LOADER_FLAGS_KSFILE) #define FL_KSCDROM(a) ((a) & LOADER_FLAGS_KSCDROM) + +void ejectFloppy(void); diff --git a/loader/modules.c b/loader/modules.c index 5c8de1910..1132b9721 100644 --- a/loader/modules.c +++ b/loader/modules.c @@ -2,15 +2,22 @@ #include <ctype.h> #include <errno.h> #include <fcntl.h> +#include <newt.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/mount.h> #include <sys/stat.h> +#include <sys/utsname.h> #include <sys/wait.h> #include <unistd.h> +#include <zlib.h> +#include "isys/imount.h" #include "isys/isys.h" +#include "isys/cpio.h" +#include "lang.h" #include "loader.h" #include "log.h" #include "modules.h" @@ -191,7 +198,95 @@ int mlLoadDeps(moduleDeps * moduleDepListPtr, const char * path) { return 0; } -int mlLoadModule(char * modName, char * path, moduleList modLoaded, +static void removeExtractedModule(char * path) { + char * fn = alloca(strlen(path) + 20); + + sprintf(fn, "%s/modules.cgz", path); + unlink(fn); + rmdir(path); +} + +static char * extractModule(char * location, char * modName) { + char * pattern[] = { NULL, NULL }; + struct utsname un; + gzFile from; + gzFile to; + int first = 1; + int fd; + char * buf; + struct stat sb; + int rc; + int failed; + char * toPath; + + uname(&un); + + pattern[0] = alloca(strlen(modName) + strlen(un.release) + 5); + sprintf(pattern[0], "%s*/%s.o", un.release, modName); + logMessage("extracting pattern %s", pattern[0]); + + devMakeInode("fd0", "/tmp/fd0"); + while (1) { + failed = 0; + + if (doPwMount("/tmp/fd0", "/tmp/drivers", "vfat", 1, 0, NULL, NULL)) + if (doPwMount("/tmp/fd0", "/tmp/drivers", "ext2", 1, 0, NULL, NULL)) + failed = 1; + + if (failed && !first) { + newtWinMessage(_("Error"), _("OK"), + _("Failed to mount driver disk.")); + } else if (!failed) { + if ((fd = open("/tmp/drivers/rhdd-6.1", O_RDONLY)) < 0) + failed = 1; + if (!failed) { + fstat(fd, &sb); + buf = malloc(sb.st_size + 1); + read(fd, buf, sb.st_size); + if (buf[sb.st_size - 1] == '\n') + sb.st_size--; + buf[sb.st_size] = '\0'; + close(fd); + + failed = strcmp(buf, location); + free(buf); + } + + if (failed && !first) { + umount("/tmp/drivers"); + newtWinMessage(_("Error"), _("OK"), + _("The wrong diskette was inserted.")); + } + } + + if (!failed) { + from = gzopen("/tmp/drivers/modules.cgz", "r"); + toPath = malloc(strlen(modName) + 30); + sprintf(toPath, "/tmp/modules/%s", modName); + mkdirChain(toPath); + strcat(toPath, "/modules.cgz"); + to = gzopen(toPath, "w"); + + myCpioFilterArchive(from, to, pattern); + + gzclose(from); + gzclose(to); + umount("/tmp/drivers"); + + sprintf(toPath, "/tmp/modules/%s", modName); + return toPath; + } + + first = 0; + + ejectFloppy(); + rc = newtWinChoice(_("Driver Disk"), _("OK"), _("Cancel"), + _("Please insert the %s driver disk now."), location); + if (rc == 2) return NULL; + } +} + +int mlLoadModule(char * modName, char * location, moduleList modLoaded, moduleDeps modDeps, char ** args, moduleInfoSet modInfo, int flags) { moduleDeps dep; @@ -203,6 +298,7 @@ int mlLoadModule(char * modName, char * path, moduleList modLoaded, int ethDevices = -1; pid_t child; int status; + char * path = NULL; if (mlModuleInList(modName, modLoaded)) { return 0; @@ -220,12 +316,17 @@ int mlLoadModule(char * modName, char * path, moduleList modLoaded, if (dep && dep->deps) { nextDep = dep->deps; while (*nextDep) { - if (mlLoadModule(*nextDep, path, modLoaded, modDeps, NULL, modInfo, flags) && path) + if (mlLoadModule(*nextDep, location, modLoaded, modDeps, NULL, modInfo, flags) && location) mlLoadModule(*nextDep, NULL, modLoaded, modDeps, NULL, modInfo, flags); nextDep++; } } + if (location) { + path = extractModule(location, modName); + if (!path) return 1; + } + sprintf(fileName, "%s.o", modName); for (argPtr = args; argPtr && *argPtr; argPtr++) { strcat(fileName, " "); @@ -285,6 +386,9 @@ int mlLoadModule(char * modName, char * path, moduleList modLoaded, } modLoaded->mods[modLoaded->numModules++].args = newArgs; + } else { + if (path) removeExtractedModule(path); + free(path); } return rc; |