aboutsummaryrefslogtreecommitdiff
path: root/modutils
diff options
context:
space:
mode:
Diffstat (limited to 'modutils')
-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
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 f2c70e16f..8526979eb 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 325f8376b..04242634b 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 cbec43888..a6224fa63 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 4204f06fe..dae623ee4 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 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;
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 \