diff options
author | Erik Troan <ewt@redhat.com> | 2002-01-25 19:41:05 +0000 |
---|---|---|
committer | Erik Troan <ewt@redhat.com> | 2002-01-25 19:41:05 +0000 |
commit | 8e36ad6d306f3c185b84f234b7182289336a4392 (patch) | |
tree | 3fce16ffd8e4471b8dc81804b4e343aba63e6809 /loader/devices.c | |
parent | 2c3ee7417a53b444b69dbc195e7733818cc00187 (diff) | |
download | anaconda-8e36ad6d306f3c185b84f234b7182289336a4392.tar.gz anaconda-8e36ad6d306f3c185b84f234b7182289336a4392.tar.xz anaconda-8e36ad6d306f3c185b84f234b7182289336a4392.zip |
moved functions from devices.c to modules.c that weren't used anywhere
else anyway; made them static
fixed small problem in reloadUnloadedModule()
Diffstat (limited to 'loader/devices.c')
-rw-r--r-- | loader/devices.c | 185 |
1 files changed, 1 insertions, 184 deletions
diff --git a/loader/devices.c b/loader/devices.c index dce14cf6e..fbf3d924f 100644 --- a/loader/devices.c +++ b/loader/devices.c @@ -42,6 +42,7 @@ void eject(char * deviceName) { unlink("/tmp/ejectDevice"); } + static int getModuleArgs(struct moduleInfo * mod, char *** argPtr) { struct newtWinEntry * entries; int i; @@ -434,190 +435,6 @@ int devDeviceMenu(enum driverMajor type, moduleInfoSet modInfo, return rc; } -static char * filterDriverModules(struct driverDiskInfo * ddi, - char * const * modNames) { - struct utsname un; - gzFile from; - gzFile to; - int first = 1; - int fd; - char * buf; - struct stat sb; - int rc; - int failed; - char * toPath; - char * chptr; - char ** pattern, ** p; - int i; - - uname(&un); - /* strip off BOOT, -SMP, whatever */ - chptr = un.release + strlen(un.release) - 1; - while (!isdigit(*chptr)) chptr--; - *(chptr + 1) = '\0'; - - for (i = 0; modNames[i]; i++) ; - pattern = alloca((i + 1) * sizeof(*pattern)); - - for (i = 0, p = pattern; modNames[i]; i++, p++) { - *p = alloca(strlen(modNames[i]) + strlen(un.release) + 5); - sprintf(*p, "%s*/%s.o", un.release, modNames[i]); - logMessage("extracting pattern %s%s%s", *p, - ddi->title ? " from " : "", - ddi->title ? ddi->title : ""); - } - *p = NULL; - - if (ddi->device) - devMakeInode(ddi->device, ddi->mntDevice); - - while (1) { - failed = 0; - - if (doPwMount(ddi->mntDevice, "/tmp/drivers", ddi->fs, 1, 0, - NULL, NULL)) - failed = 1; - - if (failed && !first) { - newtWinMessage(_("Error"), _("OK"), - _("Failed to mount driver disk: %s."), strerror(errno)); - } 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, ddi->title); - free(buf); - } - - if (failed && !first) { - umount("/tmp/drivers"); - newtWinMessage(_("Error"), _("OK"), - _("The wrong diskette was inserted.")); - } - } - - if (!failed) { - from = gunzip_open("/tmp/drivers/modules.cgz"); - toPath = malloc(strlen(modNames[0]) + 30); - sprintf(toPath, "/tmp/modules/%s", modNames[0]); - mkdirChain(toPath); - strcat(toPath, "/modules.cgz"); - to = gzip_open(toPath, O_TRUNC | O_RDWR | O_CREAT, 0600); - - /* This message isn't good, but it'll do. */ - winStatus(50, 3, _("Loading"), _("Loading %s driver..."), - modNames[0]); - - myCpioFilterArchive(from, to, pattern); - - newtPopWindow(); - - gunzip_close(from); - gunzip_close(to); - umount("/tmp/drivers"); - - return toPath; - } - - first = 0; - - if (ddi->device) - eject(ddi->device); - - rc = newtWinChoice(_("Driver Disk"), _("OK"), _("Cancel"), - _("Please insert the %s driver disk now."), ddi->title); - if (rc == 2) return NULL; - } -} - -char ** extractModules(struct driverDiskInfo * ddi, - char * const * modNames, char ** oldPaths) { - gzFile fd; - char * ballPath; - struct cpioFileMapping * map; - int i, numMaps; - char * const * m; - struct utsname u; - int rc; - const char * failedFile; - char fn[255]; - struct stat sb; - - /* this needs to know about modules64.cgz for sparc */ - - uname(&u); - - if (ddi) { - logMessage("looking for drivers on driver disk"); - ballPath = filterDriverModules(ddi, modNames); - } else { - ballPath = strdup("/modules/modules.cgz"); - } - - fd = gunzip_open(ballPath); - if (!fd) { - logMessage("failed to open %s", ballPath); - free(ballPath); - return NULL; - } - - for (m = modNames, i = 0; *m; i++, m++); - - map = alloca(sizeof(*map) * i); - memset(map, 0, sizeof(*map) * i); - if (!oldPaths) - /* +1 NULL terminates this list */ - oldPaths = calloc(i + 1, sizeof(*oldPaths)); - - for (m = modNames, i = 0, numMaps = 0; *m; m++, i++) { - if (!oldPaths[i]) { - map[numMaps].archivePath = alloca(strlen(u.release) + - strlen(*m) + 25); - sprintf(map[numMaps].archivePath, "%s/%s.o", u.release, *m); - map[numMaps].fsPath = alloca(10 + strlen(*m)); - sprintf(map[numMaps].fsPath, "/tmp/%s.o", *m); - unlink(map[numMaps].fsPath); - map[numMaps].mapFlags = CPIO_MAP_PATH; - numMaps++; - } - } - - /* nothing to do */ - if (!numMaps) { - gunzip_close(fd); - return oldPaths; - } - - qsort(map, numMaps, sizeof(*map), myCpioFileMapCmp); - rc = myCpioInstallArchive(fd, map, numMaps, NULL, NULL, &failedFile); - - gunzip_close(fd); - - for (m = modNames, i = 0, numMaps = 0; *m; m++, i++) { - if (!oldPaths[i]) { - /* can't trust map; the order changed thanks to qsort */ - sprintf(fn, "/tmp/%s.o", modNames[i]); - if (!stat(fn, &sb)) { - if (ddi) - logMessage("module %s found on driver disk %s (%d bytes)", - modNames[i], ddi->title, sb.st_size); - oldPaths[i] = strdup(fn); - } - numMaps++; - } - } - - return oldPaths; -} - void ddReadDriverDiskModInfo(moduleInfoSet modInfo) { int num = 0; char fileName[80]; |