modprobe documentation discrepancy (modules.dep support)
Hi,
the modprobe documentation states that:
%<--------
modprobe expects an up-to-date modules.dep.bin file (or fallback human readable modules.dep file)
%<--------
but in reality no fallback happens in the current code. module-init-tools did the fallback, so I suppose this is a leftover from the previous documentation.
I guess the simplest thing to do would be removing the documentation. On the other hand the depmod.pl script (from ltib.org) doesn't create the binary file, so not supporting "legacy" modules.dep breaks some stuff...
Signature · 4 lines
Best regards | S pozdravom | Mit freundlichen Gr��en | Cordialement Andrej Krutak SYSGO
Hi again,
below is a patch to (re-)add support for modules.dep (in addition to modules.dep.bin), in a very dirty way. Basically I just took parts of the original code from module-init-tools...
Also, it fixes the CHECK_ERR_AND_FINISH macro.
However, this doesn't fix the whole "problem" - 'modprobe nonexistingmodule' is called, no error is printed, because of the faulty processing of subsequent non-existent files (like modules.builtin.bin etc. - which depmod.pl doesn't generate).
To fully fix this, one would have to also add support for the other legacy files. Well, at least a support to handle the missing files gracefully.
Fixing this is important for when you want to cross-compile the kernel in a non-linux environment. I didn't find find any other tool than depmod.pl that could generate all the files required by modprobe (but depmod.pl, as mentioned before, doesn't generate other .bin files) - and kmod/module-init-tools can't be cross-compiled for cygwin/mingw32...
Best regards,
Andrej Krutak
SYSGO
--- libkmod/libkmod-module.c | 4 +- libkmod/libkmod.c | 107 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 107 insertions(+), 4 deletions(-)
libkmod/libkmod-module.c +0 -0
@@ -473,7 +473,7 @@ KMOD_EXPORT struct kmod_module *kmod_module_ref(struct
kmod_module *mod)
if ((_err) < 0) \
goto _label_err; \
if (*(_list) != NULL) \
- goto finish; \
+ goto label_finish; \
} while (0)
/**
@@ -553,7 +553,7 @@ finish:
DBG(ctx, "lookup %s=%d, list=%p\n", alias, err, *list); return err;
fail:
- DBG(ctx, "Failed to lookup %s\n", alias);
+ DBG(ctx, "Failed to lookup %s (%d)\n", alias, err);
kmod_module_unref_list(*list);
*list = NULL;
return err;
libkmod/libkmod.c +74 -0
77 lines not on this page · raw message
*name, const char *fn)
+{
+ char *line;
+ FILE *modules_dep;
+
+ modules_dep = fopen(fn, "r");
+ if (!modules_dep)
+ return NULL;
+
+ /* Stop at first line, as we can have duplicates (eg. symlinks
+ from boot/ */
+ while ((line = getline_wrapped(modules_dep, NULL)) != NULL) {
+ if (is_module_line(line, name))
+ break;
+ free(line);
+ }
+ fclose(modules_dep);
+
+ return line;
+}
+
char *kmod_search_moddep(struct kmod_ctx *ctx, const char *name) {
struct index_file *idx;
char fn[PATH_MAX];
char *line;
+
if (ctx->indexes[KMOD_INDEX_MODULES_DEP]) {
DBG(ctx, "use mmaped index '%s' modname=%s\n",
@@ -553,8 +648,16 @@ char *kmod_search_moddep(struct kmod_ctx *ctx, const char *name)
idx = index_file_open(fn);
if (idx == NULL) {
- DBG(ctx, "could not open moddep file '%s'\n", fn);
- return NULL;
+ struct stat st;
+
+ snprintf(fn, sizeof(fn), "%s/%s", ctx->dirname,
+ index_files[KMOD_INDEX_MODULES_DEP].fn);
+ if (stat(fn, &st) != 0) {
+ DBG(ctx, "could not open moddep file '%s[.bin]'\n", fn);
+ return NULL;
+ }
+
+ return kmod_search_moddep_legacy(ctx, name, fn);
}
line = index_search(idx, name);
Signature · 1 line
1.7.9.5
Quoted 14 lines · Andrej Krutak
Hi again,
below is a patch to (re-)add support for modules.dep (in addition to modules.dep.bin), in a very dirty way. Basically I just took parts of the original code from module-init-tools...
Also, it fixes the
CHECK_ERR_AND_FINISHmacro.However, this doesn't fix the whole "problem" - 'modprobe nonexistingmodule' is called, no error is printed, because of the faulty processing of subsequent non-existent files (like modules.builtin.bin etc. - which depmod.pl doesn't generate).
Quoted 8 lines
To fully fix this, one would have to also add support for the other legacy files. Well, at least a support to handle the missing files gracefully.
Fixing this is important for when you want to cross-compile the kernel in a non-linux environment. I didn't find find any other tool than depmod.pl that could generate all the files required by modprobe (but depmod.pl, as mentioned before, doesn't generate other .bin files) - and kmod/module-init-tools can't be cross-compiled for cygwin/mingw32...
I think it's better to just remove the reference in the man page. We don't support other tools poking /lib/modules/* files. They are private to kmod and we can break them in a future version.
I'd rather advise you to fix your setup so you don't need to cross-compile depmod. If you want to cross-compile... well, you need to provide the patches to at least adding the stubs for things that doesn't exist there... But this patch would probably never be accepted upstream since it's such a weird thing to do, sorry.
Lucas De Marchi