[PATCH 01/19] Load all scsi_dh_* modules, since they can't be modprobe by aliases...

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

 



Load all scsi_dh_* modules.  These know how to bind to scsi targets, and
which devices to bind to, so this will really only effect people with those
targets.
---
 loader/loader.c |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/loader/loader.c b/loader/loader.c
index 645e7cf..9605b69 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -49,6 +49,7 @@
 #include <sys/socket.h>
 #include <sys/stat.h>
 #include <sys/wait.h>
+#include <sys/utsname.h>
 
 #include <linux/fb.h>
 #include <linux/serial.h>
@@ -1767,6 +1768,54 @@ static void add_to_path_env(const char *env, const char *val)
     setenv(env, newenv, 1);
 }
 
+static void loadScsiDhModules(void)
+{
+    struct utsname utsname;
+    char *modules = NULL;
+    char *tmp = NULL;
+    struct dirent *ent = NULL;
+
+    uname(&utsname);
+    checked_asprintf(&tmp,
+        "/lib/modules/%s/kernel/drivers/scsi/device_handler", utsname.release);
+
+    DIR *dir = opendir(tmp);
+    free(tmp);
+    if (!dir)
+        return;
+
+    int fd = dirfd(dir);
+    while ((ent = readdir(dir)) != NULL) {
+        struct stat sb;
+
+        if (fstatat(fd, ent->d_name, &sb, 0) < 0)
+            continue;
+
+        size_t len = strlen(ent->d_name) - 3;
+        if (strcmp(ent->d_name+len, ".ko"))
+            continue;
+
+        if (S_ISREG(sb.st_mode)) {
+            char modname[len+1];
+            strncpy(modname, ent->d_name, len);
+	    modname[len] = '\0';
+
+            if (modules && modules[0]) {
+                checked_asprintf(&tmp, "%s:%s", modules, modname);
+            } else {
+                checked_asprintf(&tmp, "%s", modname);
+            }
+
+            free(modules);
+            modules = tmp;
+        }
+    }
+    closedir(dir);
+
+    mlLoadModuleSet(modules);
+    free(modules);
+}
+
 int main(int argc, char ** argv) {
     int rc, ret, pid, status;
 
@@ -1930,6 +1979,8 @@ int main(int argc, char ** argv) {
 
     mlLoadModuleSet("cramfs:squashfs:iscsi_tcp");
 
+    loadScsiDhModules();
+
 #if !defined(__s390__) && !defined(__s390x__)
     mlLoadModuleSet("floppy:edd:pcspkr:iscsi_ibft");
 #endif
-- 
1.6.5.2

_______________________________________________
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