-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libkmod: tools: Introduce 'module alternative' directory (was: module fallback) #261
base: master
Are you sure you want to change the base?
Conversation
Can we get a manpage(s) update, on how things are supposed to work? Ideally it will include (either the doc or commit message) some details why the alternative ordering or behaviour isn't warranted. Once that is solid and we're comfortable things won't backfire/respective workflows are supported/etc, we can beat the code and tests in shape. |
Sure, I thought the commit messages and PR description were self explanatory.
|
Hi @evelikov I am re-reading your notification and I am not sure what you mean with |
Hi @evelikov can you please answer my question? I will be happy to add manpage if you tell me what you want to see exactly |
This option allows the user to specify the alternative directory that the kmod tools should look at when MODULE_DIRECTORY is empty. Defaults to /run/modules. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
Move code in do_static_nodes into two helpers: one to get the dirname (MODULE_DIRECTORY/$kernel) and another to do the main logic. This is in preparation to perform the same two steps again for the new MODULE_ALTERNATIVE_DIRECTORY option. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
If nothing is found in MODULE_DIRECTORY, perform the same exact steps but with MODULE_ALTERNATIVE_DIRECTORY. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
Move code in do_modinfo into two helpers: one to get the dirname ($root/MODULE_DIRECTORY/$kernel) and another to do the main logic. The first helper, get_module_dirname(), is also always called to figure the dirname path and to avoid providing NULL to the kmod_new() API. This is because kmod_new() always defaults to MODULE_DIRECTORY when the dirname path is empty, and won't work when MODULE_ALTERNATIVE_DIRECTORY will be used. This is in preparation to perform the same two steps again for the new MODULE_ALTERNATIVE_DIRECTORY option. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
If nothing is found in MODULE_DIRECTORY, perform the same exact steps but with MODULE_ALTERNATIVE_DIRECTORY. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
Move code in do_modprobe into two helpers: one to get the dirname ($root/MODULE_DIRECTORY/$kernel) and another to do the main logic. The first helper, get_module_dirname(), is also always called to figure the dirname path and to avoid providing NULL to the kmod_new() API. This is because kmod_new() always defaults to MODULE_DIRECTORY when the dirname path is empty, and won't work when MODULE_ALTERNATIVE_DIRECTORY will be used. This is in preparation to perform the same two steps again for the new MODULE_ALTERNATIVE_DIRECTORY option. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
If nothing is found in MODULE_DIRECTORY, perform the same exact steps but with MODULE_ALTERNATIVE_DIRECTORY. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
Move code in do_insmod into two helpers: one to get the dirname ($root/MODULE_DIRECTORY/$kernel) and another to do the main logic. The first helper, get_module_dirname(), is also always called to figure the dirname path and to avoid providing NULL to the kmod_new() API. This is because kmod_new() always defaults to MODULE_DIRECTORY when the dirname path is empty, and won't work when MODULE_ALTERNATIVE_DIRECTORY will be used. This is in preparation to perform the same two steps again for the new MODULE_ALTERNATIVE_DIRECTORY option. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
If nothing is found in MODULE_DIRECTORY, perform the same exact steps but with MODULE_ALTERNATIVE_DIRECTORY. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
Move code in do_lsmod into two helpers: one to get the dirname ($root/MODULE_DIRECTORY/$kernel) and another to do the main logic. The first helper, get_module_dirname(), is also always called to figure the dirname path and to avoid providing NULL to the kmod_new() API. This is because kmod_new() always defaults to MODULE_DIRECTORY when the dirname path is empty, and won't work when MODULE_ALTERNATIVE_DIRECTORY will be used. This is in preparation to perform the same two steps again for the new MODULE_ALTERNATIVE_DIRECTORY option. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
If nothing is found in MODULE_DIRECTORY, perform the same exact steps but with MODULE_ALTERNATIVE_DIRECTORY. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
Move code in do_rmmod into two helpers: one to get the dirname ($root/MODULE_DIRECTORY/$kernel) and another to do the main logic. The first helper, get_module_dirname(), is also always called to figure the dirname path and to avoid providing NULL to the kmod_new() API. This is because kmod_new() always defaults to MODULE_DIRECTORY when the dirname path is empty, and won't work when MODULE_ALTERNATIVE_DIRECTORY will be used. This is in preparation to perform the same two steps again for the new MODULE_ALTERNATIVE_DIRECTORY option. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
If nothing is found in MODULE_DIRECTORY, perform the same exact steps but with MODULE_ALTERNATIVE_DIRECTORY. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
…issing Currently if no module is found in MODULE_DIRECTORY, kmod will just print "Module %s not found", but now that we have two search path, it is worth specifying which is the path that was not found. TODO: ERR() produces a not so pleasant to see error which might confuse the user, especially if a module is in MODULE_ALTERNATIVE_DIRECTORY and not in MODULE_DIRECTORY, because we would have such output: modprobe: ERROR: Module %s not found in directory <MODULE_DIRECTORY> <output foud in MODULE_ALTERNATIVE_DIRECTORY> Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
Now that we have to repeat the same logic twice for MODULE_DIRECTORY and MODULE_ALTERNATIVE_DIRECTORY, setting LOG priority to FATAL causes modprobe to exit failure, without trying the second path. Therefore increase the log priority to ERROR. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
a0ec54b
to
2c9821c
Compare
This PR is the improvement of #202 opened by @vittyvk .
Below you find a description of the original PR. The main change here is that if
/lib/modules
exists, nothing changes in kmod functionality. If, however, for some reasons it misses,/run/modules
is used as search path.The change itself is pretty easy: call twice the same logic for each tool with a different, customizable path (
MODULE_DIRECTORY
andMODULE_ALTERNATIVE_DIRECTORY
).The only things that is missing is what to do with error prints. As I suggest in the penultimate commit "tools: improve error logs to specify in which dirname is the module missing", it is pretty confusing to see first an error and then a successful output, or even worse no output (because modprobe doesn't print anything if it works).
Something similar also happens in the last commit, where I must decrease the log priority otherwise the second call to the main function in modprobe is not called.
For the above reasons, I did not implement any test yet.
Another consideration is static-nodes: as I understand, it will read a input file from ctx->dirname and then will print informations about the modules. So should it run on both MODULE_DIRECTORY and MODULE_ALTERNATIVE_DIRECTORY?
Original PR description: