[PATCH 7/8] Use udev to coldplug modules.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Run udevtrigger to start coldplug, and udevsettle to wait for it to
finish.
---
 loader2/hardware.c |  135 +++++++++++++++------------------------------------
 1 files changed, 40 insertions(+), 95 deletions(-)

diff --git a/loader2/hardware.c b/loader2/hardware.c
index ccd40dd..3a63741 100644
--- a/loader2/hardware.c
+++ b/loader2/hardware.c
@@ -25,10 +25,10 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <ctype.h>
+#include <sys/wait.h>
 
 #include "loader.h"
 #include "hardware.h"
-#include "pcmcia.h"
 #include "log.h"
 
 /* FIXME: for turning off dma */
@@ -39,115 +39,60 @@
 /* boot flags */
 extern uint64_t flags;
 
-static int detectHardware(moduleInfoSet modInfo, char *** modules) {
-    struct device ** devices, ** device;
-    char ** modList;
-    int numMods;
-    char *driver;
+static int detectHardware(char *** modules) {
+    int child, rc, status;
+    int timeout = 0; /* FIXME: commandline option for this */
 
     logMessage(DEBUGLVL, "probing buses");
 
-    devices = probeDevices(CLASS_UNSPEC,
-                           BUS_PCI | BUS_SBUS | BUS_VIO | BUS_MACIO |
-                           /* Waiting on a kudzu that supports BUS_EBUS... */
-                           /* BUS_PCMCIA | BUS_XEN | BUS_EBUS | BUS_PS3, */
-                           BUS_PCMCIA | BUS_XEN | BUS_PS3 | BUS_USB,
-                           PROBE_ALL);
+    if (!(child = fork())) {
+        int fd = open("/dev/tty3", O_RDWR);
 
-    logMessage(DEBUGLVL, "finished bus probing");
+        dup2(fd, 0);
+        dup2(fd, 1);
+        dup2(fd, 2);
+        close(fd);
 
-    if (devices == NULL) {
-        *modules = NULL;
-        return LOADER_OK;
+        rc = execl("/sbin/udevtrigger","udevtrigger",NULL);
+        _exit(1);
     }
-    
-    numMods = 0;
-    for (device = devices; *device; device++) numMods++;
-    
-    if (!numMods) {
-        *modules = NULL;
-        return LOADER_OK;
-    }
-    
-    modList = malloc(sizeof(*modList) * (numMods + 1));
-    numMods = 0;
-    
-    for (device = devices; *device; device++) {
-        driver = (*device)->driver;
-        /* this is kind of icky and verbose.  there are better and more 
-         * general ways to do it but this is simple and obvious */
-	if (!driver) {
-	    logMessage(DEBUGLVL, "ignoring driverless device %s", (*device)->desc);
-        } else if (FL_NOPCMCIA(flags) && ((*device)->type == CLASS_SOCKET)) {
-            logMessage(DEBUGLVL, "ignoring pcmcia device %s (%s)",
-                       (*device)->desc, driver);
-        } else if (FL_NOIEEE1394(flags) && ((*device)->type == CLASS_FIREWIRE)) {
-            logMessage(DEBUGLVL, "ignoring firewire device %s (%s)",
-                       (*device)->desc, driver);
-        } else if (FL_NOUSB(flags) && ((*device)->type == CLASS_USB)) {
-            logMessage(DEBUGLVL, "ignoring usb device %s (%s)", (*device)->desc,
-                       driver);
-        } else if (FL_NOSTORAGE(flags) && 
-                   (((*device)->type == CLASS_SCSI) || 
-                    ((*device)->type == CLASS_IDE) ||
-                    ((*device)->type == CLASS_RAID) ||
-                    ((*device)->type == CLASS_ATA) ||
-                    ((*device)->type == CLASS_SATA))) {
-            logMessage(DEBUGLVL, "ignoring storage device %s (%s)",
-                       (*device)->desc, driver);
-        } else if (FL_NONET(flags) && ((*device)->type == CLASS_NETWORK)) {
-            logMessage(DEBUGLVL, "ignoring network device %s (%s)",
-                       (*device)->desc, driver);
-        } else {
-            modList[numMods++] = strdup(driver);
-        }
-        
-        freeDevice (*device);
+
+    waitpid(child, &status, 0);
+    if (!WIFEXITED(status) || (WIFEXITED(status) && WEXITSTATUS(status))) {
+        rc = 1;
+    } else {
+        rc = 0;
     }
-    
-    modList[numMods] = NULL;
-    *modules = modList;
-    
-    free(devices);
-    
-    return LOADER_OK;
-}
 
-int scsiTapeInitialize(moduleList modLoaded, moduleDeps modDeps,
-                      moduleInfoSet modInfo) {
-    struct device ** devices;
+    logMessage(DEBUGLVL, "waiting for hardware to initialize");
 
-    if (FL_TESTING(flags)) return 0;
+    if (!(child = fork())) {
+        char *args[] = { "/sbin/udevsettle", "udevsettle", NULL, NULL };
+        int fd = open("/dev/tty3", O_RDWR);
 
-    logMessage(INFO, "looking for scsi tape devices");
-    
-    devices = probeDevices(CLASS_TAPE, BUS_SCSI, 0);
-    
-    if (!devices) {
-        logMessage(INFO, "no scsi tape devices found");
-        return 0;
-    }
+        dup2(fd, 0);
+        dup2(fd, 1);
+        dup2(fd, 2);
+        close(fd);
 
-    logMessage(INFO, "scsi tape device(s) found, loading st.ko");
+        if (timeout) {
+            rc = asprintf(&args[2],"--timeout=%d",timeout);
+        }
 
-    if (mlLoadModuleSet("st", modLoaded, modDeps, modInfo)) {
-	logMessage(ERROR, "failed to insert st module");
-	return 1;
+        rc = execv("/sbin/udevsettle",args);
+        _exit(1);
     }
-    
-    return 0;
-}
-
 
-int probeiSeries(moduleInfoSet modInfo, moduleList modLoaded, 
-		 moduleDeps modDeps) {
-    /* this is a hack since we can't really probe on iSeries */
-#ifdef __powerpc__
-    if (!access("/proc/iSeries", X_OK)) {
-	mlLoadModuleSet("iseries_veth:veth:viodasd:viocd", modLoaded, modDeps, modInfo);
+    waitpid(child, &status, 0);
+    if (!WIFEXITED(status) || (WIFEXITED(status) && WEXITSTATUS(status))) {
+        rc = 1;
+    } else {
+        rc = 0;
     }
-#endif
-    return 0;
+    if (rc) {
+        return LOADER_ERROR;
+    }
+    return LOADER_OK;
 }
 
 /* this allows us to do an early load of modules specified on the
-- 
1.5.3.7

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux