]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
Only search path in moddep if it's not already set
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Thu, 8 Dec 2011 12:42:34 +0000 (10:42 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Thu, 8 Dec 2011 13:15:24 +0000 (11:15 -0200)
rmmod/insmod should be able to operate directly on files, not relying on
indexes and configuration.

The following test was not working and now it is:

$ # go to a dir != mod->dirname
$ cd /lib/modules/$(uname -r)/kernel
$ # try to insert module giving a relative path
$ insmod drivers/acpi/ac.ko

libkmod/libkmod-module.c

index 3acd5b0c95317052ef2b85006bbe8a37220744c1..d262d2fa77dab0452efb6f00d1ac7ce58dd204f2 100644 (file)
@@ -419,19 +419,22 @@ KMOD_EXPORT const char *kmod_module_get_name(const struct kmod_module *mod)
  */
 KMOD_EXPORT const char *kmod_module_get_path(const struct kmod_module *mod)
 {
-       if (!mod->init.dep) {
-               /* lazy init */
-               char *line = kmod_search_moddep(mod->ctx, mod->name);
+       char *line;
 
-               if (line == NULL)
-                       return NULL;
+       DBG(mod->ctx, "name='%s' path='%s'", mod->name, mod->path);
 
-               kmod_module_parse_depline((struct kmod_module *) mod, line);
-               free(line);
+       if (mod->path != NULL)
+               return mod->path;
+       if (mod->init.dep)
+               return NULL;
 
-               if (!mod->init.dep)
-                       return NULL;
-       }
+       /* lazy init */
+       line = kmod_search_moddep(mod->ctx, mod->name);
+       if (line == NULL)
+               return NULL;
+
+       kmod_module_parse_depline((struct kmod_module *) mod, line);
+       free(line);
 
        return mod->path;
 }