]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod-module: probe: add flag to ignore loaded modules
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Mon, 30 Jan 2012 20:54:45 +0000 (18:54 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Tue, 31 Jan 2012 16:08:57 +0000 (14:08 -0200)
We need a way to tell libkmod to ignore loaded modules, so modprobe can
tell it to dry-run and show dependencies. However there's a conflict
with two flags. KMOD_PROBE_STOP_ON_ALREADY_LOADED prevails if passed
together with KMOD_PROBE_IGNORE_LOADED.

libkmod/libkmod-module.c
libkmod/libkmod.h

index a85eeeafb9841ae92e23d6bec0219d491b9280af..1229a95b6f6d25c6d1f03b4af62682743d6ec946 100644 (file)
@@ -1172,7 +1172,12 @@ KMOD_EXPORT int kmod_module_probe_insert_module(struct kmod_module *mod,
 
                        err = module_do_install_commands(m, options, &cb);
                } else {
-                       int state = kmod_module_get_initstate(m);
+                       int state;
+
+                       if (flags & KMOD_PROBE_IGNORE_LOADED)
+                               state = -1;
+                       else
+                               state = kmod_module_get_initstate(m);
 
                        if (state == KMOD_MODULE_LIVE ||
                                        state == KMOD_MODULE_COMING ||
@@ -1182,10 +1187,9 @@ KMOD_EXPORT int kmod_module_probe_insert_module(struct kmod_module *mod,
                                        break;
                                }
 
-                               DBG(mod->ctx, "Ignoring '%s': "
-                                       "module already loaded\n", m->name);
-                               free(options);
-                               continue;
+                               DBG(mod->ctx, "Ignoring module '%s': "
+                                               "already loaded\n", m->name);
+                               err = 0;
                        }
                        if (print_action != NULL)
                                print_action(m, false, options ?: "");
index a9f6dfcd4644b0384844733ed6ab778df14bf7cc..cf4a7b7b7fee7f52dc31a8bd7df5c5d754bb46e3 100644 (file)
@@ -128,6 +128,7 @@ enum kmod_probe {
        KMOD_PROBE_FORCE_VERMAGIC =             0x00001,
        KMOD_PROBE_FORCE_MODVERSION =           0x00002,
        KMOD_PROBE_IGNORE_COMMAND =             0x00004,
+       KMOD_PROBE_IGNORE_LOADED =              0x00008,
 
        /* codes below can be used in return value, too */
        KMOD_PROBE_APPLY_BLACKLIST_ALL =        0x10000,