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

[PATCH 2/3] Implement rdloaddriver= in loader (#689029)



Support dracut's rdloaddriver= option for force-loading kernel modules
at boot time.  This keeps loader's options in line with dracut and deals
with the customer cases where they want to force the loading of a
particular kernel module before udev scans the system.

The following examples are valid:

    rdloaddriver=module
    rdloaddriver=module,module,module

Unlike dracut, you may not specify more than one rdloaddriver= option on
the command line.  If you specify multiple, the installer uses the last
one specified and ignores the preceeding ones.

"rdloaddriver" itself is case-insensitive, but the kernel module name
must exactly match what it's called.
---
 loader/loader.c |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/loader/loader.c b/loader/loader.c
index aa26605..6961b3e 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -899,6 +899,7 @@ static void parseCmdLineFlags(struct loaderData_s * loaderData,
     char buf[1024];
     int len;
     gint argc = 0;
+    gchar *rdloaddriver = NULL;
     gchar **argv = NULL;
     GError *optErr = NULL;
     int numExtraArgs = 0;
@@ -1110,6 +1111,13 @@ static void parseCmdLineFlags(struct loaderData_s * loaderData,
                             &loaderData->proxyPassword, &loaderData->proxy);
         else if (!strncasecmp(argv[i], "noverifyssl", 11))
             flags |= LOADER_FLAGS_NOVERIFYSSL;
+        else if (!strncasecmp(argv[i], "rdloaddriver=", 13)) {
+            if (rdloaddriver != NULL) {
+                g_free(rdloaddriver);
+            }
+
+            rdloaddriver = g_strdup(argv[i] + 13);
+        }
         else if (numExtraArgs < (MAX_EXTRA_ARGS - 1)) {
             /* go through and append args we just want to pass on to */
             /* the anaconda script, but don't want to represent as a */
@@ -1177,6 +1185,25 @@ static void parseCmdLineFlags(struct loaderData_s * loaderData,
     /* NULL terminates the array of extra args */
     extraArgs[numExtraArgs] = NULL;
 
+    /* do rdloaddriver module loading now */
+    if (rdloaddriver != NULL) {
+        gchar **mods = NULL;
+
+        if (g_strcmp0(rdloaddriver, "")) {
+            if ((mods = g_strsplit(rdloaddriver, ",", 0)) != NULL) {
+                for (i=0; i < g_strv_length(mods); i++) {
+                    if (mods[i] != NULL && g_strcmp0(mods[i], "")) {
+                        mlLoadModule(mods[i], NULL);
+                    }
+                }
+
+                g_strfreev(mods);
+            }
+        }
+
+        g_free(rdloaddriver);
+    }
+
     return;
 }
 
-- 
1.7.1


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