modprobe-small: make applets individually selectable

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2016-12-23 15:12:27 +01:00
parent ce3a98a222
commit a1cd0d9849
8 changed files with 41 additions and 32 deletions

View File

@ -4,8 +4,7 @@
# enabling it. Run it after applets.h is generated. # enabling it. Run it after applets.h is generated.
# CONFIG_applet names # CONFIG_applet names
grep ^IF_ applets.h | grep -v IF_FEATURE_ | sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \ grep ^IF_ applets.h | grep -v ^IF_FEATURE_ | sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \
| grep -v MODPROBE_SMALL \
| sort | uniq \ | sort | uniq \
>applets_APP1 >applets_APP1

View File

@ -14,7 +14,6 @@ apps="`
grep ^IF_ include/applets.h \ grep ^IF_ include/applets.h \
| grep -v ^IF_FEATURE_ \ | grep -v ^IF_FEATURE_ \
| sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \ | sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \
| grep -v ^MODPROBE_SMALL \
| sort | uniq | sort | uniq
`" `"
@ -46,6 +45,11 @@ for app in $apps; do
: $((fail++)) : $((fail++))
echo "Build error for ${app}" echo "Build error for ${app}"
mv .config busybox_config_${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 else
mv busybox busybox_${app} mv busybox busybox_${app}
rm busybox_make_${app}.log rm busybox_make_${app}.log
@ -53,5 +57,6 @@ for app in $apps; do
mv .config.SV .config mv .config.SV .config
#exit #exit
done done
touch .config # or else next "make" can be confused
echo "Failures: $fail" echo "Failures: $fail"
test $fail = 0 # set exitcode test $fail = 0 # set exitcode

View File

@ -9,15 +9,16 @@
*/ */
//config:config DEPMOD //config:config DEPMOD
//config: bool "depmod" //config: bool "depmod"
//config: default n //config: default y
//config: depends on !MODPROBE_SMALL
//config: select PLATFORM_LINUX //config: select PLATFORM_LINUX
//config: help //config: help
//config: depmod generates modules.dep (and potentially modules.alias //config: depmod generates modules.dep (and potentially modules.alias
//config: and modules.symbols) that contain dependency information //config: and modules.symbols) that contain dependency information
//config: for modprobe. //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 //kbuild:lib-$(CONFIG_DEPMOD) += depmod.o modutils.o

View File

@ -9,14 +9,15 @@
//config:config INSMOD //config:config INSMOD
//config: bool "insmod" //config: bool "insmod"
//config: default n //config: default n
//config: depends on !MODPROBE_SMALL
//config: select PLATFORM_LINUX //config: select PLATFORM_LINUX
//config: help //config: help
//config: insmod is used to load specified modules in the running kernel. //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:lib-$(CONFIG_INSMOD) += insmod.o modutils.o
//kbuild:endif
#include "libbb.h" #include "libbb.h"
#include "modutils.h" #include "modutils.h"

View File

@ -9,25 +9,26 @@
*/ */
//config:config LSMOD //config:config LSMOD
//config: bool "lsmod" //config: bool "lsmod"
//config: default n //config: default y
//config: depends on !MODPROBE_SMALL
//config: select PLATFORM_LINUX //config: select PLATFORM_LINUX
//config: help //config: help
//config: lsmod is used to display a list of loaded modules. //config: lsmod is used to display a list of loaded modules.
//config: //config:
//config:config FEATURE_LSMOD_PRETTY_2_6_OUTPUT //config:config FEATURE_LSMOD_PRETTY_2_6_OUTPUT
//config: bool "Pretty output" //config: bool "Pretty output"
//config: default n //config: default y
//config: depends on LSMOD //config: depends on LSMOD && !MODPROBE_SMALL
//config: select PLATFORM_LINUX //config: select PLATFORM_LINUX
//config: help //config: help
//config: This option makes output format of lsmod adjusted to //config: This option makes output format of lsmod adjusted to
//config: the format of module-init-tools for Linux kernel 2.6. //config: the format of module-init-tools for Linux kernel 2.6.
//config: Increases size somewhat. //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:lib-$(CONFIG_LSMOD) += lsmod.o modutils.o
//kbuild:endif
//usage:#if !ENABLE_MODPROBE_SMALL //usage:#if !ENABLE_MODPROBE_SMALL
//usage:#define lsmod_trivial_usage //usage:#define lsmod_trivial_usage

View File

@ -25,11 +25,11 @@
//config: help //config: help
//config: Check if the module is already loaded. //config: Check if the module is already loaded.
//applet:IF_MODPROBE_SMALL(APPLET(modprobe, BB_DIR_SBIN, BB_SUID_DROP)) //applet:IF_MODPROBE(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_DEPMOD(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_INSMOD(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_LSMOD(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_RMMOD(IF_MODPROBE_SMALL(APPLET_ODDNAME(rmmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, rmmod)))
//kbuild:lib-$(CONFIG_MODPROBE_SMALL) += modprobe-small.o //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;) IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(char *options;)
/* are we lsmod? -> just dump /proc/modules */ /* are we lsmod? -> just dump /proc/modules */
if ('l' == applet0) { if (ENABLE_LSMOD && 'l' == applet0) {
xprint_and_close_file(xfopen_for_read("/proc/modules")); xprint_and_close_file(xfopen_for_read("/proc/modules"));
return EXIT_SUCCESS; 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 */ /* Prevent ugly corner cases with no modules at all */
modinfo = xzalloc(sizeof(modinfo[0])); modinfo = xzalloc(sizeof(modinfo[0]));
if ('i' != applet0) { /* not insmod */ if (!ENABLE_INSMOD || 'i' != applet0) { /* not insmod */
/* Goto modules directory */ /* Goto modules directory */
xchdir(CONFIG_DEFAULT_MODULES_DIR); xchdir(CONFIG_DEFAULT_MODULES_DIR);
} }
uname(&uts); /* never fails */ uname(&uts); /* never fails */
/* depmod? */ /* depmod? */
if ('d' == applet0) { if (ENABLE_DEPMOD && 'd' == applet0) {
/* Supported: /* Supported:
* -n: print result to stdout * -n: print result to stdout
* -a: process all modules (default) * -a: process all modules (default)
@ -986,11 +986,11 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
argv += optind; argv += optind;
/* are we rmmod? -> simulate modprobe -r */ /* are we rmmod? -> simulate modprobe -r */
if ('r' == applet0) { if (ENABLE_RMMOD && 'r' == applet0) {
option_mask32 |= OPT_r; option_mask32 |= OPT_r;
} }
if ('i' != applet0) { /* not insmod */ if (!ENABLE_INSMOD || 'i' != applet0) { /* not insmod */
/* Goto $VERSION directory */ /* Goto $VERSION directory */
xchdir(uts.release); xchdir(uts.release);
} }
@ -1014,7 +1014,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
argv[1] = NULL; argv[1] = NULL;
#endif #endif
if ('i' == applet0) { /* insmod */ if (ENABLE_INSMOD && 'i' == applet0) { /* insmod */
size_t len; size_t len;
void *map; void *map;
@ -1034,7 +1034,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
} }
/* Try to load modprobe.dep.bb */ /* Try to load modprobe.dep.bb */
if ('r' != applet0) { /* not rmmod */ if (!ENABLE_RMMOD || 'r' != applet0) { /* not rmmod */
load_dep_bb(); load_dep_bb();
} }

View File

@ -9,8 +9,7 @@
*/ */
//config:config MODPROBE //config:config MODPROBE
//config: bool "modprobe" //config: bool "modprobe"
//config: default n //config: default y
//config: depends on !MODPROBE_SMALL
//config: select PLATFORM_LINUX //config: select PLATFORM_LINUX
//config: help //config: help
//config: Handle the loading of modules, and their dependencies on a high //config: Handle the loading of modules, and their dependencies on a high
@ -18,8 +17,8 @@
//config: //config:
//config:config FEATURE_MODPROBE_BLACKLIST //config:config FEATURE_MODPROBE_BLACKLIST
//config: bool "Blacklist support" //config: bool "Blacklist support"
//config: default n //config: default y
//config: depends on MODPROBE //config: depends on MODPROBE && !MODPROBE_SMALL
//config: select PLATFORM_LINUX //config: select PLATFORM_LINUX
//config: help //config: help
//config: Say 'y' here to enable support for the 'blacklist' command in //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: hardware autodetection scripts to load modules like evdev, frame
//config: buffer drivers etc. //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:lib-$(CONFIG_MODPROBE) += modprobe.o modutils.o
//kbuild:endif
#include "libbb.h" #include "libbb.h"
#include "modutils.h" #include "modutils.h"

View File

@ -10,14 +10,15 @@
//config:config RMMOD //config:config RMMOD
//config: bool "rmmod" //config: bool "rmmod"
//config: default n //config: default n
//config: depends on !MODPROBE_SMALL
//config: select PLATFORM_LINUX //config: select PLATFORM_LINUX
//config: help //config: help
//config: rmmod is used to unload specified modules from the kernel. //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:lib-$(CONFIG_RMMOD) += rmmod.o modutils.o
//kbuild:endif
//usage:#if !ENABLE_MODPROBE_SMALL //usage:#if !ENABLE_MODPROBE_SMALL
//usage:#define rmmod_trivial_usage //usage:#define rmmod_trivial_usage