summaryrefslogtreecommitdiffstats
path: root/loader
diff options
context:
space:
mode:
authorJeremy Katz <katzj@redhat.com>2001-12-06 21:01:52 +0000
committerJeremy Katz <katzj@redhat.com>2001-12-06 21:01:52 +0000
commit4721016ba96b57674977a4ee52f1a1358b5ec7e2 (patch)
treefc00d2f4b621a7d4dd5e4cc24826ed12ab9cf76d /loader
parent18c298c7969ef2a50a1ee48e4167c414bde1e367 (diff)
downloadanaconda-4721016ba96b57674977a4ee52f1a1358b5ec7e2.tar.gz
anaconda-4721016ba96b57674977a4ee52f1a1358b5ec7e2.tar.xz
anaconda-4721016ba96b57674977a4ee52f1a1358b5ec7e2.zip
merge changes from the 7.2 branch for
* nousbstorage flag * unload usb-storage before loading scsi modules * support for RedHat/base/updates.img
Diffstat (limited to 'loader')
-rw-r--r--loader/devices.c1
-rw-r--r--loader/loader.c65
-rw-r--r--loader/loader.h4
-rw-r--r--loader/modules.c118
-rw-r--r--loader/modules.h5
5 files changed, 186 insertions, 7 deletions
diff --git a/loader/devices.c b/loader/devices.c
index cdc06a5dc..12df690b4 100644
--- a/loader/devices.c
+++ b/loader/devices.c
@@ -643,3 +643,4 @@ void ddReadDriverDiskModInfo(moduleInfoSet modInfo) {
}
}
+
diff --git a/loader/loader.c b/loader/loader.c
index 96727c08d..7ccee7fa9 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -84,6 +84,7 @@ int ourInsmodCommand(int argc, char ** argv);
int kon_main(int argc, char ** argv);
static int mountLoopback(char * fsystem, char * mntpoint, char * device);
static int umountLoopback(char * mntpoint, char * device);
+int copyDirectory(char * from, char * to);
#if defined(__ia64__)
static char * floppyDevice = "hda";
@@ -482,7 +483,7 @@ static int setupStage2Image(int fd, char * dest, int flags,
#ifdef INCLUDE_LOCAL
static int loadLocalImages(char * prefix, char * dir, int flags,
char * device, char * mntpoint) {
- int fd, rc;
+ int fd, rc, fd2;
char * path;
/* In a kind world, this would do nothing more then mount a ramfs
@@ -499,6 +500,19 @@ static int loadLocalImages(char * prefix, char * dir, int flags,
return 1;
}
+ /* handle updates.img now before we copy stage2 over... this allows
+ * us to keep our ramdisk size as small as possible */
+ sprintf(path, "%s/%s/RedHat/base/updates.img", prefix, dir ? dir : "");
+ if ((fd2 = open(path, O_RDONLY)) >= 0) {
+ if (!setupStage2Image(fd2, "/tmp/ramfs/updates-disk.img", flags,
+ "loop7", "/tmp/update-disk")) {
+ copyDirectory("/tmp/update-disk", "/tmp/updates");
+ umountLoopback("/tmp/update-disk", "loop7");
+ unlink("/tmp/ramfs/updates-disk.img");
+ }
+ close(fd2);
+ }
+
rc = setupStage2Image(fd, "/tmp/ramfs/hdstg1.img", flags, device, mntpoint);
close(fd);
@@ -602,6 +616,8 @@ static char * setupOldHardDrive(char * device, char * type, char * dir,
return url;
}
+#endif
+
static int umountLoopback(char * mntpoint, char * device) {
int loopfd;
@@ -617,9 +633,6 @@ static int umountLoopback(char * mntpoint, char * device) {
return 0;
}
-#endif
-
-
static int mountLoopback(char * fsystem, char * mntpoint, char * device) {
struct loop_info loopInfo;
@@ -728,6 +741,20 @@ static int totalMemory(void) {
return total;
}
+/* try to grab an updates.img from /mnt/source/RedHat/base/
+ * XXX hard coded locations suck. oh well
+ */
+static void useMntSourceUpdates() {
+ if (!access("/mnt/source/RedHat/base/updates.img", R_OK)) {
+ if (!mountLoopback("/mnt/source/RedHat/base/updates.img",
+ "/tmp/update-disk", "loop7")) {
+ copyDirectory("/tmp/update-disk", "/tmp/updates");
+ umountLoopback("/tmp/update-disk", "loop7");
+ unlink("/tmp/ramfs/update-disk.img");
+ }
+ }
+}
+
#ifdef INCLUDE_LOCAL
static char * mountHardDrive(struct installMethod * method,
@@ -934,6 +961,7 @@ void ejectCdrom(void) {
}
+
/* XXX this ignores "location", which should be fixed */
static char * mediaCheckCdrom(char *cddriver, int flags) {
@@ -997,6 +1025,8 @@ static char * setupCdrom(struct installMethod * method,
!access("/mnt/source/RedHat/base/stage2.img", R_OK)) {
if (!mountLoopback("/mnt/source/RedHat/base/stage2.img",
"/mnt/runtime", "loop0")) {
+ useMntSourceUpdates();
+
buf = malloc(200);
sprintf(buf, "cdrom://%s/mnt/source", kd->known[i].name);
@@ -1235,6 +1265,7 @@ static char * mountNfsImage(struct installMethod * method,
if (!access("/mnt/source/RedHat/base/stage2.img", R_OK)) {
if (!mountLoopback("/mnt/source/RedHat/base/stage2.img",
"/mnt/runtime", "loop0")) {
+ useMntSourceUpdates();
stage = NFS_STAGE_DONE;
}
} else {
@@ -1308,6 +1339,17 @@ static int loadSingleUrlImage(struct iurlinfo * ui, char * file, int flags,
static int loadUrlImages(struct iurlinfo * ui, int flags) {
setupRamdisk();
+ /* try to pull the updates.img before getting the netstg1.img so
+ * we can minimize our ramdisk size */
+ if (!loadSingleUrlImage(ui, "RedHat/base/updates.img", flags,
+ "/tmp/ramfs/updates-disk.img",
+ "/tmp/update-disk", "loop7")) {
+ /* copy the updates, then unmount the loopback and unlink the img */
+ copyDirectory("/tmp/update-disk", "/tmp/updates");
+ umountLoopback("/tmp/update-disk", "loop7");
+ unlink("/tmp/ramfs/updates-disk.img");
+ }
+
if (loadSingleUrlImage(ui, "RedHat/base/netstg1.img", flags,
"/tmp/ramfs/netstg1.img",
"/mnt/runtime", "loop0")) {
@@ -1316,7 +1358,7 @@ static int loadUrlImages(struct iurlinfo * ui, int flags) {
_("Unable to retrieve the first install image"));
return 1;
}
-
+
return 0;
}
@@ -2011,6 +2053,8 @@ static int parseCmdLineFlags(int flags, char * cmdLine, char ** ksSource,
flags |= LOADER_FLAGS_LOWRES;
else if (!strcasecmp(argv[i], "nofb"))
flags |= LOADER_FLAGS_NOFB;
+ else if (!strcasecmp(argv[i], "nousbstorage"))
+ flags |= LOADER_FLAGS_NOUSBSTORAGE;
else if (!strcasecmp(argv[i], "nousb"))
flags |= LOADER_FLAGS_NOUSB;
else if (!strcasecmp(argv[i], "noprobe"))
@@ -2497,6 +2541,7 @@ void setFloppyDevice(int flags) {
static int usbInitialize(moduleList modLoaded, moduleDeps modDeps,
moduleInfoSet modInfo, int flags) {
struct device ** devices;
+ char * buf = NULL;
if (FL_NOUSB(flags)) return 0;
@@ -2523,8 +2568,14 @@ static int usbInitialize(moduleList modLoaded, moduleDeps modDeps,
NULL, NULL))
logMessage("failed to mount device usbdevfs: %s", strerror(errno));
- mlLoadModuleSet("hid:keybdev:usb-storage", modLoaded, modDeps, modInfo,
- flags);
+ /* sleep so we make sure usb devices get properly initialized */
+ sleep(2);
+
+ buf = alloca(40);
+ sprintf(buf, "hid:keybdev%s",
+ (FL_NOUSBSTORAGE(flags) ? "" : ":usb-storage"));
+ mlLoadModuleSet(buf, modLoaded, modDeps, modInfo, flags);
+ sleep(1);
return 0;
}
diff --git a/loader/loader.h b/loader/loader.h
index 4367e3950..c71d133c1 100644
--- a/loader/loader.h
+++ b/loader/loader.h
@@ -29,6 +29,7 @@
#define LOADER_FLAGS_NOPASS (1 << 23)
#define LOADER_FLAGS_KSHTTP (1 << 24)
#define LOADER_FLAGS_MEDIACHECK (1 << 25)
+#define LOADER_FLAGS_NOUSBSTORAGE (1 << 26)
#define FL_TESTING(a) ((a) & LOADER_FLAGS_TESTING)
#define FL_EXPERT(a) ((a) & LOADER_FLAGS_EXPERT)
@@ -56,7 +57,10 @@
#define FL_NOPASS(a) ((a) & LOADER_FLAGS_NOPASS)
#define FL_KSHTTP(a) ((a) & LOADER_FLAGS_KSHTTP)
#define FL_MEDIACHECK(a) ((a) & LOADER_FLAGS_MEDIACHECK)
+#define FL_NOUSBSTORAGE(a) ((a) & LOADER_FLAGS_NOUSBSTORAGE)
#define CODE_PCMCIA 1
void startNewt(int flags);
+
+void setFloppyDevice(int flags);
diff --git a/loader/modules.c b/loader/modules.c
index dbf3e7601..232bbd057 100644
--- a/loader/modules.c
+++ b/loader/modules.c
@@ -324,6 +324,14 @@ static int loadModule(const char * modName, char * path, moduleList modLoaded,
strcat(fileName, *argPtr);
}
+ if (modInfo && (mi = isysFindModuleInfo(modInfo, modName))) {
+ if (mi->major == DRIVER_SCSI) {
+ /* XXX this shouldn't happen before every load but instead
+ * just before loading a module group */
+ simpleRemoveLoadedModule("usb-storage", modLoaded, flags);
+ }
+ }
+
if (FL_TESTING(flags)) {
logMessage("would have insmod %s", path);
rc = 0;
@@ -349,6 +357,13 @@ static int loadModule(const char * modName, char * path, moduleList modLoaded,
}
}
+ if (modInfo && (strncmp(modName, "usb-storage", 11) != 0) && (mi = isysFindModuleInfo(modInfo, modName))) {
+ if (mi->major == DRIVER_SCSI) {
+ reloadUnloadedModule("usb-storage", NULL, modLoaded, NULL, flags);
+ setFloppyDevice(flags);
+ }
+ }
+
if (!rc) {
modLoaded->mods[modLoaded->numModules].name = strdup(modName);
modLoaded->mods[modLoaded->numModules].weLoaded = 1;
@@ -628,3 +643,106 @@ int mlWriteConfModules(moduleList list, int fd) {
return 0;
}
+
+/* simple removal of a loaded module which is going to be reloaded.
+ * Note that this does NOT modify the modLoaded struct at all
+ */
+int simpleRemoveLoadedModule(const char * modName, moduleList modLoaded,
+ int flags) {
+ int status, rc = 0;
+ pid_t child;
+
+ if (!mlModuleInList(modName, modLoaded)) {
+ return 0;
+ }
+
+ if (FL_TESTING(flags)) {
+ logMessage("would have rmmod %s", modName);
+ rc = 0;
+ } else {
+ logMessage("going to rmmod %s", modName);
+ if (!(child = fork())) {
+ int fd = open("/dev/tty3", O_RDWR);
+
+ dup2(fd, 0);
+ dup2(fd, 1);
+ dup2(fd, 2);
+ close(fd);
+
+ execl("/sbin/rmmod", "/sbin/rmmod", modName, NULL);
+ _exit(rc);
+ }
+
+ waitpid(child, &status, 0);
+
+ if (!WIFEXITED(status) || WEXITSTATUS(status)) {
+ rc = 1;
+ } else {
+ rc = 0;
+ }
+ }
+ return rc;
+}
+
+/* simple reinsertion of a module; just looks for the module and reloads it
+ * if we think it was already loaded
+ */
+int reloadUnloadedModule(char * modName, void * location,
+ moduleList modLoaded, char ** args, int flags) {
+ char fileName[200];
+ int rc, status;
+ pid_t child;
+ char ** path;
+ char ** argPtr;
+ char ** list;
+
+ if (!mlModuleInList(modName, modLoaded)) {
+ return 0;
+ }
+
+ list = malloc(3 * sizeof(*list));
+ *list = modName;
+ *(list + 1) = NULL;
+
+ if (location)
+ path = extractModules(location, tsortModules(modLoaded, NULL, modName, 0, NULL, NULL), (char **) NULL);
+
+ 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);
+ rc = 0;
+ } else {
+ logMessage("going to insmod %s", fileName);
+
+ if (!(child = fork())) {
+ int fd = open("/dev/tty3", O_RDWR);
+
+ dup2(fd, 0);
+ dup2(fd, 1);
+ dup2(fd, 2);
+ close(fd);
+
+ rc = insmod(fileName, NULL, args);
+ _exit(rc);
+ }
+
+ waitpid(child, &status, 0);
+
+ if (!WIFEXITED(status) || WEXITSTATUS(status)) {
+ rc = 1;
+ } else {
+ rc = 0;
+ }
+ }
+
+ logMessage("reloadModule returning %d", rc);
+ return rc;
+}
+
diff --git a/loader/modules.h b/loader/modules.h
index 90f42e795..ab3e1b280 100644
--- a/loader/modules.h
+++ b/loader/modules.h
@@ -40,4 +40,9 @@ char ** mlGetDeps(moduleDeps modDeps, const char * modName);
int mlModuleInList(const char * modName, moduleList list);
int mlWriteConfModules(moduleList list, int fd);
+int simpleRemoveLoadedModule(const char * modName, moduleList modLoaded,
+ int flags);
+int reloadUnloadedModule(char * modName, void * location,
+ moduleList modLoaded, char ** args, int flags);
+
#endif