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>
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
//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"
/* 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
* 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
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 */
//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"
//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"
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();
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;
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",
} 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 */
//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)"
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;
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"
/* 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 */
return modname;
}
+#if ENABLE_FEATURE_CMDLINE_MODULE_OPTIONS
char* FAST_FUNC parse_cmdline_module_options(char **argv, int quote_spaces)
{
char *options;
/* 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)
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 \