summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>2007-12-15 00:13:15 -0500
committerBill Nottingham <notting@redhat.com>2007-12-19 15:03:08 -0500
commita46262b9362cb3566f790fd3b7b95f3b1e05dcea (patch)
tree90ccfddbd43859797257c346ba98c171e31be4fb
parent7cd51453fe00fdc2498f3ff2d1b22d8891871bc6 (diff)
downloadanaconda-a46262b9362cb3566f790fd3b7b95f3b1e05dcea.tar.gz
anaconda-a46262b9362cb3566f790fd3b7b95f3b1e05dcea.tar.xz
anaconda-a46262b9362cb3566f790fd3b7b95f3b1e05dcea.zip
Use udev to coldplug modules.
Run udevtrigger to start coldplug, and udevsettle to wait for it to finish.
-rw-r--r--loader2/hardware.c135
1 files changed, 40 insertions, 95 deletions
diff --git a/loader2/hardware.c b/loader2/hardware.c
index 466f01bbe..b1d775121 100644
--- a/loader2/hardware.c
+++ b/loader2/hardware.c
@@ -32,10 +32,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 */
@@ -46,115 +46,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