From e1065da652ca3680fdf465dd502a2bae2c2a89b9 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 22 Dec 2016 14:36:49 +0100 Subject: Tweak some config defaults; fix MODPROBE_SMALL ordering in "make config" Signed-off-by: Denys Vlasenko --- modutils/modprobe-small.c | 34 +++------------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) (limited to 'modutils/modprobe-small.c') diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c index 51ba42f7a..e3a349b4e 100644 --- a/modutils/modprobe-small.c +++ b/modutils/modprobe-small.c @@ -7,37 +7,9 @@ * * Licensed under GPLv2, see file LICENSE in this source tree. */ -//config:config MODPROBE_SMALL -//config: bool "Simplified modutils" -//config: default y -//config: select PLATFORM_LINUX -//config: help -//config: Simplified modutils. -//config: -//config: With this option modprobe does not require modules.dep file -//config: and does not use /etc/modules.conf file. -//config: It scans module files in /lib/modules/`uname -r` and -//config: determines dependencies and module alias names on the fly. -//config: This may make module loading slower, most notably -//config: when one needs to load module by alias (this requires -//config: scanning through module _bodies_). -//config: -//config: At the first attempt to load a module by alias modprobe -//config: will try to generate modules.dep.bb file in order to speed up -//config: future loads by alias. Failure to do so (read-only /lib/modules, -//config: etc) is not reported, and future modprobes will be slow too. -//config: -//config: NB: modules.dep.bb file format is not compatible -//config: with modules.dep file as created/used by standard module tools. -//config: -//config: Additional module parameters can be stored in -//config: /etc/modules/$module_name files. -//config: -//config: Apart from modprobe, other utilities are also provided: -//config: - insmod is an alias to modprobe -//config: - rmmod is an alias to modprobe -r -//config: - depmod generates modules.dep.bb -//config: + +/* config MODPROBE_SMALL is defined in Config.src to ensure better "make config" order */ + //config:config FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE //config: bool "Accept module options on modprobe command line" //config: default y -- cgit v1.2.3-55-g6feb From d28cd9900a58a902b1bf53404a250dfb345b2e96 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 23 Dec 2016 15:12:27 +0100 Subject: modprobe-small: make applets individually selectable Signed-off-by: Denys Vlasenko --- include/applets.h.sh | 3 +-- make_single_applets.sh | 7 ++++++- modutils/depmod.c | 7 ++++--- modutils/insmod.c | 5 +++-- modutils/lsmod.c | 11 ++++++----- modutils/modprobe-small.c | 24 ++++++++++++------------ modutils/modprobe.c | 11 ++++++----- modutils/rmmod.c | 5 +++-- 8 files changed, 41 insertions(+), 32 deletions(-) (limited to 'modutils/modprobe-small.c') diff --git a/include/applets.h.sh b/include/applets.h.sh index be8b92404..be117cf84 100755 --- a/include/applets.h.sh +++ b/include/applets.h.sh @@ -4,8 +4,7 @@ # enabling it. Run it after applets.h is generated. # CONFIG_applet names -grep ^IF_ applets.h | grep -v IF_FEATURE_ | sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \ -| grep -v MODPROBE_SMALL \ +grep ^IF_ applets.h | grep -v ^IF_FEATURE_ | sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \ | sort | uniq \ >applets_APP1 diff --git a/make_single_applets.sh b/make_single_applets.sh index 5b9393e33..6473e4ddd 100755 --- a/make_single_applets.sh +++ b/make_single_applets.sh @@ -14,7 +14,6 @@ apps="` grep ^IF_ include/applets.h \ | grep -v ^IF_FEATURE_ \ | sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \ -| grep -v ^MODPROBE_SMALL \ | sort | uniq `" @@ -46,6 +45,11 @@ for app in $apps; do : $((fail++)) echo "Build error for ${app}" mv .config busybox_config_${app} + elif ! grep -q '^#define NUM_APPLETS 1$' include/NUM_APPLETS.h; then + mv busybox busybox_${app} + : $((fail++)) + echo "NUM_APPLETS != 1 for ${app}: `cat include/NUM_APPLETS.h`" + mv .config busybox_config_${app} else mv busybox busybox_${app} rm busybox_make_${app}.log @@ -53,5 +57,6 @@ for app in $apps; do mv .config.SV .config #exit done +touch .config # or else next "make" can be confused echo "Failures: $fail" test $fail = 0 # set exitcode diff --git a/modutils/depmod.c b/modutils/depmod.c index b9347027e..cfa9abb1a 100644 --- a/modutils/depmod.c +++ b/modutils/depmod.c @@ -9,15 +9,16 @@ */ //config:config DEPMOD //config: bool "depmod" -//config: default n -//config: depends on !MODPROBE_SMALL +//config: default y //config: select PLATFORM_LINUX //config: help //config: depmod generates modules.dep (and potentially modules.alias //config: and modules.symbols) that contain dependency information //config: for modprobe. -//applet:IF_DEPMOD(APPLET(depmod, BB_DIR_SBIN, BB_SUID_DROP)) +//kbuild:ifneq ($(CONFIG_MODPROBE_SMALL),y) +//applet:IF_DEPMOD(IF_NOT_MODPROBE_SMALL(APPLET(depmod, BB_DIR_SBIN, BB_SUID_DROP))) +//kbuild:endif //kbuild:lib-$(CONFIG_DEPMOD) += depmod.o modutils.o diff --git a/modutils/insmod.c b/modutils/insmod.c index 2ebf4beb9..5949fe551 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c @@ -9,14 +9,15 @@ //config:config INSMOD //config: bool "insmod" //config: default n -//config: depends on !MODPROBE_SMALL //config: select PLATFORM_LINUX //config: help //config: insmod is used to load specified modules in the running kernel. -//applet:IF_INSMOD(APPLET(insmod, BB_DIR_SBIN, BB_SUID_DROP)) +//applet:IF_INSMOD(IF_NOT_MODPROBE_SMALL(APPLET(insmod, BB_DIR_SBIN, BB_SUID_DROP))) +//kbuild:ifneq ($(CONFIG_MODPROBE_SMALL),y) //kbuild:lib-$(CONFIG_INSMOD) += insmod.o modutils.o +//kbuild:endif #include "libbb.h" #include "modutils.h" diff --git a/modutils/lsmod.c b/modutils/lsmod.c index ee85fb0fb..24589420a 100644 --- a/modutils/lsmod.c +++ b/modutils/lsmod.c @@ -9,25 +9,26 @@ */ //config:config LSMOD //config: bool "lsmod" -//config: default n -//config: depends on !MODPROBE_SMALL +//config: default y //config: select PLATFORM_LINUX //config: help //config: lsmod is used to display a list of loaded modules. //config: //config:config FEATURE_LSMOD_PRETTY_2_6_OUTPUT //config: bool "Pretty output" -//config: default n -//config: depends on LSMOD +//config: default y +//config: depends on LSMOD && !MODPROBE_SMALL //config: select PLATFORM_LINUX //config: help //config: This option makes output format of lsmod adjusted to //config: the format of module-init-tools for Linux kernel 2.6. //config: Increases size somewhat. -//applet:IF_LSMOD(APPLET(lsmod, BB_DIR_SBIN, BB_SUID_DROP)) +//applet:IF_LSMOD(IF_NOT_MODPROBE_SMALL(APPLET(lsmod, BB_DIR_SBIN, BB_SUID_DROP))) +//kbuild:ifneq ($(CONFIG_MODPROBE_SMALL),y) //kbuild:lib-$(CONFIG_LSMOD) += lsmod.o modutils.o +//kbuild:endif //usage:#if !ENABLE_MODPROBE_SMALL //usage:#define lsmod_trivial_usage diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c index e3a349b4e..652ff4dfa 100644 --- a/modutils/modprobe-small.c +++ b/modutils/modprobe-small.c @@ -25,11 +25,11 @@ //config: help //config: Check if the module is already loaded. -//applet:IF_MODPROBE_SMALL(APPLET(modprobe, BB_DIR_SBIN, BB_SUID_DROP)) -//applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(depmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, depmod)) -//applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(insmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, insmod)) -//applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(lsmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, lsmod)) -//applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(rmmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, rmmod)) +//applet:IF_MODPROBE(IF_MODPROBE_SMALL(APPLET(modprobe, BB_DIR_SBIN, BB_SUID_DROP))) +//applet:IF_DEPMOD(IF_MODPROBE_SMALL(APPLET_ODDNAME(depmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, depmod))) +//applet:IF_INSMOD(IF_MODPROBE_SMALL(APPLET_ODDNAME(insmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, insmod))) +//applet:IF_LSMOD(IF_MODPROBE_SMALL(APPLET_ODDNAME(lsmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, lsmod))) +//applet:IF_RMMOD(IF_MODPROBE_SMALL(APPLET_ODDNAME(rmmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, rmmod))) //kbuild:lib-$(CONFIG_MODPROBE_SMALL) += modprobe-small.o @@ -930,7 +930,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv) IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(char *options;) /* are we lsmod? -> just dump /proc/modules */ - if ('l' == applet0) { + if (ENABLE_LSMOD && 'l' == applet0) { xprint_and_close_file(xfopen_for_read("/proc/modules")); return EXIT_SUCCESS; } @@ -940,14 +940,14 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv) /* Prevent ugly corner cases with no modules at all */ modinfo = xzalloc(sizeof(modinfo[0])); - if ('i' != applet0) { /* not insmod */ + if (!ENABLE_INSMOD || 'i' != applet0) { /* not insmod */ /* Goto modules directory */ xchdir(CONFIG_DEFAULT_MODULES_DIR); } uname(&uts); /* never fails */ /* depmod? */ - if ('d' == applet0) { + if (ENABLE_DEPMOD && 'd' == applet0) { /* Supported: * -n: print result to stdout * -a: process all modules (default) @@ -986,11 +986,11 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv) argv += optind; /* are we rmmod? -> simulate modprobe -r */ - if ('r' == applet0) { + if (ENABLE_RMMOD && 'r' == applet0) { option_mask32 |= OPT_r; } - if ('i' != applet0) { /* not insmod */ + if (!ENABLE_INSMOD || 'i' != applet0) { /* not insmod */ /* Goto $VERSION directory */ xchdir(uts.release); } @@ -1014,7 +1014,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv) argv[1] = NULL; #endif - if ('i' == applet0) { /* insmod */ + if (ENABLE_INSMOD && 'i' == applet0) { /* insmod */ size_t len; void *map; @@ -1034,7 +1034,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv) } /* Try to load modprobe.dep.bb */ - if ('r' != applet0) { /* not rmmod */ + if (!ENABLE_RMMOD || 'r' != applet0) { /* not rmmod */ load_dep_bb(); } diff --git a/modutils/modprobe.c b/modutils/modprobe.c index d404ef92f..09e3de6c3 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c @@ -9,8 +9,7 @@ */ //config:config MODPROBE //config: bool "modprobe" -//config: default n -//config: depends on !MODPROBE_SMALL +//config: default y //config: select PLATFORM_LINUX //config: help //config: Handle the loading of modules, and their dependencies on a high @@ -18,8 +17,8 @@ //config: //config:config FEATURE_MODPROBE_BLACKLIST //config: bool "Blacklist support" -//config: default n -//config: depends on MODPROBE +//config: default y +//config: depends on MODPROBE && !MODPROBE_SMALL //config: select PLATFORM_LINUX //config: help //config: Say 'y' here to enable support for the 'blacklist' command in @@ -28,9 +27,11 @@ //config: hardware autodetection scripts to load modules like evdev, frame //config: buffer drivers etc. -//applet:IF_MODPROBE(APPLET(modprobe, BB_DIR_SBIN, BB_SUID_DROP)) +//applet:IF_MODPROBE(IF_NOT_MODPROBE_SMALL(APPLET(modprobe, BB_DIR_SBIN, BB_SUID_DROP))) +//kbuild:ifneq ($(CONFIG_MODPROBE_SMALL),y) //kbuild:lib-$(CONFIG_MODPROBE) += modprobe.o modutils.o +//kbuild:endif #include "libbb.h" #include "modutils.h" diff --git a/modutils/rmmod.c b/modutils/rmmod.c index e0358838a..4c4d50885 100644 --- a/modutils/rmmod.c +++ b/modutils/rmmod.c @@ -10,14 +10,15 @@ //config:config RMMOD //config: bool "rmmod" //config: default n -//config: depends on !MODPROBE_SMALL //config: select PLATFORM_LINUX //config: help //config: rmmod is used to unload specified modules from the kernel. -//applet:IF_RMMOD(APPLET(rmmod, BB_DIR_SBIN, BB_SUID_DROP)) +//applet:IF_RMMOD(IF_NOT_MODPROBE_SMALL(APPLET(rmmod, BB_DIR_SBIN, BB_SUID_DROP))) +//kbuild:ifneq ($(CONFIG_MODPROBE_SMALL),y) //kbuild:lib-$(CONFIG_RMMOD) += rmmod.o modutils.o +//kbuild:endif //usage:#if !ENABLE_MODPROBE_SMALL //usage:#define rmmod_trivial_usage -- cgit v1.2.3-55-g6feb From add927e3d16414738ce46c28bb9d83e173848740 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Mon, 26 Dec 2016 20:07:59 +0100 Subject: modutils: remove special handling of uClibc Commit 3a45b87ac36f (modutils: support finit_module syscall) introduced macro finit_module. But it is not defined for uClibc. The compilation for busybox fails for MIPS with: With uClibc, we get following build errors: modutils/lib.a(modutils.o): In function `bb_init_module': modutils.c:(.text.bb_init_module+0x94): undefined reference to `finit_module' modutils.c:(.text.bb_init_module+0xa0): undefined reference to `finit_module' We can just use syscall() without any need for the uClibc wrappers. Newer versions of uClibc-ng (>1.0.20) will remove the module syscall wrappers. Found via Buildroot autobuilders: http://autobuild.buildroot.net/results/556/55655daef23788fb3967f801ec8b79e9bed7122b/build-end.log function old new delta bb_delete_module 26 32 +6 bb_init_module 90 95 +5 delete_module 37 - -37 init_module 53 - -53 ------------------------------------------------------------------------------ (add/remove: 0/4 grow/shrink: 2/0 up/down: 11/-90) Total: -79 bytes Reported-by: Rahul Bedarkar Signed-off-by: Waldemar Brodkorb Signed-off-by: Denys Vlasenko --- modutils/modprobe-small.c | 4 ++-- modutils/modutils.c | 16 ++++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) (limited to 'modutils/modprobe-small.c') diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c index 652ff4dfa..0fc9ea454 100644 --- a/modutils/modprobe-small.c +++ b/modutils/modprobe-small.c @@ -39,8 +39,8 @@ #include #include -extern int init_module(void *module, unsigned long len, const char *options); -extern int delete_module(const char *module, unsigned flags); +#define init_module(mod, len, opts) syscall(__NR_init_module, mod, len, opts) +#define delete_module(mod, flags) syscall(__NR_delete_module, mod, flags) #ifdef __NR_finit_module # define finit_module(fd, uargs, flags) syscall(__NR_finit_module, fd, uargs, flags) #endif diff --git a/modutils/modutils.c b/modutils/modutils.c index d36caaf68..4204f06fe 100644 --- a/modutils/modutils.c +++ b/modutils/modutils.c @@ -7,17 +7,13 @@ */ #include "modutils.h" -#ifdef __UCLIBC__ -extern int init_module(void *module, unsigned long len, const char *options); -extern int delete_module(const char *module, unsigned int flags); -#else -# include -# define init_module(mod, len, opts) syscall(__NR_init_module, mod, len, opts) -# if defined(__NR_finit_module) -# define finit_module(fd, uargs, flags) syscall(__NR_finit_module, fd, uargs, flags) -# endif -# define delete_module(mod, flags) syscall(__NR_delete_module, mod, flags) +#include + +#define init_module(mod, len, opts) syscall(__NR_init_module, mod, len, opts) +#if defined(__NR_finit_module) +# define finit_module(fd, uargs, flags) syscall(__NR_finit_module, fd, uargs, flags) #endif +#define delete_module(mod, flags) syscall(__NR_delete_module, mod, flags) static module_entry *helper_get_module(module_db *db, const char *module, int create) { -- cgit v1.2.3-55-g6feb