summaryrefslogtreecommitdiff
path: root/modutils
diff options
context:
space:
mode:
authorDenys Vlasenko2010-02-27 23:15:22 +0100
committerDenys Vlasenko2010-02-27 23:15:22 +0100
commit3e26d4fa233705f2061b6f296ac2a604e94f508a (patch)
treea78c15569cdcbcc3efcd18d046df4afd550df027 /modutils
parentf6b29a2dc9fc4e3c0cf8cd0c2ac6e674d47480ec (diff)
downloadbusybox-3e26d4fa233705f2061b6f296ac2a604e94f508a.zip
busybox-3e26d4fa233705f2061b6f296ac2a604e94f508a.tar.gz
modprobe: pick up module options from /proc/cmdline too
Based on patch by Ozan Çağlayan (ozan AT pardus.org.tr) function old new delta parse_and_add_kcmdline_module_options - 149 +149 do_modprobe 357 365 +8 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'modutils')
-rw-r--r--modutils/modprobe.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index 292f2df..0cfb365 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -228,6 +228,39 @@ static const char *humanly_readable_name(struct module_entry *m)
return m->probed_name ? m->probed_name : m->modname;
}
+static char *parse_and_add_kcmdline_module_options(char *options, const char *modulename)
+{
+ /* defined in arch/<architecture>/include/asm/setup.h
+ * (maximum is 2048 for IA64 and SPARC) */
+ char kcmdline_buf[2048];
+ char *kcmdline;
+ char *kptr;
+ int len;
+
+ len = open_read_close("/proc/cmdline", kcmdline_buf, 2047);
+ if (len <= 0)
+ return options;
+ kcmdline_buf[len] = '\0';
+
+ len = strlen(modulename);
+ kcmdline = kcmdline_buf;
+ while ((kptr = strsep(&kcmdline, "\n\t ")) != NULL) {
+ if (strncmp(modulename, kptr, len) != 0)
+ continue;
+ kptr += len;
+ if (*kptr != '.')
+ continue;
+ /* It is "modulename.xxxx" */
+ kptr++;
+ if (strchr(kptr, '=') != NULL) {
+ /* It is "modulename.opt=[val]" */
+ options = gather_options_str(options, kptr);
+ }
+ }
+
+ return options;
+}
+
/* Return: similar to bb_init_module:
* 0 on success,
* -errno on open/read error,
@@ -288,6 +321,7 @@ 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 (m == m2)
options = gather_options_str(options, G.cmdline_mopts);
rc = bb_init_module(fn, options);