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
*/
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;
}