aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modutils/Config.src8
-rw-r--r--modutils/insmod.c6
-rw-r--r--modutils/modprobe-small.c23
-rw-r--r--modutils/modprobe.c8
-rw-r--r--modutils/modutils.c2
-rw-r--r--modutils/modutils.h4
6 files changed, 32 insertions, 19 deletions
diff --git a/modutils/Config.src b/modutils/Config.src
index f2448c914..a15cce518 100644
--- a/modutils/Config.src
+++ b/modutils/Config.src
@@ -37,6 +37,14 @@ INSERT
37 37
38comment "Options common to multiple modutils" 38comment "Options common to multiple modutils"
39 39
40config FEATURE_CMDLINE_MODULE_OPTIONS
41 bool "Accept module options on modprobe command line"
42 default y
43 depends on INSMOD || MODPROBE
44 help
45 Allow insmod and modprobe take module options from the applets'
46 command line.
47
40config FEATURE_2_4_MODULES 48config FEATURE_2_4_MODULES
41 bool "Support version 2.2/2.4 Linux kernels" 49 bool "Support version 2.2/2.4 Linux kernels"
42 default n 50 default n
diff --git a/modutils/insmod.c b/modutils/insmod.c
index f2c70e16f..8526979eb 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -27,9 +27,9 @@
27 27
28//usage:#if !ENABLE_MODPROBE_SMALL 28//usage:#if !ENABLE_MODPROBE_SMALL
29//usage:#define insmod_trivial_usage 29//usage:#define insmod_trivial_usage
30//usage: IF_FEATURE_2_4_MODULES("[OPTIONS] MODULE ") 30//usage: IF_FEATURE_2_4_MODULES("[OPTIONS] MODULE")
31//usage: IF_NOT_FEATURE_2_4_MODULES("FILE ") 31//usage: IF_NOT_FEATURE_2_4_MODULES("FILE")
32//usage: "[SYMBOL=VALUE]..." 32//usage: IF_FEATURE_CMDLINE_MODULE_OPTIONS(" [SYMBOL=VALUE]...")
33//usage:#define insmod_full_usage "\n\n" 33//usage:#define insmod_full_usage "\n\n"
34//usage: "Load kernel module" 34//usage: "Load kernel module"
35//usage: IF_FEATURE_2_4_MODULES( "\n" 35//usage: IF_FEATURE_2_4_MODULES( "\n"
diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c
index 325f8376b..04242634b 100644
--- a/modutils/modprobe-small.c
+++ b/modutils/modprobe-small.c
@@ -10,13 +10,6 @@
10 10
11/* config MODPROBE_SMALL is defined in Config.src to ensure better "make config" order */ 11/* config MODPROBE_SMALL is defined in Config.src to ensure better "make config" order */
12 12
13//config:config FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE
14//config: bool "Accept module options on modprobe command line"
15//config: default y
16//config: depends on MODPROBE_SMALL && (INSMOD || MODPROBE)
17//config: help
18//config: Allow insmod and modprobe take module options from command line.
19//config:
20//config:config FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED 13//config:config FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED
21//config: bool "Skip loading of already loaded modules" 14//config: bool "Skip loading of already loaded modules"
22//config: default y 15//config: default y
@@ -690,7 +683,7 @@ static int rmmod(const char *filename)
690 * NB: also called by depmod with bogus name "/", 683 * NB: also called by depmod with bogus name "/",
691 * just in order to force modprobe.dep.bb creation. 684 * just in order to force modprobe.dep.bb creation.
692*/ 685*/
693#if !ENABLE_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE 686#if !ENABLE_FEATURE_CMDLINE_MODULE_OPTIONS
694#define process_module(a,b) process_module(a) 687#define process_module(a,b) process_module(a)
695#define cmdline_options "" 688#define cmdline_options ""
696#endif 689#endif
@@ -735,7 +728,7 @@ static int process_module(char *name, const char *cmdline_options)
735 options = xmalloc_open_read_close(opt_filename, NULL); 728 options = xmalloc_open_read_close(opt_filename, NULL);
736 if (options) 729 if (options)
737 replace(options, '\n', ' '); 730 replace(options, '\n', ' ');
738#if ENABLE_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE 731#if ENABLE_FEATURE_CMDLINE_MODULE_OPTIONS
739 if (cmdline_options) { 732 if (cmdline_options) {
740 /* NB: cmdline_options always have one leading ' ' 733 /* NB: cmdline_options always have one leading ' '
741 * (see main()), we remove it here */ 734 * (see main()), we remove it here */
@@ -910,7 +903,7 @@ The following options are useful for people managing distributions:
910//usage:#define depmod_full_usage "" 903//usage:#define depmod_full_usage ""
911 904
912//usage:#define insmod_trivial_usage 905//usage:#define insmod_trivial_usage
913//usage: "FILE" IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(" [SYMBOL=VALUE]...") 906//usage: "FILE" IF_FEATURE_CMDLINE_MODULE_OPTIONS(" [SYMBOL=VALUE]...")
914//usage:#define insmod_full_usage "\n\n" 907//usage:#define insmod_full_usage "\n\n"
915//usage: "Load kernel module" 908//usage: "Load kernel module"
916 909
@@ -920,7 +913,7 @@ The following options are useful for people managing distributions:
920//usage: "Unload kernel modules" 913//usage: "Unload kernel modules"
921 914
922//usage:#define modprobe_trivial_usage 915//usage:#define modprobe_trivial_usage
923//usage: "[-rq] MODULE" IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(" [SYMBOL=VALUE]...") 916//usage: "[-rq] MODULE" IF_FEATURE_CMDLINE_MODULE_OPTIONS(" [SYMBOL=VALUE]...")
924//usage:#define modprobe_full_usage "\n\n" 917//usage:#define modprobe_full_usage "\n\n"
925//usage: " -r Remove MODULE" 918//usage: " -r Remove MODULE"
926//usage: "\n -q Quiet" 919//usage: "\n -q Quiet"
@@ -934,7 +927,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
934 int exitcode; 927 int exitcode;
935#endif 928#endif
936 struct utsname uts; 929 struct utsname uts;
937 IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(char *options = NULL;) 930 IF_FEATURE_CMDLINE_MODULE_OPTIONS(char *options = NULL;)
938 931
939 INIT_G(); 932 INIT_G();
940 933
@@ -998,7 +991,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
998 if (!ONLY_APPLET) 991 if (!ONLY_APPLET)
999 option_mask32 |= OPT_r; 992 option_mask32 |= OPT_r;
1000 } else if (!ENABLE_MODPROBE || !(option_mask32 & OPT_r)) { 993 } else if (!ENABLE_MODPROBE || !(option_mask32 & OPT_r)) {
1001# if ENABLE_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE 994# if ENABLE_FEATURE_CMDLINE_MODULE_OPTIONS
1002 /* If not rmmod/-r, parse possible module options given on command line. 995 /* If not rmmod/-r, parse possible module options given on command line.
1003 * insmod/modprobe takes one module name, the rest are parameters. */ 996 * insmod/modprobe takes one module name, the rest are parameters. */
1004 char **arg = argv; 997 char **arg = argv;
@@ -1023,7 +1016,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
1023 if (!map) 1016 if (!map)
1024 bb_perror_msg_and_die("can't read '%s'", *argv); 1017 bb_perror_msg_and_die("can't read '%s'", *argv);
1025 if (init_module(map, len, 1018 if (init_module(map, len,
1026 (IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(options ? options : ) "") 1019 (IF_FEATURE_CMDLINE_MODULE_OPTIONS(options ? options : ) "")
1027 ) != 0 1020 ) != 0
1028 ) { 1021 ) {
1029 bb_error_msg_and_die("can't insert '%s': %s", 1022 bb_error_msg_and_die("can't insert '%s': %s",
@@ -1045,7 +1038,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
1045 } while (*++argv); 1038 } while (*++argv);
1046 1039
1047 if (ENABLE_FEATURE_CLEAN_UP) { 1040 if (ENABLE_FEATURE_CLEAN_UP) {
1048 IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(free(options);) 1041 IF_FEATURE_CMDLINE_MODULE_OPTIONS(free(options);)
1049 } 1042 }
1050 return exitcode; 1043 return exitcode;
1051#endif /* MODPROBE || INSMOD || RMMOD */ 1044#endif /* MODPROBE || INSMOD || RMMOD */
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index cbec43888..a6224fa63 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -112,7 +112,7 @@
112//usage: 112//usage:
113//usage:#define modprobe_trivial_usage 113//usage:#define modprobe_trivial_usage
114//usage: "[-alrqvsD" IF_FEATURE_MODPROBE_BLACKLIST("b") "]" 114//usage: "[-alrqvsD" IF_FEATURE_MODPROBE_BLACKLIST("b") "]"
115//usage: " MODULE [SYMBOL=VALUE]..." 115//usage: " MODULE" IF_FEATURE_CMDLINE_MODULE_OPTIONS(" [SYMBOL=VALUE]...")
116//usage:#define modprobe_full_usage "\n\n" 116//usage:#define modprobe_full_usage "\n\n"
117//usage: " -a Load multiple MODULEs" 117//usage: " -a Load multiple MODULEs"
118//usage: "\n -l List (MODULE is a pattern)" 118//usage: "\n -l List (MODULE is a pattern)"
@@ -174,7 +174,9 @@ static const char modprobe_longopts[] ALIGN1 =
174 174
175struct globals { 175struct globals {
176 llist_t *probes; /* MEs of module(s) requested on cmdline */ 176 llist_t *probes; /* MEs of module(s) requested on cmdline */
177#if ENABLE_FEATURE_CMDLINE_MODULE_OPTIONS
177 char *cmdline_mopts; /* module options from cmdline */ 178 char *cmdline_mopts; /* module options from cmdline */
179#endif
178 int num_unresolved_deps; 180 int num_unresolved_deps;
179 /* bool. "Did we have 'symbol:FOO' requested on cmdline?" */ 181 /* bool. "Did we have 'symbol:FOO' requested on cmdline?" */
180 smallint need_symbols; 182 smallint need_symbols;
@@ -458,8 +460,10 @@ static int do_modprobe(struct module_entry *m)
458 options = m2->options; 460 options = m2->options;
459 m2->options = NULL; 461 m2->options = NULL;
460 options = parse_and_add_kcmdline_module_options(options, m2->modname); 462 options = parse_and_add_kcmdline_module_options(options, m2->modname);
463#if ENABLE_FEATURE_CMDLINE_MODULE_OPTIONS
461 if (m == m2) 464 if (m == m2)
462 options = gather_options_str(options, G.cmdline_mopts); 465 options = gather_options_str(options, G.cmdline_mopts);
466#endif
463 467
464 if (option_mask32 & OPT_SHOW_DEPS) { 468 if (option_mask32 & OPT_SHOW_DEPS) {
465 printf(options ? "insmod %s/%s/%s %s\n" 469 printf(options ? "insmod %s/%s/%s %s\n"
@@ -626,7 +630,9 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
626 /* First argument is module name, rest are parameters */ 630 /* First argument is module name, rest are parameters */
627 DBG("probing just module %s", *argv); 631 DBG("probing just module %s", *argv);
628 add_probe(argv[0]); 632 add_probe(argv[0]);
633#if ENABLE_FEATURE_CMDLINE_MODULE_OPTIONS
629 G.cmdline_mopts = parse_cmdline_module_options(argv, /*quote_spaces:*/ 1); 634 G.cmdline_mopts = parse_cmdline_module_options(argv, /*quote_spaces:*/ 1);
635#endif
630 } 636 }
631 637
632 /* Happens if all requested modules are already loaded */ 638 /* Happens if all requested modules are already loaded */
diff --git a/modutils/modutils.c b/modutils/modutils.c
index 4204f06fe..dae623ee4 100644
--- a/modutils/modutils.c
+++ b/modutils/modutils.c
@@ -120,6 +120,7 @@ char* FAST_FUNC filename2modname(const char *filename, char *modname)
120 return modname; 120 return modname;
121} 121}
122 122
123#if ENABLE_FEATURE_CMDLINE_MODULE_OPTIONS
123char* FAST_FUNC parse_cmdline_module_options(char **argv, int quote_spaces) 124char* FAST_FUNC parse_cmdline_module_options(char **argv, int quote_spaces)
124{ 125{
125 char *options; 126 char *options;
@@ -155,6 +156,7 @@ char* FAST_FUNC parse_cmdline_module_options(char **argv, int quote_spaces)
155 /* if (optlen != 0) options[optlen-1] = '\0'; */ 156 /* if (optlen != 0) options[optlen-1] = '\0'; */
156 return options; 157 return options;
157} 158}
159#endif
158 160
159#if ENABLE_FEATURE_INSMOD_TRY_MMAP 161#if ENABLE_FEATURE_INSMOD_TRY_MMAP
160void* FAST_FUNC try_to_mmap_module(const char *filename, size_t *image_size_p) 162void* FAST_FUNC try_to_mmap_module(const char *filename, size_t *image_size_p)
diff --git a/modutils/modutils.h b/modutils/modutils.h
index 2cbd1448a..76ce242ba 100644
--- a/modutils/modutils.h
+++ b/modutils/modutils.h
@@ -51,7 +51,11 @@ void replace(char *s, char what, char with) FAST_FUNC;
51char *replace_underscores(char *s) FAST_FUNC; 51char *replace_underscores(char *s) FAST_FUNC;
52int string_to_llist(char *string, llist_t **llist, const char *delim) FAST_FUNC; 52int string_to_llist(char *string, llist_t **llist, const char *delim) FAST_FUNC;
53char *filename2modname(const char *filename, char *modname) FAST_FUNC; 53char *filename2modname(const char *filename, char *modname) FAST_FUNC;
54#if ENABLE_FEATURE_CMDLINE_MODULE_OPTIONS
54char *parse_cmdline_module_options(char **argv, int quote_spaces) FAST_FUNC; 55char *parse_cmdline_module_options(char **argv, int quote_spaces) FAST_FUNC;
56#else
57# define parse_cmdline_module_options(argv, quote_spaces) ""
58#endif
55 59
56/* insmod for 2.4 and modprobe's options (insmod 2.6 has no options at all): */ 60/* insmod for 2.4 and modprobe's options (insmod 2.6 has no options at all): */
57#define INSMOD_OPTS \ 61#define INSMOD_OPTS \