[PATCH] modutils: fix config options dependency (2)
Denys Vlasenko
vda.linux at googlemail.com
Sun Feb 5 18:04:21 UTC 2017
Applied a simpler version of it. Thanks
On Wed, Feb 1, 2017 at 10:22 AM, Kang-Che Sung <explorer09 at gmail.com> wrote:
> - The modprobe-small implementation of rmmod no longer chdir's to
> "/lib/modules/`uname -r`" as it was not necessary for rmmod's
> operation. (And it no longer need to die if such modules directory
> doesn't exist.)
> - Configs DEFAULT_MODULES_DIR and DEFAULT_DEPMOD_FILE no longer depend
> on MODPROBE_SMALL as the latter may not enable depmod or modprobe
> that requires these configs.
> - Clarify DEFAULT_DEPMOD_FILE's description regarding the ".bb" name
> suffix.
>
> Signed-off-by: Kang-Che Sung <explorer09 at gmail.com>
> ---
> modutils/Config.src | 10 +++++++---
> modutils/modprobe-small.c | 36 +++++++++++++++++++++++++++++++-----
> 2 files changed, 38 insertions(+), 8 deletions(-)
>
> diff --git a/modutils/Config.src b/modutils/Config.src
> index a15cce518..d0bae2ea3 100644
> --- a/modutils/Config.src
> +++ b/modutils/Config.src
> @@ -159,7 +159,7 @@ config FEATURE_MODUTILS_SYMBOLS
> config DEFAULT_MODULES_DIR
> string "Default directory containing modules"
> default "/lib/modules"
> - depends on DEPMOD || MODPROBE || MODPROBE_SMALL || MODINFO
> + depends on DEPMOD || MODPROBE || MODINFO
> help
> Directory that contains kernel modules.
> Defaults to "/lib/modules"
> @@ -167,9 +167,13 @@ config DEFAULT_MODULES_DIR
> config DEFAULT_DEPMOD_FILE
> string "Default name of modules.dep"
> default "modules.dep"
> - depends on DEPMOD || MODPROBE || MODPROBE_SMALL || MODINFO
> + depends on DEPMOD || MODPROBE || MODINFO
> help
> Filename that contains kernel modules dependencies.
> - Defaults to "modules.dep"
> + Defaults to "modules.dep".
> + If you configured the "simplified modutils" (MODPROBE_SMALL), a
> + ".bb" suffix will be added after this name. Do not specify ".bb"
> + here unless you intend your depmod or modprobe to work on
> + "modules.dep.bb.bb" or such.
>
> endmenu
> diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c
> index 04242634b..a3ba846a7 100644
> --- a/modutils/modprobe-small.c
> +++ b/modutils/modprobe-small.c
> @@ -84,6 +84,22 @@ int lsmod_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
> #define is_insmod (ENABLE_INSMOD && (ONLY_APPLET || applet_name[0] == 'i'))
> #define is_rmmod (ENABLE_RMMOD && (ONLY_APPLET || applet_name[0] == 'r'))
>
> +/* Applets that need to chdir to /lib/modules/`uname -r` */
> +/* Note: the last conditional is used when all 4 applets are configured, and
> + * employs an ASCII trick so that one check would suffice:
> + * 'm' -> 01101101
> + * 'd' -> 01100100
> + * 'i' -> 01101001
> + * 'r' -> 01110010 ('d' & 'm' & '\x1f') == '\x04' -> 00000100
> + * .....^.. note this bit! */
> +#define is_depmod_or_modprobe ((ENABLE_MODPROBE || ENABLE_DEPMOD) \
> + && ((!ENABLE_INSMOD && !ENABLE_RMMOD) \
> + || (!ENABLE_MODPROBE && applet_name[0] == 'd') \
> + || (!ENABLE_DEPMOD && applet_name[0] == 'm') \
> + || (!ENABLE_INSMOD && applet_name[0] != 'r') \
> + || (!ENABLE_RMMOD && applet_name[0] != 'i') \
> + || ((applet_name[0] & ('d' & 'm' & '\x1f')) != 0)))
> +
> enum {
> OPT_q = (1 << 0), /* be quiet */
> OPT_r = (1 << 1), /* module removal instead of loading */
> @@ -923,23 +939,30 @@ The following options are useful for people managing distributions:
> int modprobe_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
> int modprobe_main(int argc UNUSED_PARAM, char **argv)
> {
> +#if ENABLE_DEPMOD || ENABLE_MODPROBE
> + struct utsname uts;
> +#endif
> #if ENABLE_MODPROBE || ENABLE_INSMOD || ENABLE_RMMOD
> int exitcode;
> +# if ENABLE_FEATURE_CMDLINE_MODULE_OPTIONS
> + char *options = NULL;
> +# endif
> #endif
> - struct utsname uts;
> - IF_FEATURE_CMDLINE_MODULE_OPTIONS(char *options = NULL;)
>
> INIT_G();
>
> /* Prevent ugly corner cases with no modules at all */
> modinfo = xzalloc(sizeof(modinfo[0]));
>
> - if (!is_insmod) {
> +#if ENABLE_DEPMOD || ENABLE_MODPROBE
> + if (is_depmod_or_modprobe) {
> /* Goto modules directory */
> xchdir(CONFIG_DEFAULT_MODULES_DIR);
> + uname(&uts); /* never fails */
> }
> - uname(&uts); /* never fails */
> +#endif
>
> +#if ENABLE_DEPMOD
> /* depmod? */
> if (is_depmod) {
> /* Supported:
> @@ -971,6 +994,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
> process_module((char*)"/", NULL);
> return !wrote_dep_bb_ok;
> }
> +#endif /* DEPMOD */
>
> #if ENABLE_MODPROBE || ENABLE_INSMOD || ENABLE_RMMOD
> /* modprobe, insmod, rmmod require at least one argument */
> @@ -980,10 +1004,12 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
> getopt32(argv, "qrfsvwb");
> argv += optind;
>
> - if (!is_insmod) {
> +# if ENABLE_MODPROBE
> + if (is_modprobe) {
> /* Goto $VERSION directory */
> xchdir(uts.release);
> }
> +# endif
>
> /* are we rmmod? -> simulate modprobe -r, but don't bother the flag if
> * there're no other applets here */
> --
> 2.11.0
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
More information about the busybox
mailing list