aboutsummaryrefslogtreecommitdiff
path: root/modutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2021-03-24 11:55:30 +0000
committerRon Yorston <rmy@pobox.com>2021-03-24 12:43:15 +0000
commit355a7a6c1e9626b7afe8758a6095f3cf275c52e1 (patch)
tree6dab679c15b049cab97212e0b43077132eec1fbe /modutils
parent71ecc8033e6989996057b32577e71148fd544596 (diff)
parent889425812b5cda8b3394d73253cbde7355fb1115 (diff)
downloadbusybox-w32-w32_1_26_2.tar.gz
busybox-w32-w32_1_26_2.tar.bz2
busybox-w32-w32_1_26_2.zip
Merge tag '1_26_2' into w32_1_26_2w32_1_26_2
Diffstat (limited to 'modutils')
-rw-r--r--modutils/Config.src31
-rw-r--r--modutils/depmod.c7
-rw-r--r--modutils/insmod.c7
-rw-r--r--modutils/lsmod.c11
-rw-r--r--modutils/modprobe-small.c62
-rw-r--r--modutils/modprobe.c11
-rw-r--r--modutils/modutils.c16
-rw-r--r--modutils/rmmod.c7
8 files changed, 78 insertions, 74 deletions
diff --git a/modutils/Config.src b/modutils/Config.src
index 4227f356a..84ff34a08 100644
--- a/modutils/Config.src
+++ b/modutils/Config.src
@@ -5,6 +5,37 @@
5 5
6menu "Linux Module Utilities" 6menu "Linux Module Utilities"
7 7
8config MODPROBE_SMALL
9 bool "Simplified modutils"
10 default y
11 select PLATFORM_LINUX
12 help
13 Simplified modutils.
14
15 With this option modprobe does not require modules.dep file
16 and does not use /etc/modules.conf file.
17 It scans module files in /lib/modules/`uname -r` and
18 determines dependencies and module alias names on the fly.
19 This may make module loading slower, most notably
20 when one needs to load module by alias (this requires
21 scanning through module _bodies_).
22
23 At the first attempt to load a module by alias modprobe
24 will try to generate modules.dep.bb file in order to speed up
25 future loads by alias. Failure to do so (read-only /lib/modules,
26 etc) is not reported, and future modprobes will be slow too.
27
28 NB: modules.dep.bb file format is not compatible
29 with modules.dep file as created/used by standard module tools.
30
31 Additional module parameters can be stored in
32 /etc/modules/$module_name files.
33
34 Apart from modprobe, other utilities are also provided:
35 - insmod is an alias to modprobe
36 - rmmod is an alias to modprobe -r
37 - depmod generates modules.dep.bb
38
8INSERT 39INSERT
9 40
10comment "Options common to multiple modutils" 41comment "Options common to multiple modutils"
diff --git a/modutils/depmod.c b/modutils/depmod.c
index b9347027e..b7965ebd2 100644
--- a/modutils/depmod.c
+++ b/modutils/depmod.c
@@ -9,17 +9,18 @@
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//applet:IF_DEPMOD(IF_NOT_MODPROBE_SMALL(APPLET(depmod, BB_DIR_SBIN, BB_SUID_DROP)))
21 20
21//kbuild:ifneq ($(CONFIG_MODPROBE_SMALL),y)
22//kbuild:lib-$(CONFIG_DEPMOD) += depmod.o modutils.o 22//kbuild:lib-$(CONFIG_DEPMOD) += depmod.o modutils.o
23//kbuild:endif
23 24
24#include "libbb.h" 25#include "libbb.h"
25#include "modutils.h" 26#include "modutils.h"
diff --git a/modutils/insmod.c b/modutils/insmod.c
index 2ebf4beb9..f2c70e16f 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -8,15 +8,16 @@
8 */ 8 */
9//config:config INSMOD 9//config:config INSMOD
10//config: bool "insmod" 10//config: bool "insmod"
11//config: default n 11//config: default y
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 51ba42f7a..0fc9ea454 100644
--- a/modutils/modprobe-small.c
+++ b/modutils/modprobe-small.c
@@ -7,37 +7,9 @@
7 * 7 *
8 * Licensed under GPLv2, see file LICENSE in this source tree. 8 * Licensed under GPLv2, see file LICENSE in this source tree.
9 */ 9 */
10//config:config MODPROBE_SMALL 10
11//config: bool "Simplified modutils" 11/* config MODPROBE_SMALL is defined in Config.src to ensure better "make config" order */
12//config: default y 12
13//config: select PLATFORM_LINUX
14//config: help
15//config: Simplified modutils.
16//config:
17//config: With this option modprobe does not require modules.dep file
18//config: and does not use /etc/modules.conf file.
19//config: It scans module files in /lib/modules/`uname -r` and
20//config: determines dependencies and module alias names on the fly.
21//config: This may make module loading slower, most notably
22//config: when one needs to load module by alias (this requires
23//config: scanning through module _bodies_).
24//config:
25//config: At the first attempt to load a module by alias modprobe
26//config: will try to generate modules.dep.bb file in order to speed up
27//config: future loads by alias. Failure to do so (read-only /lib/modules,
28//config: etc) is not reported, and future modprobes will be slow too.
29//config:
30//config: NB: modules.dep.bb file format is not compatible
31//config: with modules.dep file as created/used by standard module tools.
32//config:
33//config: Additional module parameters can be stored in
34//config: /etc/modules/$module_name files.
35//config:
36//config: Apart from modprobe, other utilities are also provided:
37//config: - insmod is an alias to modprobe
38//config: - rmmod is an alias to modprobe -r
39//config: - depmod generates modules.dep.bb
40//config:
41//config:config FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE 13//config:config FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE
42//config: bool "Accept module options on modprobe command line" 14//config: bool "Accept module options on modprobe command line"
43//config: default y 15//config: default y
@@ -53,11 +25,11 @@
53//config: help 25//config: help
54//config: Check if the module is already loaded. 26//config: Check if the module is already loaded.
55 27
56//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)))
57//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)))
58//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)))
59//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)))
60//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)))
61 33
62//kbuild:lib-$(CONFIG_MODPROBE_SMALL) += modprobe-small.o 34//kbuild:lib-$(CONFIG_MODPROBE_SMALL) += modprobe-small.o
63 35
@@ -67,8 +39,8 @@
67#include <fnmatch.h> 39#include <fnmatch.h>
68#include <sys/syscall.h> 40#include <sys/syscall.h>
69 41
70extern int init_module(void *module, unsigned long len, const char *options); 42#define init_module(mod, len, opts) syscall(__NR_init_module, mod, len, opts)
71extern int delete_module(const char *module, unsigned flags); 43#define delete_module(mod, flags) syscall(__NR_delete_module, mod, flags)
72#ifdef __NR_finit_module 44#ifdef __NR_finit_module
73# define finit_module(fd, uargs, flags) syscall(__NR_finit_module, fd, uargs, flags) 45# define finit_module(fd, uargs, flags) syscall(__NR_finit_module, fd, uargs, flags)
74#endif 46#endif
@@ -958,7 +930,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
958 IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(char *options;) 930 IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(char *options;)
959 931
960 /* are we lsmod? -> just dump /proc/modules */ 932 /* are we lsmod? -> just dump /proc/modules */
961 if ('l' == applet0) { 933 if (ENABLE_LSMOD && 'l' == applet0) {
962 xprint_and_close_file(xfopen_for_read("/proc/modules")); 934 xprint_and_close_file(xfopen_for_read("/proc/modules"));
963 return EXIT_SUCCESS; 935 return EXIT_SUCCESS;
964 } 936 }
@@ -968,14 +940,14 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
968 /* Prevent ugly corner cases with no modules at all */ 940 /* Prevent ugly corner cases with no modules at all */
969 modinfo = xzalloc(sizeof(modinfo[0])); 941 modinfo = xzalloc(sizeof(modinfo[0]));
970 942
971 if ('i' != applet0) { /* not insmod */ 943 if (!ENABLE_INSMOD || 'i' != applet0) { /* not insmod */
972 /* Goto modules directory */ 944 /* Goto modules directory */
973 xchdir(CONFIG_DEFAULT_MODULES_DIR); 945 xchdir(CONFIG_DEFAULT_MODULES_DIR);
974 } 946 }
975 uname(&uts); /* never fails */ 947 uname(&uts); /* never fails */
976 948
977 /* depmod? */ 949 /* depmod? */
978 if ('d' == applet0) { 950 if (ENABLE_DEPMOD && 'd' == applet0) {
979 /* Supported: 951 /* Supported:
980 * -n: print result to stdout 952 * -n: print result to stdout
981 * -a: process all modules (default) 953 * -a: process all modules (default)
@@ -1014,11 +986,11 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
1014 argv += optind; 986 argv += optind;
1015 987
1016 /* are we rmmod? -> simulate modprobe -r */ 988 /* are we rmmod? -> simulate modprobe -r */
1017 if ('r' == applet0) { 989 if (ENABLE_RMMOD && 'r' == applet0) {
1018 option_mask32 |= OPT_r; 990 option_mask32 |= OPT_r;
1019 } 991 }
1020 992
1021 if ('i' != applet0) { /* not insmod */ 993 if (!ENABLE_INSMOD || 'i' != applet0) { /* not insmod */
1022 /* Goto $VERSION directory */ 994 /* Goto $VERSION directory */
1023 xchdir(uts.release); 995 xchdir(uts.release);
1024 } 996 }
@@ -1042,7 +1014,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
1042 argv[1] = NULL; 1014 argv[1] = NULL;
1043#endif 1015#endif
1044 1016
1045 if ('i' == applet0) { /* insmod */ 1017 if (ENABLE_INSMOD && 'i' == applet0) { /* insmod */
1046 size_t len; 1018 size_t len;
1047 void *map; 1019 void *map;
1048 1020
@@ -1062,7 +1034,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
1062 } 1034 }
1063 1035
1064 /* Try to load modprobe.dep.bb */ 1036 /* Try to load modprobe.dep.bb */
1065 if ('r' != applet0) { /* not rmmod */ 1037 if (!ENABLE_RMMOD || 'r' != applet0) { /* not rmmod */
1066 load_dep_bb(); 1038 load_dep_bb();
1067 } 1039 }
1068 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/modutils.c b/modutils/modutils.c
index d36caaf68..4204f06fe 100644
--- a/modutils/modutils.c
+++ b/modutils/modutils.c
@@ -7,17 +7,13 @@
7 */ 7 */
8#include "modutils.h" 8#include "modutils.h"
9 9
10#ifdef __UCLIBC__ 10#include <sys/syscall.h>
11extern int init_module(void *module, unsigned long len, const char *options); 11
12extern int delete_module(const char *module, unsigned int flags); 12#define init_module(mod, len, opts) syscall(__NR_init_module, mod, len, opts)
13#else 13#if defined(__NR_finit_module)
14# include <sys/syscall.h> 14# define finit_module(fd, uargs, flags) syscall(__NR_finit_module, fd, uargs, flags)
15# define init_module(mod, len, opts) syscall(__NR_init_module, mod, len, opts)
16# if defined(__NR_finit_module)
17# define finit_module(fd, uargs, flags) syscall(__NR_finit_module, fd, uargs, flags)
18# endif
19# define delete_module(mod, flags) syscall(__NR_delete_module, mod, flags)
20#endif 15#endif
16#define delete_module(mod, flags) syscall(__NR_delete_module, mod, flags)
21 17
22static module_entry *helper_get_module(module_db *db, const char *module, int create) 18static module_entry *helper_get_module(module_db *db, const char *module, int create)
23{ 19{
diff --git a/modutils/rmmod.c b/modutils/rmmod.c
index e0358838a..527696f63 100644
--- a/modutils/rmmod.c
+++ b/modutils/rmmod.c
@@ -9,15 +9,16 @@
9 */ 9 */
10//config:config RMMOD 10//config:config RMMOD
11//config: bool "rmmod" 11//config: bool "rmmod"
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: 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