aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-12-23 15:12:27 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2016-12-23 15:13:16 +0100
commita1cd0d9849946e0627484ec6b6435837c853a113 (patch)
tree23c7c643bd0af2859beff3876bdbaa20953bdb5f
parentce3a98a222a2191ef4a22e90c49a51dfa7279e07 (diff)
downloadbusybox-w32-a1cd0d9849946e0627484ec6b6435837c853a113.tar.gz
busybox-w32-a1cd0d9849946e0627484ec6b6435837c853a113.tar.bz2
busybox-w32-a1cd0d9849946e0627484ec6b6435837c853a113.zip
modprobe-small: make applets individually selectable
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rwxr-xr-xinclude/applets.h.sh3
-rwxr-xr-xmake_single_applets.sh7
-rw-r--r--modutils/depmod.c7
-rw-r--r--modutils/insmod.c5
-rw-r--r--modutils/lsmod.c11
-rw-r--r--modutils/modprobe-small.c24
-rw-r--r--modutils/modprobe.c11
-rw-r--r--modutils/rmmod.c5
8 files changed, 41 insertions, 32 deletions
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 @@
4# enabling it. Run it after applets.h is generated. 4# enabling it. Run it after applets.h is generated.
5 5
6# CONFIG_applet names 6# CONFIG_applet names
7grep ^IF_ applets.h | grep -v IF_FEATURE_ | sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \ 7grep ^IF_ applets.h | grep -v ^IF_FEATURE_ | sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \
8| grep -v MODPROBE_SMALL \
9| sort | uniq \ 8| sort | uniq \
10>applets_APP1 9>applets_APP1
11 10
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="`
14grep ^IF_ include/applets.h \ 14grep ^IF_ include/applets.h \
15| grep -v ^IF_FEATURE_ \ 15| grep -v ^IF_FEATURE_ \
16| sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \ 16| sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \
17| grep -v ^MODPROBE_SMALL \
18| sort | uniq 17| sort | uniq
19`" 18`"
20 19
@@ -46,6 +45,11 @@ for app in $apps; do
46 : $((fail++)) 45 : $((fail++))
47 echo "Build error for ${app}" 46 echo "Build error for ${app}"
48 mv .config busybox_config_${app} 47 mv .config busybox_config_${app}
48 elif ! grep -q '^#define NUM_APPLETS 1$' include/NUM_APPLETS.h; then
49 mv busybox busybox_${app}
50 : $((fail++))
51 echo "NUM_APPLETS != 1 for ${app}: `cat include/NUM_APPLETS.h`"
52 mv .config busybox_config_${app}
49 else 53 else
50 mv busybox busybox_${app} 54 mv busybox busybox_${app}
51 rm busybox_make_${app}.log 55 rm busybox_make_${app}.log
@@ -53,5 +57,6 @@ for app in $apps; do
53 mv .config.SV .config 57 mv .config.SV .config
54 #exit 58 #exit
55done 59done
60touch .config # or else next "make" can be confused
56echo "Failures: $fail" 61echo "Failures: $fail"
57test $fail = 0 # set exitcode 62test $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 @@
9 */ 9 */
10//config:config DEPMOD 10//config:config DEPMOD
11//config: bool "depmod" 11//config: bool "depmod"
12//config: default n 12//config: default y
13//config: depends on !MODPROBE_SMALL
14//config: select PLATFORM_LINUX 13//config: select PLATFORM_LINUX
15//config: help 14//config: help
16//config: depmod generates modules.dep (and potentially modules.alias 15//config: depmod generates modules.dep (and potentially modules.alias
17//config: and modules.symbols) that contain dependency information 16//config: and modules.symbols) that contain dependency information
18//config: for modprobe. 17//config: for modprobe.
19 18
20//applet:IF_DEPMOD(APPLET(depmod, BB_DIR_SBIN, BB_SUID_DROP)) 19//kbuild:ifneq ($(CONFIG_MODPROBE_SMALL),y)
20//applet:IF_DEPMOD(IF_NOT_MODPROBE_SMALL(APPLET(depmod, BB_DIR_SBIN, BB_SUID_DROP)))
21//kbuild:endif
21 22
22//kbuild:lib-$(CONFIG_DEPMOD) += depmod.o modutils.o 23//kbuild:lib-$(CONFIG_DEPMOD) += depmod.o modutils.o
23 24
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 @@
9//config:config INSMOD 9//config:config INSMOD
10//config: bool "insmod" 10//config: bool "insmod"
11//config: default n 11//config: default n
12//config: depends on !MODPROBE_SMALL
13//config: select PLATFORM_LINUX 12//config: select PLATFORM_LINUX
14//config: help 13//config: help
15//config: insmod is used to load specified modules in the running kernel. 14//config: insmod is used to load specified modules in the running kernel.
16 15
17//applet:IF_INSMOD(APPLET(insmod, BB_DIR_SBIN, BB_SUID_DROP)) 16//applet:IF_INSMOD(IF_NOT_MODPROBE_SMALL(APPLET(insmod, BB_DIR_SBIN, BB_SUID_DROP)))
18 17
18//kbuild:ifneq ($(CONFIG_MODPROBE_SMALL),y)
19//kbuild:lib-$(CONFIG_INSMOD) += insmod.o modutils.o 19//kbuild:lib-$(CONFIG_INSMOD) += insmod.o modutils.o
20//kbuild:endif
20 21
21#include "libbb.h" 22#include "libbb.h"
22#include "modutils.h" 23#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 @@
9 */ 9 */
10//config:config LSMOD 10//config:config LSMOD
11//config: bool "lsmod" 11//config: bool "lsmod"
12//config: default n 12//config: default y
13//config: depends on !MODPROBE_SMALL
14//config: select PLATFORM_LINUX 13//config: select PLATFORM_LINUX
15//config: help 14//config: help
16//config: lsmod is used to display a list of loaded modules. 15//config: lsmod is used to display a list of loaded modules.
17//config: 16//config:
18//config:config FEATURE_LSMOD_PRETTY_2_6_OUTPUT 17//config:config FEATURE_LSMOD_PRETTY_2_6_OUTPUT
19//config: bool "Pretty output" 18//config: bool "Pretty output"
20//config: default n 19//config: default y
21//config: depends on LSMOD 20//config: depends on LSMOD && !MODPROBE_SMALL
22//config: select PLATFORM_LINUX 21//config: select PLATFORM_LINUX
23//config: help 22//config: help
24//config: This option makes output format of lsmod adjusted to 23//config: This option makes output format of lsmod adjusted to
25//config: the format of module-init-tools for Linux kernel 2.6. 24//config: the format of module-init-tools for Linux kernel 2.6.
26//config: Increases size somewhat. 25//config: Increases size somewhat.
27 26
28//applet:IF_LSMOD(APPLET(lsmod, BB_DIR_SBIN, BB_SUID_DROP)) 27//applet:IF_LSMOD(IF_NOT_MODPROBE_SMALL(APPLET(lsmod, BB_DIR_SBIN, BB_SUID_DROP)))
29 28
29//kbuild:ifneq ($(CONFIG_MODPROBE_SMALL),y)
30//kbuild:lib-$(CONFIG_LSMOD) += lsmod.o modutils.o 30//kbuild:lib-$(CONFIG_LSMOD) += lsmod.o modutils.o
31//kbuild:endif
31 32
32//usage:#if !ENABLE_MODPROBE_SMALL 33//usage:#if !ENABLE_MODPROBE_SMALL
33//usage:#define lsmod_trivial_usage 34//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 @@
25//config: help 25//config: help
26//config: Check if the module is already loaded. 26//config: Check if the module is already loaded.
27 27
28//applet:IF_MODPROBE_SMALL(APPLET(modprobe, BB_DIR_SBIN, BB_SUID_DROP)) 28//applet:IF_MODPROBE(IF_MODPROBE_SMALL(APPLET(modprobe, BB_DIR_SBIN, BB_SUID_DROP)))
29//applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(depmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, depmod)) 29//applet:IF_DEPMOD(IF_MODPROBE_SMALL(APPLET_ODDNAME(depmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, depmod)))
30//applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(insmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, insmod)) 30//applet:IF_INSMOD(IF_MODPROBE_SMALL(APPLET_ODDNAME(insmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, insmod)))
31//applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(lsmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, lsmod)) 31//applet:IF_LSMOD(IF_MODPROBE_SMALL(APPLET_ODDNAME(lsmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, lsmod)))
32//applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(rmmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, rmmod)) 32//applet:IF_RMMOD(IF_MODPROBE_SMALL(APPLET_ODDNAME(rmmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, rmmod)))
33 33
34//kbuild:lib-$(CONFIG_MODPROBE_SMALL) += modprobe-small.o 34//kbuild:lib-$(CONFIG_MODPROBE_SMALL) += modprobe-small.o
35 35
@@ -930,7 +930,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
930 IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(char *options;) 930 IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(char *options;)
931 931
932 /* are we lsmod? -> just dump /proc/modules */ 932 /* are we lsmod? -> just dump /proc/modules */
933 if ('l' == applet0) { 933 if (ENABLE_LSMOD && 'l' == applet0) {
934 xprint_and_close_file(xfopen_for_read("/proc/modules")); 934 xprint_and_close_file(xfopen_for_read("/proc/modules"));
935 return EXIT_SUCCESS; 935 return EXIT_SUCCESS;
936 } 936 }
@@ -940,14 +940,14 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
940 /* Prevent ugly corner cases with no modules at all */ 940 /* Prevent ugly corner cases with no modules at all */
941 modinfo = xzalloc(sizeof(modinfo[0])); 941 modinfo = xzalloc(sizeof(modinfo[0]));
942 942
943 if ('i' != applet0) { /* not insmod */ 943 if (!ENABLE_INSMOD || 'i' != applet0) { /* not insmod */
944 /* Goto modules directory */ 944 /* Goto modules directory */
945 xchdir(CONFIG_DEFAULT_MODULES_DIR); 945 xchdir(CONFIG_DEFAULT_MODULES_DIR);
946 } 946 }
947 uname(&uts); /* never fails */ 947 uname(&uts); /* never fails */
948 948
949 /* depmod? */ 949 /* depmod? */
950 if ('d' == applet0) { 950 if (ENABLE_DEPMOD && 'd' == applet0) {
951 /* Supported: 951 /* Supported:
952 * -n: print result to stdout 952 * -n: print result to stdout
953 * -a: process all modules (default) 953 * -a: process all modules (default)
@@ -986,11 +986,11 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
986 argv += optind; 986 argv += optind;
987 987
988 /* are we rmmod? -> simulate modprobe -r */ 988 /* are we rmmod? -> simulate modprobe -r */
989 if ('r' == applet0) { 989 if (ENABLE_RMMOD && 'r' == applet0) {
990 option_mask32 |= OPT_r; 990 option_mask32 |= OPT_r;
991 } 991 }
992 992
993 if ('i' != applet0) { /* not insmod */ 993 if (!ENABLE_INSMOD || 'i' != applet0) { /* not insmod */
994 /* Goto $VERSION directory */ 994 /* Goto $VERSION directory */
995 xchdir(uts.release); 995 xchdir(uts.release);
996 } 996 }
@@ -1014,7 +1014,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
1014 argv[1] = NULL; 1014 argv[1] = NULL;
1015#endif 1015#endif
1016 1016
1017 if ('i' == applet0) { /* insmod */ 1017 if (ENABLE_INSMOD && 'i' == applet0) { /* insmod */
1018 size_t len; 1018 size_t len;
1019 void *map; 1019 void *map;
1020 1020
@@ -1034,7 +1034,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
1034 } 1034 }
1035 1035
1036 /* Try to load modprobe.dep.bb */ 1036 /* Try to load modprobe.dep.bb */
1037 if ('r' != applet0) { /* not rmmod */ 1037 if (!ENABLE_RMMOD || 'r' != applet0) { /* not rmmod */
1038 load_dep_bb(); 1038 load_dep_bb();
1039 } 1039 }
1040 1040
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 @@
9 */ 9 */
10//config:config MODPROBE 10//config:config MODPROBE
11//config: bool "modprobe" 11//config: bool "modprobe"
12//config: default n 12//config: default y
13//config: depends on !MODPROBE_SMALL
14//config: select PLATFORM_LINUX 13//config: select PLATFORM_LINUX
15//config: help 14//config: help
16//config: Handle the loading of modules, and their dependencies on a high 15//config: Handle the loading of modules, and their dependencies on a high
@@ -18,8 +17,8 @@
18//config: 17//config:
19//config:config FEATURE_MODPROBE_BLACKLIST 18//config:config FEATURE_MODPROBE_BLACKLIST
20//config: bool "Blacklist support" 19//config: bool "Blacklist support"
21//config: default n 20//config: default y
22//config: depends on MODPROBE 21//config: depends on MODPROBE && !MODPROBE_SMALL
23//config: select PLATFORM_LINUX 22//config: select PLATFORM_LINUX
24//config: help 23//config: help
25//config: Say 'y' here to enable support for the 'blacklist' command in 24//config: Say 'y' here to enable support for the 'blacklist' command in
@@ -28,9 +27,11 @@
28//config: hardware autodetection scripts to load modules like evdev, frame 27//config: hardware autodetection scripts to load modules like evdev, frame
29//config: buffer drivers etc. 28//config: buffer drivers etc.
30 29
31//applet:IF_MODPROBE(APPLET(modprobe, BB_DIR_SBIN, BB_SUID_DROP)) 30//applet:IF_MODPROBE(IF_NOT_MODPROBE_SMALL(APPLET(modprobe, BB_DIR_SBIN, BB_SUID_DROP)))
32 31
32//kbuild:ifneq ($(CONFIG_MODPROBE_SMALL),y)
33//kbuild:lib-$(CONFIG_MODPROBE) += modprobe.o modutils.o 33//kbuild:lib-$(CONFIG_MODPROBE) += modprobe.o modutils.o
34//kbuild:endif
34 35
35#include "libbb.h" 36#include "libbb.h"
36#include "modutils.h" 37#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 @@
10//config:config RMMOD 10//config:config RMMOD
11//config: bool "rmmod" 11//config: bool "rmmod"
12//config: default n 12//config: default n
13//config: depends on !MODPROBE_SMALL
14//config: select PLATFORM_LINUX 13//config: select PLATFORM_LINUX
15//config: help 14//config: help
16//config: rmmod is used to unload specified modules from the kernel. 15//config: rmmod is used to unload specified modules from the kernel.
17 16
18//applet:IF_RMMOD(APPLET(rmmod, BB_DIR_SBIN, BB_SUID_DROP)) 17//applet:IF_RMMOD(IF_NOT_MODPROBE_SMALL(APPLET(rmmod, BB_DIR_SBIN, BB_SUID_DROP)))
19 18
19//kbuild:ifneq ($(CONFIG_MODPROBE_SMALL),y)
20//kbuild:lib-$(CONFIG_RMMOD) += rmmod.o modutils.o 20//kbuild:lib-$(CONFIG_RMMOD) += rmmod.o modutils.o
21//kbuild:endif
21 22
22//usage:#if !ENABLE_MODPROBE_SMALL 23//usage:#if !ENABLE_MODPROBE_SMALL
23//usage:#define rmmod_trivial_usage 24//usage:#define rmmod_trivial_usage