diff options
author | Erik Troan <ewt@redhat.com> | 2000-04-26 23:23:02 +0000 |
---|---|---|
committer | Erik Troan <ewt@redhat.com> | 2000-04-26 23:23:02 +0000 |
commit | 58fbf93ed369ca8cf76f712db9f10a90c36d6e0c (patch) | |
tree | 019ee73fba5b89c7e6d9b935401bf2abc5cd6c8e /loader/modules.c | |
parent | ad6042cadfc532aa6c74321fa7d667e86bf6b1ea (diff) | |
download | anaconda-58fbf93ed369ca8cf76f712db9f10a90c36d6e0c.tar.gz anaconda-58fbf93ed369ca8cf76f712db9f10a90c36d6e0c.tar.xz anaconda-58fbf93ed369ca8cf76f712db9f10a90c36d6e0c.zip |
implemented new driver disk structure
Diffstat (limited to 'loader/modules.c')
-rw-r--r-- | loader/modules.c | 108 |
1 files changed, 106 insertions, 2 deletions
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; |