Commit 3e63a93b authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Linus Torvalds

kmod: introduce call_modprobe() helper

No functional changes.  Move the call_usermodehelper code from
__request_module() into the new simple helper, call_modprobe().
Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Tejun Heo <tj@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 5b9bd473
...@@ -60,6 +60,21 @@ static DECLARE_RWSEM(umhelper_sem); ...@@ -60,6 +60,21 @@ static DECLARE_RWSEM(umhelper_sem);
*/ */
char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe"; char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe";
static int call_modprobe(char *module_name, int wait)
{
static char *envp[] = {
"HOME=/",
"TERM=linux",
"PATH=/sbin:/usr/sbin:/bin:/usr/bin",
NULL
};
char *argv[] = { modprobe_path, "-q", "--", module_name, NULL };
return call_usermodehelper_fns(modprobe_path, argv, envp,
wait, NULL, NULL, NULL);
}
/** /**
* __request_module - try to load a kernel module * __request_module - try to load a kernel module
* @wait: wait (or not) for the operation to complete * @wait: wait (or not) for the operation to complete
...@@ -81,11 +96,6 @@ int __request_module(bool wait, const char *fmt, ...) ...@@ -81,11 +96,6 @@ int __request_module(bool wait, const char *fmt, ...)
char module_name[MODULE_NAME_LEN]; char module_name[MODULE_NAME_LEN];
unsigned int max_modprobes; unsigned int max_modprobes;
int ret; int ret;
char *argv[] = { modprobe_path, "-q", "--", module_name, NULL };
static char *envp[] = { "HOME=/",
"TERM=linux",
"PATH=/sbin:/usr/sbin:/bin:/usr/bin",
NULL };
static atomic_t kmod_concurrent = ATOMIC_INIT(0); static atomic_t kmod_concurrent = ATOMIC_INIT(0);
#define MAX_KMOD_CONCURRENT 50 /* Completely arbitrary value - KAO */ #define MAX_KMOD_CONCURRENT 50 /* Completely arbitrary value - KAO */
static int kmod_loop_msg; static int kmod_loop_msg;
...@@ -128,9 +138,7 @@ int __request_module(bool wait, const char *fmt, ...) ...@@ -128,9 +138,7 @@ int __request_module(bool wait, const char *fmt, ...)
trace_module_request(module_name, wait, _RET_IP_); trace_module_request(module_name, wait, _RET_IP_);
ret = call_usermodehelper_fns(modprobe_path, argv, envp, ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC,
NULL, NULL, NULL);
atomic_dec(&kmod_concurrent); atomic_dec(&kmod_concurrent);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment