summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKang-Che Sung2017-01-31 21:09:17 +0800
committerDenys Vlasenko2017-02-01 10:14:05 +0100
commitb1d6a2c6247bae0b9f1903ba0e0d16c56f4ef556 (patch)
treeafc10aba770e711341483ef13b95ab3ac4916f9b
parent264cb01540cdd995e7c376fd8bcef94e09e31819 (diff)
downloadbusybox-b1d6a2c6247bae0b9f1903ba0e0d16c56f4ef556.zip
busybox-b1d6a2c6247bae0b9f1903ba0e0d16c56f4ef556.tar.gz
cmdline module options can be disabled on "big" modutils
Allow module options on command line to be disabled on "big" modutils. Config FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE is renamed to FEATURE_CMDLINE_MODULE_OPTIONS and no longer depends on !MODPROBE_SMALL (I'm not sure if disabling this is useful on "big" modutils, but at least the macro can serve as a marker and ensure both implementations of same feature have consistent behavior.) Signed-off-by: Kang-Che Sung <explorer09@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-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 f2448c9..a15cce5 100644
--- a/modutils/Config.src
+++ b/modutils/Config.src
@@ -37,6 +37,14 @@ INSERT
comment "Options common to multiple modutils"
+config FEATURE_CMDLINE_MODULE_OPTIONS
+ bool "Accept module options on modprobe command line"
+ default y
+ depends on INSMOD || MODPROBE
+ help
+ Allow insmod and modprobe take module options from the applets'
+ command line.
+
config FEATURE_2_4_MODULES
bool "Support version 2.2/2.4 Linux kernels"
default n
diff --git a/modutils/insmod.c b/modutils/insmod.c
index f2c70e1..8526979 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -27,9 +27,9 @@
//usage:#if !ENABLE_MODPROBE_SMALL
//usage:#define insmod_trivial_usage
-//usage: IF_FEATURE_2_4_MODULES("[OPTIONS] MODULE ")
-//usage: IF_NOT_FEATURE_2_4_MODULES("FILE ")
-//usage: "[SYMBOL=VALUE]..."
+//usage: IF_FEATURE_2_4_MODULES("[OPTIONS] MODULE")
+//usage: IF_NOT_FEATURE_2_4_MODULES("FILE")
+//usage: IF_FEATURE_CMDLINE_MODULE_OPTIONS(" [SYMBOL=VALUE]...")
//usage:#define insmod_full_usage "\n\n"
//usage: "Load kernel module"
//usage: IF_FEATURE_2_4_MODULES( "\n"
diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c
index 325f837..0424263 100644
--- a/modutils/modprobe-small.c
+++ b/modutils/modprobe-small.c
@@ -10,13 +10,6 @@
/* config MODPROBE_SMALL is defined in Config.src to ensure better "make config" order */
-//config:config FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE
-//config: bool "Accept module options on modprobe command line"
-//config: default y
-//config: depends on MODPROBE_SMALL && (INSMOD || MODPROBE)
-//config: help
-//config: Allow insmod and modprobe take module options from command line.
-//config:
//config:config FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED
//config: bool "Skip loading of already loaded modules"
//config: default y
@@ -690,7 +683,7 @@ static int rmmod(const char *filename)
* NB: also called by depmod with bogus name "/",
* just in order to force modprobe.dep.bb creation.
*/
-#if !ENABLE_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE
+#if !ENABLE_FEATURE_CMDLINE_MODULE_OPTIONS
#define process_module(a,b) process_module(a)
#define cmdline_options ""
#endif
@@ -735,7 +728,7 @@ static int process_module(char *name, const char *cmdline_options)
options = xmalloc_open_read_close(opt_filename, NULL);
if (options)
replace(options, '\n', ' ');
-#if ENABLE_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE
+#if ENABLE_FEATURE_CMDLINE_MODULE_OPTIONS
if (cmdline_options) {
/* NB: cmdline_options always have one leading ' '
* (see main()), we remove it here */
@@ -910,7 +903,7 @@ The following options are useful for people managing distributions:
//usage:#define depmod_full_usage ""
//usage:#define insmod_trivial_usage
-//usage: "FILE" IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(" [SYMBOL=VALUE]...")
+//usage: "FILE" IF_FEATURE_CMDLINE_MODULE_OPTIONS(" [SYMBOL=VALUE]...")
//usage:#define insmod_full_usage "\n\n"
//usage: "Load kernel module"
@@ -920,7 +913,7 @@ The following options are useful for people managing distributions:
//usage: "Unload kernel modules"
//usage:#define modprobe_trivial_usage
-//usage: "[-rq] MODULE" IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(" [SYMBOL=VALUE]...")
+//usage: "[-rq] MODULE" IF_FEATURE_CMDLINE_MODULE_OPTIONS(" [SYMBOL=VALUE]...")
//usage:#define modprobe_full_usage "\n\n"
//usage: " -r Remove MODULE"
//usage: "\n -q Quiet"
@@ -934,7 +927,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
int exitcode;
#endif
struct utsname uts;
- IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(char *options = NULL;)
+ IF_FEATURE_CMDLINE_MODULE_OPTIONS(char *options = NULL;)
INIT_G();
@@ -998,7 +991,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
if (!ONLY_APPLET)
option_mask32 |= OPT_r;
} else if (!ENABLE_MODPROBE || !(option_mask32 & OPT_r)) {
-# if ENABLE_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE
+# if ENABLE_FEATURE_CMDLINE_MODULE_OPTIONS
/* If not rmmod/-r, parse possible module options given on command line.
* insmod/modprobe takes one module name, the rest are parameters. */
char **arg = argv;
@@ -1023,7 +1016,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
if (!map)
bb_perror_msg_and_die("can't read '%s'", *argv);
if (init_module(map, len,
- (IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(options ? options : ) "")
+ (IF_FEATURE_CMDLINE_MODULE_OPTIONS(options ? options : ) "")
) != 0
) {
bb_error_msg_and_die("can't insert '%s': %s",
@@ -1045,7 +1038,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
} while (*++argv);
if (ENABLE_FEATURE_CLEAN_UP) {
- IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(free(options);)
+ IF_FEATURE_CMDLINE_MODULE_OPTIONS(free(options);)
}
return exitcode;
#endif /* MODPROBE || INSMOD || RMMOD */
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index cbec438..a6224fa 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -112,7 +112,7 @@
//usage:
//usage:#define modprobe_trivial_usage
//usage: "[-alrqvsD" IF_FEATURE_MODPROBE_BLACKLIST("b") "]"
-//usage: " MODULE [SYMBOL=VALUE]..."
+//usage: " MODULE" IF_FEATURE_CMDLINE_MODULE_OPTIONS(" [SYMBOL=VALUE]...")
//usage:#define modprobe_full_usage "\n\n"
//usage: " -a Load multiple MODULEs"
//usage: "\n -l List (MODULE is a pattern)"
@@ -174,7 +174,9 @@ static const char modprobe_longopts[] ALIGN1 =
struct globals {
llist_t *probes; /* MEs of module(s) requested on cmdline */
+#if ENABLE_FEATURE_CMDLINE_MODULE_OPTIONS
char *cmdline_mopts; /* module options from cmdline */
+#endif
int num_unresolved_deps;
/* bool. "Did we have 'symbol:FOO' requested on cmdline?" */
smallint need_symbols;
@@ -458,8 +460,10 @@ static int do_modprobe(struct module_entry *m)
options = m2->options;
m2->options = NULL;
options = parse_and_add_kcmdline_module_options(options, m2->modname);
+#if ENABLE_FEATURE_CMDLINE_MODULE_OPTIONS
if (m == m2)
options = gather_options_str(options, G.cmdline_mopts);
+#endif
if (option_mask32 & OPT_SHOW_DEPS) {
printf(options ? "insmod %s/%s/%s %s\n"
@@ -626,7 +630,9 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
/* First argument is module name, rest are parameters */
DBG("probing just module %s", *argv);
add_probe(argv[0]);
+#if ENABLE_FEATURE_CMDLINE_MODULE_OPTIONS
G.cmdline_mopts = parse_cmdline_module_options(argv, /*quote_spaces:*/ 1);
+#endif
}
/* Happens if all requested modules are already loaded */
diff --git a/modutils/modutils.c b/modutils/modutils.c
index 4204f06..dae623e 100644
--- a/modutils/modutils.c
+++ b/modutils/modutils.c
@@ -120,6 +120,7 @@ char* FAST_FUNC filename2modname(const char *filename, char *modname)
return modname;
}
+#if ENABLE_FEATURE_CMDLINE_MODULE_OPTIONS
char* FAST_FUNC parse_cmdline_module_options(char **argv, int quote_spaces)
{
char *options;
@@ -155,6 +156,7 @@ char* FAST_FUNC parse_cmdline_module_options(char **argv, int quote_spaces)
/* if (optlen != 0) options[optlen-1] = '\0'; */
return options;
}
+#endif
#if ENABLE_FEATURE_INSMOD_TRY_MMAP
void* 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 2cbd144..76ce242 100644
--- a/modutils/modutils.h
+++ b/modutils/modutils.h
@@ -51,7 +51,11 @@ void replace(char *s, char what, char with) FAST_FUNC;
char *replace_underscores(char *s) FAST_FUNC;
int string_to_llist(char *string, llist_t **llist, const char *delim) FAST_FUNC;
char *filename2modname(const char *filename, char *modname) FAST_FUNC;
+#if ENABLE_FEATURE_CMDLINE_MODULE_OPTIONS
char *parse_cmdline_module_options(char **argv, int quote_spaces) FAST_FUNC;
+#else
+# define parse_cmdline_module_options(argv, quote_spaces) ""
+#endif
/* insmod for 2.4 and modprobe's options (insmod 2.6 has no options at all): */
#define INSMOD_OPTS \