chiark / gitweb /
test: allow deletion of temporary files from normal fs
[elogind.git] / src / modules-load / modules-load.c
index 22ea733..6aeaf45 100644 (file)
@@ -41,7 +41,7 @@ static char **arg_proc_cmdline_modules = NULL;
 static void systemd_kmod_log(void *data, int priority, const char *file, int line,
                              const char *fn, const char *format, va_list args)
 {
-        log_meta(priority, file, line, fn, format, args);
+        log_metav(priority, file, line, fn, format, args);
 }
 #pragma GCC diagnostic pop
 
@@ -49,17 +49,13 @@ static int add_modules(const char *p) {
         char **t, **k;
 
         k = strv_split(p, ",");
-        if (!k) {
-                log_error("Out of memory");
-                return -ENOMEM;
-        }
+        if (!k)
+                return log_oom();
 
         t = strv_merge(arg_proc_cmdline_modules, k);
         strv_free(k);
-        if (!t) {
-                log_error("Out of memory");
-                return -ENOMEM;
-        }
+        if (!t)
+                return log_oom();
 
         strv_free(arg_proc_cmdline_modules);
         arg_proc_cmdline_modules = t;
@@ -90,16 +86,16 @@ static int parse_proc_cmdline(void) {
                         goto finish;
                 }
 
-                if (startswith(word, "driver=")) {
+                if (startswith(word, "modules-load=")) {
 
-                        r = add_modules(word + 7);
+                        r = add_modules(word + 13);
                         if (r < 0)
                                 goto finish;
 
-                } else if (startswith(word, "rd.driver=")) {
+                } else if (startswith(word, "rd.modules-load=")) {
 
                         if (in_initrd()) {
-                                r = add_modules(word + 10);
+                                r = add_modules(word + 16);
                                 if (r < 0)
                                         goto finish;
                         }
@@ -117,7 +113,7 @@ finish:
 }
 
 static int load_module(struct kmod_ctx *ctx, const char *m) {
-        const int probe_flags = KMOD_PROBE_APPLY_BLACKLIST|KMOD_PROBE_IGNORE_LOADED;
+        const int probe_flags = KMOD_PROBE_APPLY_BLACKLIST;
         struct kmod_list *itr, *modlist = NULL;
         int r = 0;
 
@@ -129,22 +125,40 @@ static int load_module(struct kmod_ctx *ctx, const char *m) {
                 return r;
         }
 
+        if (!modlist) {
+                log_error("Failed to find module '%s'", m);
+                return -ENOENT;
+        }
+
         kmod_list_foreach(itr, modlist) {
                 struct kmod_module *mod;
-                int err;
+                int state, err;
 
                 mod = kmod_module_get_module(itr);
-                err = kmod_module_probe_insert_module(mod, probe_flags,
-                                                      NULL, NULL, NULL, NULL);
-
-                if (err == 0)
-                        log_info("Inserted module '%s'", kmod_module_get_name(mod));
-                else if (err == KMOD_PROBE_APPLY_BLACKLIST)
-                        log_info("Module '%s' is blacklisted", kmod_module_get_name(mod));
-                else {
-                        log_error("Failed to insert '%s': %s", kmod_module_get_name(mod),
-                                  strerror(-err));
-                        r = err;
+                state = kmod_module_get_initstate(mod);
+
+                switch (state) {
+                case KMOD_MODULE_BUILTIN:
+                        log_info("Module '%s' is builtin", kmod_module_get_name(mod));
+                        break;
+
+                case KMOD_MODULE_LIVE:
+                        log_info("Module '%s' is already loaded", kmod_module_get_name(mod));
+                        break;
+
+                default:
+                        err = kmod_module_probe_insert_module(mod, probe_flags,
+                                                              NULL, NULL, NULL, NULL);
+
+                        if (err == 0)
+                                log_info("Inserted module '%s'", kmod_module_get_name(mod));
+                        else if (err == KMOD_PROBE_APPLY_BLACKLIST)
+                                log_info("Module '%s' is blacklisted", kmod_module_get_name(mod));
+                        else {
+                                log_error("Failed to insert '%s': %s", kmod_module_get_name(mod),
+                                          strerror(-err));
+                                r = err;
+                        }
                 }
 
                 kmod_module_unref(mod);