diff options
Diffstat (limited to 'modutils')
| -rw-r--r-- | modutils/Config.src | 31 | ||||
| -rw-r--r-- | modutils/depmod.c | 7 | ||||
| -rw-r--r-- | modutils/insmod.c | 7 | ||||
| -rw-r--r-- | modutils/lsmod.c | 11 | ||||
| -rw-r--r-- | modutils/modprobe-small.c | 58 | ||||
| -rw-r--r-- | modutils/modprobe.c | 11 | ||||
| -rw-r--r-- | modutils/rmmod.c | 7 |
7 files changed, 70 insertions, 62 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 | ||
| 6 | menu "Linux Module Utilities" | 6 | menu "Linux Module Utilities" |
| 7 | 7 | ||
| 8 | config 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 | |||
| 8 | INSERT | 39 | INSERT |
| 9 | 40 | ||
| 10 | comment "Options common to multiple modutils" | 41 | comment "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..652ff4dfa 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 | ||
| @@ -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/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 |
