diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-02-27 23:15:22 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-02-27 23:15:22 +0100 |
commit | 3e26d4fa233705f2061b6f296ac2a604e94f508a (patch) | |
tree | a78c15569cdcbcc3efcd18d046df4afd550df027 | |
parent | f6b29a2dc9fc4e3c0cf8cd0c2ac6e674d47480ec (diff) | |
download | busybox-w32-3e26d4fa233705f2061b6f296ac2a604e94f508a.tar.gz busybox-w32-3e26d4fa233705f2061b6f296ac2a604e94f508a.tar.bz2 busybox-w32-3e26d4fa233705f2061b6f296ac2a604e94f508a.zip |
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>
-rw-r--r-- | modutils/modprobe.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/modutils/modprobe.c b/modutils/modprobe.c index 292f2df22..0cfb365b6 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c | |||
@@ -228,6 +228,39 @@ static const char *humanly_readable_name(struct module_entry *m) | |||
228 | return m->probed_name ? m->probed_name : m->modname; | 228 | return m->probed_name ? m->probed_name : m->modname; |
229 | } | 229 | } |
230 | 230 | ||
231 | static char *parse_and_add_kcmdline_module_options(char *options, const char *modulename) | ||
232 | { | ||
233 | /* defined in arch/<architecture>/include/asm/setup.h | ||
234 | * (maximum is 2048 for IA64 and SPARC) */ | ||
235 | char kcmdline_buf[2048]; | ||
236 | char *kcmdline; | ||
237 | char *kptr; | ||
238 | int len; | ||
239 | |||
240 | len = open_read_close("/proc/cmdline", kcmdline_buf, 2047); | ||
241 | if (len <= 0) | ||
242 | return options; | ||
243 | kcmdline_buf[len] = '\0'; | ||
244 | |||
245 | len = strlen(modulename); | ||
246 | kcmdline = kcmdline_buf; | ||
247 | while ((kptr = strsep(&kcmdline, "\n\t ")) != NULL) { | ||
248 | if (strncmp(modulename, kptr, len) != 0) | ||
249 | continue; | ||
250 | kptr += len; | ||
251 | if (*kptr != '.') | ||
252 | continue; | ||
253 | /* It is "modulename.xxxx" */ | ||
254 | kptr++; | ||
255 | if (strchr(kptr, '=') != NULL) { | ||
256 | /* It is "modulename.opt=[val]" */ | ||
257 | options = gather_options_str(options, kptr); | ||
258 | } | ||
259 | } | ||
260 | |||
261 | return options; | ||
262 | } | ||
263 | |||
231 | /* Return: similar to bb_init_module: | 264 | /* Return: similar to bb_init_module: |
232 | * 0 on success, | 265 | * 0 on success, |
233 | * -errno on open/read error, | 266 | * -errno on open/read error, |
@@ -288,6 +321,7 @@ static int do_modprobe(struct module_entry *m) | |||
288 | 321 | ||
289 | options = m2->options; | 322 | options = m2->options; |
290 | m2->options = NULL; | 323 | m2->options = NULL; |
324 | options = parse_and_add_kcmdline_module_options(options, m2->modname); | ||
291 | if (m == m2) | 325 | if (m == m2) |
292 | options = gather_options_str(options, G.cmdline_mopts); | 326 | options = gather_options_str(options, G.cmdline_mopts); |
293 | rc = bb_init_module(fn, options); | 327 | rc = bb_init_module(fn, options); |