aboutsummaryrefslogtreecommitdiff
path: root/modutils
diff options
context:
space:
mode:
authorGravatar Denis Vlasenko <vda.linux@googlemail.com>2008-09-06 14:14:01 +0000
committerGravatar Denis Vlasenko <vda.linux@googlemail.com>2008-09-06 14:14:01 +0000
commit1c781cc8fffa64ae59438bf653994cf908ba2b35 (patch)
treec0818e38cf4c8862c1ad7bced2c4e0d7dfaef029 /modutils
parent4acb1b079316765b5896b4b87fc67804384412b2 (diff)
downloadbusybox-1c781cc8fffa64ae59438bf653994cf908ba2b35.tar.gz
busybox-1c781cc8fffa64ae59438bf653994cf908ba2b35.tar.bz2
modprobe-small: make insmod command line compatible
function old new delta modprobe_main 326 435 +109 moderror - 52 +52 process_module 577 530 -47
Diffstat (limited to 'modutils')
-rw-r--r--modutils/modprobe-small.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c
index 5e33cdc57..e2bf828b7 100644
--- a/modutils/modprobe-small.c
+++ b/modutils/modprobe-small.c
@@ -599,7 +599,7 @@ static void process_module(char *name, const char *cmdline_options)
}
free(deps);
- /* insmod -> load it */
+ /* modprobe -> load it */
if (!is_rmmod && !strstr(options, "blacklist")) {
errno = 0;
if (load_module(info->pathname, options) != 0) {
@@ -688,8 +688,10 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
/* Prevent ugly corner cases with no modules at all */
modinfo = xzalloc(sizeof(modinfo[0]));
- /* Goto modules directory */
- xchdir(CONFIG_DEFAULT_MODULES_DIR);
+ if ('i' != applet0) { /* not insmod */
+ /* Goto modules directory */
+ xchdir(CONFIG_DEFAULT_MODULES_DIR);
+ }
uname(&uts); /* never fails */
/* depmod? */
@@ -736,8 +738,10 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
option_mask32 |= OPT_r;
}
- /* Goto $VERSION directory */
- xchdir(uts.release);
+ if ('i' != applet0) { /* not insmod */
+ /* Goto $VERSION directory */
+ xchdir(uts.release);
+ }
#if ENABLE_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE
/* If not rmmod, parse possible module options given on command line.
@@ -758,11 +762,26 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
argv[1] = NULL;
#endif
+ if ('i' == applet0) { /* insmod */
+ size_t len;
+ void *map;
+
+ len = MAXINT(ssize_t);
+ map = xmalloc_xopen_read_close(*argv, &len);
+ if (init_module(map, len,
+ USE_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(options ? options : "")
+ SKIP_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE("")
+ ) != 0)
+ bb_error_msg_and_die("cannot insert '%s': %s",
+ *argv, moderror(errno));
+ return 0;
+ }
+
/* Try to load modprobe.dep.bb */
load_dep_bb();
/* Load/remove modules.
- * Only rmmod loops here, insmod/modprobe has only argv[0] */
+ * Only rmmod loops here, modprobe has only argv[0] */
do {
process_module(*argv++, options);
} while (*argv);