summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Troan <ewt@redhat.com>2001-10-03 23:32:37 +0000
committerErik Troan <ewt@redhat.com>2001-10-03 23:32:37 +0000
commit0e5929d0486328301e1dafbc15fa969b8d0f49d3 (patch)
tree4240a5839d9d233a8c466e769855260a323f38bd
parente69dd253220c61a134f1c93f33947597c6130e23 (diff)
downloadanaconda-0e5929d0486328301e1dafbc15fa969b8d0f49d3.tar.gz
anaconda-0e5929d0486328301e1dafbc15fa969b8d0f49d3.tar.xz
anaconda-0e5929d0486328301e1dafbc15fa969b8d0f49d3.zip
*** empty log message ***
-rw-r--r--loader/devices.c98
-rw-r--r--loader/devices.h3
-rw-r--r--loader/lang.c8
-rw-r--r--loader/loader.c22
-rw-r--r--loader/misc.c7
-rw-r--r--loader/misc.h1
-rw-r--r--loader/modules.c246
-rw-r--r--loader/modules.h5
-rw-r--r--loader/pcmcia.c13
9 files changed, 305 insertions, 98 deletions
diff --git a/loader/devices.c b/loader/devices.c
index a3f98e142..b0aa8d8e8 100644
--- a/loader/devices.c
+++ b/loader/devices.c
@@ -7,6 +7,7 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
+#include <sys/stat.h>
#include <sys/utsname.h>
#include <zlib.h>
#include <linux/fd.h>
@@ -20,7 +21,7 @@
#include "misc.h"
#include "modules.h"
#include "windows.h"
-#include "../kudzu/kudzu.h"
+#include "kudzu/kudzu.h"
#include "isys/cpio.h"
void eject(char * deviceName) {
@@ -441,8 +442,8 @@ int devDeviceMenu(enum driverMajor type, moduleInfoSet modInfo,
return rc;
}
-char * extractModule(struct driverDiskInfo * ddi, char * modName) {
- char * pattern[] = { NULL, NULL };
+static char * filterDriverModules(struct driverDiskInfo * ddi,
+ const char * const * modNames) {
struct utsname un;
gzFile from;
gzFile to;
@@ -454,17 +455,23 @@ char * extractModule(struct driverDiskInfo * ddi, char * modName) {
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';
- pattern[0] = alloca(strlen(modName) + strlen(un.release) + 5);
- sprintf(pattern[0], "%s*/%s.o", un.release, modName);
- logMessage("extracting pattern %s", pattern[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", *p);
+ }
if (ddi->device)
devMakeInode(ddi->device, ddi->mntDevice);
@@ -504,13 +511,15 @@ char * extractModule(struct driverDiskInfo * ddi, char * modName) {
if (!failed) {
from = gzopen("/tmp/drivers/modules.cgz", "r");
- toPath = malloc(strlen(modName) + 30);
- sprintf(toPath, "/tmp/modules/%s", modName);
+ toPath = malloc(strlen(modNames[0]) + 30);
+ sprintf(toPath, "/tmp/modules/%s", modNames[0]);
mkdirChain(toPath);
strcat(toPath, "/modules.cgz");
to = gzopen(toPath, "w");
- winStatus(50, 3, _("Loading"), _("Loading %s driver..."), modName);
+ /* This message isn't good, but it'll do. */
+ winStatus(50, 3, _("Loading"), _("Loading %s driver..."),
+ modNames[0]);
myCpioFilterArchive(from, to, pattern);
@@ -520,7 +529,7 @@ char * extractModule(struct driverDiskInfo * ddi, char * modName) {
gzclose(to);
umount("/tmp/drivers");
- sprintf(toPath, "/tmp/modules/%s", modName);
+ sprintf(toPath, "/tmp/modules/%s", modNames[0]);
return toPath;
}
@@ -535,6 +544,73 @@ char * extractModule(struct driverDiskInfo * ddi, char * modName) {
}
}
+char ** extractModules(struct driverDiskInfo * ddi,
+ const char * const * modNames, char ** oldPaths) {
+ gzFile fd;
+ char * ballPath;
+ struct cpioFileMapping * map;
+ int i, numMaps;
+ const char * const * m;
+ struct utsname u;
+ int rc;
+ const char * failedFile;
+ char fn[255];
+
+ /* this needs to know about modules64.cgz for sparc */
+
+ uname(&u);
+ strcpy(u.release, "2.4.7-10BOOT");
+
+ if (ddi) {
+ ballPath = filterDriverModules(ddi, modNames);
+ } else {
+ ballPath = strdup("/modules/modules.cgz");
+ }
+
+ fd = gzopen(ballPath, "r");
+ 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++;
+ }
+ }
+
+ qsort(map, numMaps, sizeof(*map), myCpioFileMapCmp);
+ rc = myCpioInstallArchive(fd, map, numMaps, NULL, NULL, &failedFile);
+
+ 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 (!access(fn, R_OK))
+ oldPaths[i] = strdup(fn);
+ numMaps++;
+ }
+ }
+
+ return oldPaths;
+}
+
void ddReadDriverDiskModInfo(moduleInfoSet modInfo) {
int num = 0;
char fileName[80];
diff --git a/loader/devices.h b/loader/devices.h
index d20e54bd9..3623cbc4c 100644
--- a/loader/devices.h
+++ b/loader/devices.h
@@ -23,6 +23,7 @@ int devInitDriverDisk(moduleInfoSet modInfo, moduleList modLoaded,
void ddReadDriverDiskModInfo(moduleInfoSet modInfo);
void ejectFloppy(void);
-char * extractModule(struct driverDiskInfo * location, char * modName);
+char ** extractModules(struct driverDiskInfo * location,
+ const char * const * modNames, char ** oldPaths);
#endif
diff --git a/loader/lang.c b/loader/lang.c
index d9f3c2d82..dabceb33e 100644
--- a/loader/lang.c
+++ b/loader/lang.c
@@ -21,6 +21,7 @@
#include "loader.h"
#include "lang.h"
#include "log.h"
+#include "misc.h"
#include "windows.h"
#define errorWindow(String) \
@@ -52,13 +53,6 @@ static int aStringCmp(const void * a, const void * b) {
return 1;
}
-static int simpleStringCmp(const void * a, const void * b) {
- const char * first = *((const char **) a);
- const char * second = *((const char **) b);
-
- return strcmp(first, second);
-}
-
char * translateString(char * str) {
unsigned int sum = 0, xor = 0;
int len = 0;
diff --git a/loader/loader.c b/loader/loader.c
index 1da59ff43..a0ed1ca47 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -2430,11 +2430,8 @@ static int usbInitialize(moduleList modLoaded, moduleDeps modDeps,
NULL, NULL))
logMessage("failed to mount device usbdevfs: %s", strerror(errno));
- mlLoadModule("hid", NULL, modLoaded, modDeps, NULL, modInfo, flags);
- mlLoadModule("keybdev", NULL, modLoaded, modDeps, NULL, modInfo, flags);
-
- /* add a flag to skip this module load maybe ? */
- mlLoadModule("usb-storage", NULL, modLoaded, modDeps, NULL, modInfo, flags);
+ mlLoadModule("hid:keybdev:usb-storage", NULL, modLoaded, modDeps, NULL,
+ modInfo, flags);
return 0;
}
@@ -2503,8 +2500,7 @@ static int agpgartInitialize(moduleList modLoaded, moduleDeps modDeps,
static void scsiSetup(moduleList modLoaded, moduleDeps modDeps,
moduleInfoSet modInfo, int flags,
struct knownDevices * kd) {
- mlLoadModule("sd_mod", NULL, modLoaded, modDeps, NULL, modInfo, flags);
- mlLoadModule("sr_mod", NULL, modLoaded, modDeps, NULL, modInfo,
+ mlLoadModule("sd_mod:sr_mod", NULL, modLoaded, modDeps, NULL, modInfo,
flags);
}
@@ -2655,9 +2651,6 @@ int main(int argc, char ** argv) {
mlLoadDeps(&modDeps, "/modules/modules.dep");
mlLoadModule("cramfs", NULL, modLoaded, modDeps, NULL, modInfo, flags);
-#if 0
- mlLoadModule("ramfs", NULL, modLoaded, modDeps, NULL, modInfo, flags);
-#endif
if (!continuing) {
ideSetup(modLoaded, modDeps, modInfo, flags, &kd);
@@ -2873,13 +2866,8 @@ int main(int argc, char ** argv) {
/* We must look for cards which require the agpgart module */
agpgartInitialize(modLoaded, modDeps, modInfo, flags);
- mlLoadModule("raid0", NULL, modLoaded, modDeps, NULL, modInfo, flags);
- mlLoadModule("raid1", NULL, modLoaded, modDeps, NULL, modInfo, flags);
- mlLoadModule("raid5", NULL, modLoaded, modDeps, NULL, modInfo, flags);
- mlLoadModule("msdos", NULL, modLoaded, modDeps, NULL, modInfo, flags);
- mlLoadModule("vfat", NULL, modLoaded, modDeps, NULL, modInfo, flags);
- mlLoadModule("ext3", NULL, modLoaded, modDeps, NULL, modInfo, flags);
- mlLoadModule("reiserfs", NULL, modLoaded, modDeps, NULL, modInfo, flags);
+ mlLoadModule("raid0:raid1:raid5:msdos:vfat:ext3:reiserfs", NULL,
+ modLoaded, modDeps, NULL, modInfo, flags);
usbInitializeMouse(modLoaded, modDeps, modInfo, flags);
diff --git a/loader/misc.c b/loader/misc.c
index 568df2ea3..059197419 100644
--- a/loader/misc.c
+++ b/loader/misc.c
@@ -59,3 +59,10 @@ char * readLine(FILE * f) {
return strdup(buf);
}
+int simpleStringCmp(const void * a, const void * b) {
+ const char * first = *((const char **) a);
+ const char * second = *((const char **) b);
+
+ return strcmp(first, second);
+}
+
diff --git a/loader/misc.h b/loader/misc.h
index ce4b39b73..2958b4038 100644
--- a/loader/misc.h
+++ b/loader/misc.h
@@ -4,5 +4,6 @@
int copyFile(char * source, char * dest);
int copyFileFd(int infd, char * dest);
char * readLine(FILE * f);
+int simpleStringCmp(const void * a, const void * b);
#endif
diff --git a/loader/modules.c b/loader/modules.c
index 1d9cfd8df..a264a0f03 100644
--- a/loader/modules.c
+++ b/loader/modules.c
@@ -19,6 +19,7 @@
#include "lang.h"
#include "loader.h"
#include "log.h"
+#include "misc.h"
#include "modules.h"
#include "devices.h"
@@ -224,24 +225,90 @@ static void removeExtractedModule(char * path) {
rmdir(path);
}
-int mlLoadModule(char * modName, void * location, moduleList modLoaded,
- moduleDeps modDeps, char ** args, moduleInfoSet modInfo,
- int flags) {
- moduleDeps dep;
- char ** nextDep, ** argPtr;
+/* this leaks memory if their is a loop in the modules. oh well. */
+char ** tsortModules(moduleList modLoaded, moduleDeps ml, char ** args,
+ int depth, char *** listPtr, int * listSizePtr) {
+ int listSize;
+ char ** list;
+ char ** next;
+ char ** deps;
+
+ if (!depth) {
+ int count;
+
+ listSize = 5;
+ list = malloc((listSize + 1) * sizeof(*list));
+ *list = NULL;
+
+ listPtr = &list;
+ listSizePtr = &listSize;
+
+ for (deps = args, count = 0; *deps; deps++, count++);
+ } else {
+ list = *listPtr;
+ listSize = *listSizePtr;
+ }
+
+ if (depth++ > 100) {
+ return NULL;
+ }
+
+ while (*args) {
+ /* don't load it twice */
+ next = list;
+ while (*next && strcmp(*next, *args)) next++;
+
+ if (*next || mlModuleInList(*args, modLoaded)) {
+ args++;
+ continue;
+ }
+
+ /* load everything this depends on */
+ deps = mlGetDeps(ml, *args);
+ if (deps) {
+ if (!tsortModules(modLoaded, ml, deps, depth, listPtr, listSizePtr))
+ return NULL;
+
+ list = *listPtr;
+ listSize = *listSizePtr;
+
+ free(deps);
+ }
+
+ /* add this to the list */
+ next = list;
+ while (*next) next++;
+
+ if ((next - list) >= listSize) {
+ listSize += 10;
+ /* leave room for a NULL */
+ list = realloc(list, sizeof(*list) * (listSize + 1));
+
+ *listSizePtr = listSize;
+ *listPtr = list;
+ }
+
+ next[0] = *args;
+ next[1] = NULL;
+
+ args++;
+ }
+
+ return list;
+}
+
+static int loadModule(const char * modName, char * path, moduleList modLoaded,
+ char ** args, moduleInfoSet modInfo, int flags) {
char fileName[200];
int rc, i;
- char ** arg, ** newArgs;
+ char ** arg, ** newArgs, ** argPtr;
struct moduleInfo * mi = NULL;
int ethDevices = -1;
pid_t child;
int status;
- char * path = NULL;
- int needUmount = 0;
- if (mlModuleInList(modName, modLoaded)) {
+ if (mlModuleInList(modName, modLoaded))
return 0;
- }
if (modInfo && (mi = isysFindModuleInfo(modInfo, modName))) {
if (mi->major == DRIVER_NET && mi->minor == DRIVER_MINOR_ETHERNET) {
@@ -249,37 +316,17 @@ int mlLoadModule(char * modName, void * location, moduleList modLoaded,
}
}
- for (dep = modDeps; dep->name && strcmp(dep->name, modName);
- dep++);
-
- if (dep && dep->deps) {
- nextDep = dep->deps;
- while (*nextDep) {
- 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);
-
sprintf(fileName, "%s.o", modName);
for (argPtr = args; argPtr && *argPtr; argPtr++) {
strcat(fileName, " ");
strcat(fileName, *argPtr);
}
- sprintf(fileName, "%s.o", modName);
-
if (FL_TESTING(flags)) {
- logMessage("would have insmod %s", fileName);
+ logMessage("would have insmod %s", path);
rc = 0;
} else {
- logMessage("going to insmod %s (path is %s)", fileName,
- path ? path : "NULL");
+ logMessage("going to insmod %s", path);
if (!(child = fork())) {
int fd = open("/dev/tty3", O_RDWR);
@@ -289,7 +336,7 @@ int mlLoadModule(char * modName, void * location, moduleList modLoaded,
dup2(fd, 2);
close(fd);
- rc = insmod(fileName, path, args);
+ rc = insmod(path, NULL, args);
_exit(rc);
}
@@ -300,16 +347,14 @@ int mlLoadModule(char * modName, void * location, moduleList modLoaded,
} else {
rc = 0;
}
- }
- if (needUmount)
- umount(path);
+ logMessage("%s done w/ rc %d", path, rc);
+ }
if (!rc) {
modLoaded->mods[modLoaded->numModules].name = strdup(modName);
modLoaded->mods[modLoaded->numModules].weLoaded = 1;
- /* path is malloced by extractModule() */
- modLoaded->mods[modLoaded->numModules].path = path;
+ modLoaded->mods[modLoaded->numModules].path = strdup(path);
modLoaded->mods[modLoaded->numModules].firstDevNum = -1;
modLoaded->mods[modLoaded->numModules].lastDevNum = -1;
modLoaded->mods[modLoaded->numModules].written = 0;
@@ -338,20 +383,6 @@ int mlLoadModule(char * modName, void * location, moduleList modLoaded,
}
modLoaded->mods[modLoaded->numModules++].args = newArgs;
- /* */
- if (!FL_TESTING(flags)) {
- int fd;
-
- fd = open("/tmp/modules.conf", O_WRONLY | O_CREAT | O_APPEND,
- 0666);
- if (fd == -1) {
- logMessage("error appending to /tmp/modules.conf: %s\n",
- strerror(errno));
- } else {
- mlWriteConfModules(modLoaded, fd);
- close(fd);
- }
- }
} else {
if (path) removeExtractedModule(path);
free(path);
@@ -360,6 +391,117 @@ int mlLoadModule(char * modName, void * location, moduleList modLoaded,
return rc;
}
+/* loads a : separated list of modules */
+int mlLoadModuleSet(const char * origModNames, void * location,
+ moduleList modLoaded, moduleDeps modDeps, char ** args,
+ moduleInfoSet modInfo, int flags) {
+ char * modNames;
+ char * end, * start, * next;
+ char ** initialList;
+ int i;
+ char ** list, ** l;
+ char ** paths, ** p;
+
+ start = modNames = alloca(strlen(origModNames) + 1);
+ strcpy(modNames, origModNames);
+
+ next = start, i = 1;
+ while (*next) {
+ if (*next == ':') i++;
+ next++;
+ }
+
+ initialList = alloca(sizeof(*initialList) * (i + 1));
+
+ i = 0;
+ while (start) {
+ next = end = strchr(start, ':');
+ if (next) *end = '\0', next++;
+
+ if (mlModuleInList(start, modLoaded)) {
+ /* already loaded */
+ start = next;
+ continue;
+ }
+
+ initialList[i++] = start;
+
+ start = next;
+ }
+ initialList[i] = NULL;
+
+ list = tsortModules(modLoaded, modDeps, initialList, 0, NULL, NULL);
+ if (!list) {
+ logMessage("found loop in module dependencies; not inserting anything");
+ return 1;
+ }
+
+ paths = NULL;
+ if (location)
+ paths = extractModules(location, list, paths);
+
+ paths = extractModules(NULL, list, paths);
+ i = 0;
+ if (!paths) {
+ logMessage("no modules found -- aborting insertion\n");
+ i++;
+ } else {
+ /* if any modules weren't found, holler */
+ for (l = list, p = paths; *l && p; l++, p++) {
+ if (!*p) {
+ logMessage("module %s not found -- aborting insertion",
+ *l);
+ i++;
+ }
+ }
+ }
+
+ /* insert the modules now */
+ for (l = list, p = paths; !i && *l; l++, p++) {
+ if (loadModule(*l, *p, modLoaded, args, modInfo, flags)) {
+ logMessage("failed to insert %s -- bailing\n", *p);
+ i++;
+ }
+ }
+
+ logMessage("done inserting modules");
+
+ if (!FL_TESTING(flags)) {
+ int fd;
+
+ fd = open("/tmp/modules.conf", O_WRONLY | O_CREAT | O_APPEND,
+ 0666);
+ if (fd == -1) {
+ logMessage("error appending to /tmp/modules.conf: %s\n",
+ strerror(errno));
+ } else {
+ mlWriteConfModules(modLoaded, fd);
+ close(fd);
+ }
+ }
+
+ logMessage("wrote modules.conf");
+
+ for (p = paths; *p; p++) {
+ unlink(*p);
+ free(*p);
+ }
+
+ free(paths);
+ free(list);
+
+ logMessage("load module set done");
+
+ return i;
+}
+
+int mlLoadModule(const char * modName, void * location, moduleList modLoaded,
+ moduleDeps modDeps, char ** args, moduleInfoSet modInfo,
+ int flags) {
+ return mlLoadModuleSet(modName, location, modLoaded, modDeps, args,
+ modInfo, flags);
+}
+
char ** mlGetDeps(moduleDeps modDeps, const char * modName) {
moduleDeps dep;
diff --git a/loader/modules.h b/loader/modules.h
index d2d44ca33..3deed97f2 100644
--- a/loader/modules.h
+++ b/loader/modules.h
@@ -27,9 +27,12 @@ int mlReadLoadedList(moduleList * list);
void mlFreeList(moduleList list);
int mlLoadDeps(moduleDeps * moduleDepList, const char * path);
moduleDeps mlNewDeps(void);
-int mlLoadModule(char * modName, void * location, moduleList modLoaded,
+int mlLoadModule(const char * modName, void * location, moduleList modLoaded,
moduleDeps modDeps, char ** args, moduleInfoSet modInfo,
int flags);
+int mlLoadModuleSet(const char * origModNames, void * location,
+ moduleList modLoaded, moduleDeps modDeps, char ** args,
+ moduleInfoSet modInfo, int flags);
char ** mlGetDeps(moduleDeps modDeps, const char * modName);
int mlModuleInList(const char * modName, moduleList list);
int mlWriteConfModules(moduleList list, int fd);
diff --git a/loader/pcmcia.c b/loader/pcmcia.c
index 8a70996c6..4175d7f99 100644
--- a/loader/pcmcia.c
+++ b/loader/pcmcia.c
@@ -144,16 +144,11 @@ int startPcmcia(char * floppyDevice, moduleList modLoaded, moduleDeps modDeps,
}
}
- if (mlLoadModule(pcic, NULL, modLoaded, modDeps, NULL,
- modInfo, flags)) {
- logMessage("failed to load pcic");
- umount("/modules");
- return LOADER_ERROR;
- }
+ sprintf("%s:ds", pcic);
- if (mlLoadModule("ds", NULL, modLoaded, modDeps, NULL,
- modInfo, flags)) {
- logMessage("failed to load ds");
+ if (mlLoadModuleSet(pcic, NULL, modLoaded, modDeps, NULL,
+ modInfo, flags)) {
+ logMessage("failed to load pcic/ds");
umount("/modules");
return LOADER_ERROR;
}