diff options
Diffstat (limited to 'loader2')
-rw-r--r-- | loader2/driverdisk.c | 82 | ||||
-rw-r--r-- | loader2/driverdisk.h | 2 | ||||
-rw-r--r-- | loader2/loader.c | 50 |
3 files changed, 77 insertions, 57 deletions
diff --git a/loader2/driverdisk.c b/loader2/driverdisk.c index 22c009f9d..ae24d01d0 100644 --- a/loader2/driverdisk.c +++ b/loader2/driverdisk.c @@ -112,21 +112,22 @@ static int loadDriverDisk(moduleInfoSet modInfo, moduleList modLoaded, return 0; } -/* JKFIXME: need a better name for this I think :) */ -/* Get the best available removable device (floppy/cdrom). Used regularly - * for device disks and update disks. +/* Get the list of removable devices (floppy/cdrom) available. Used to + * find suitable devices for update disk / driver disk source. + * Returns the number of devices. ***devNames will be a NULL-terminated list + * of device names */ -int getRemovableDevice(char ** device, int flags) { +int getRemovableDevices(char *** devNames) { struct device **devices, **floppies, **cdroms; - char ** devNames; int numDevices = 0; - int i = 0, j = 0, rc, num = 0; + int i = 0, j = 0; floppies = probeDevices(CLASS_FLOPPY, BUS_IDE | BUS_SCSI | BUS_MISC, PROBE_ALL); cdroms = probeDevices(CLASS_CDROM, BUS_IDE | BUS_SCSI, PROBE_ALL); - /* JKFIMXE: need to handle disconnected devices */ + /* we should probably take detached into account here, but it just + * means we use a little bit more memory than we really need to */ if (floppies) for (i = 0; floppies[i]; i++) numDevices++; if (cdroms) @@ -135,51 +136,35 @@ int getRemovableDevice(char ** device, int flags) { /* JKFIXME: better error handling */ if (!numDevices) { logMessage("no devices found to load drivers from"); - return LOADER_BACK; + return numDevices; } devices = malloc((numDevices + 1) * sizeof(**devices)); i = 0; if (floppies) - for (j = 0; floppies[j]; j++) devices[i++] = floppies[j]; + for (j = 0; floppies[j]; j++) + if (floppies[j]->detached == 0) devices[i++] = floppies[j]; if (cdroms) - for (j = 0; cdroms[j]; j++) devices[i++] = cdroms[j]; + for (j = 0; cdroms[j]; j++) + if (cdroms[j]->detached == 0) devices[i++] = cdroms[j]; devices[i] = NULL; + numDevices = i; for (i = 0; devices[i]; i++) { logMessage("devices[%d] is %s", i, devices[i]->device); } - if (numDevices == 1) { - logMessage("only one possible device, %s", devices[0]->device); - *device = strdup(devices[0]->device); - free(devices); - return LOADER_OK; - } - - - devNames = malloc((numDevices + 1) * sizeof(*devNames)); - for (i = 0; devices[i]; i++) - devNames[i] = strdup(devices[i]->device); + *devNames = malloc((numDevices + 1) * sizeof(*devNames)); + for (i = 0; devices[i] && (i < numDevices); i++) + (*devNames)[i] = strdup(devices[i]->device); free(devices); - startNewt(flags); - rc = newtWinMenu(_("Device Driver Source"), - _("You have multiple devices which could serve as " - "sources for a driver disk. Which would you like " - "to use?"), 40, 10, 10, - numDevices < 6 ? numDevices : 6, devNames, - &num, _("OK"), _("Back"), NULL); - if (rc == 2) { - free(devNames); - return LOADER_BACK; - } + if (i != numDevices) + logMessage("somehow numDevices != len(devices)"); - *device = strdup(devNames[num]); - free(devNames); - return LOADER_OK; + return numDevices; } /* Prompt for loading a driver from "media" @@ -190,16 +175,33 @@ int loadDriverFromMedia(int class, moduleList modLoaded, moduleDeps * modDepsPtr moduleInfoSet modInfo, struct knownDevices * kd, int flags) { - char * device; + char * device = NULL; + char ** devNames = NULL; enum { DEV_DEVICE, DEV_INSERT, DEV_LOAD, DEV_DONE } stage = DEV_DEVICE; - int rc, i; + int rc, i, num = 0; while (stage != DEV_DONE) { switch(stage) { case DEV_DEVICE: - rc = getRemovableDevice(&device, flags); - if (rc == LOADER_BACK) - return rc; + rc = getRemovableDevices(&devNames); + if (rc == 0) + return LOADER_BACK; + + startNewt(flags); + rc = newtWinMenu(_("Driver Disk Source"), + _("You have multiple devices which could serve " + "as sources for a driver disk. Which would " + "you like to use?"), 40, 10, 10, + rc < 6 ? rc : 6, devNames, + &num, _("OK"), _("Back"), NULL); + + if (rc == 2) { + free(devNames); + return LOADER_BACK; + } + device = strdup(devNames[num]); + free(devNames); + stage = DEV_INSERT; case DEV_INSERT: { char * buf; diff --git a/loader2/driverdisk.h b/loader2/driverdisk.h index 47d54c641..7a3995bfb 100644 --- a/loader2/driverdisk.h +++ b/loader2/driverdisk.h @@ -10,6 +10,6 @@ int loadDriverFromMedia(int class, moduleList modLoaded, moduleDeps * modDeps, moduleInfoSet modInfo, struct knownDevices * kd, int flags); -int getRemovableDevice(char ** device, int flags); +int getRemovableDevices(char *** devNames); #endif diff --git a/loader2/loader.c b/loader2/loader.c index 954a69ebf..c7361b704 100644 --- a/loader2/loader.c +++ b/loader2/loader.c @@ -229,36 +229,54 @@ static void spawnShell(int flags) { void loadUpdates(struct knownDevices *kd, int flags) { int done = 0; int rc; + char * device = NULL, ** devNames = NULL; + char * buf; + int num = 0; startNewt(flags); do { - rc = newtWinChoice(_("Updates Disk"), _("OK"), _("Cancel"), - _("Insert your updates disk and press " - "\"OK\" to continue.")); + rc = getRemovableDevices(&devNames); + if (rc == 0) + return; + startNewt(flags); + rc = newtWinMenu(_("Update Disk Source"), + _("You have multiple devices which could serve " + "as sources for an update disk. Which would " + "you like to use?"), 40, 10, 10, + rc < 6 ? rc : 6, devNames, + &num, _("OK"), _("Back"), NULL); + + if (rc == 2) { + free(devNames); + return; + } + device = strdup(devNames[num]); + free(devNames); - if (rc == 2) return; - /* JKFIXME: handle updates from floppy or cd */ - return; -#if 0 - logMessage("UPDATES floppy device is %s", floppyDevice); + buf = sdupprintf(_("Insert your updates disk into /dev/%s and press " + "\"OK\" to continue."), device); + rc = newtWinChoice(_("Updates Disk"), _("OK"), _("Cancel"), buf); + if (rc == 2) + return; + + logMessage("UPDATES device is %s", device); - devMakeInode(floppyDevice, "/tmp/floppy"); - if (doPwMount("/tmp/floppy", "/tmp/update-disk", "ext2", 1, 0, NULL, - NULL)) { + devMakeInode(device, "/tmp/upd.disk"); + if (doPwMount("/tmp/upd.disk", "/tmp/update-disk", "ext2", 1, 0, + NULL, NULL) && + doPwMount("/tmp/upd.disk", "/tmp/update-disk", "iso9660", 1, 0, + NULL, NULL)) { newtWinMessage(_("Error"), _("OK"), - _("Failed to mount floppy disk.")); + _("Failed to mount updates disk")); } else { - /* Copy everything to /tmp/updates so .so files don't get run - from /dev/floppy. We could (and probably should) get smarter - about this at some point. */ + /* Copy everything to /tmp/updates so we can unmount the disk */ winStatus(40, 3, _("Updates"), _("Reading anaconda updates...")); if (!copyDirectory("/tmp/update-disk", "/tmp/updates")) done = 1; newtPopWindow(); umount("/tmp/update-disk"); } -#endif } while (!done); return; |