aboutsummaryrefslogtreecommitdiff
path: root/modutils/modprobe-small.c
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/modprobe-small.c
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/modprobe-small.c')
-rw-r--r--modutils/modprobe-small.c62
1 files changed, 17 insertions, 45 deletions
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