diff options
author | Oleg Nesterov <oleg@redhat.com> | 2012-03-23 18:02:49 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-23 19:58:42 -0400 |
commit | 3e63a93b987685f02421e18b2aa452d20553a88b (patch) | |
tree | 4674115a6be71dbd2a78a411cb3617842acd8c8e /kernel/kmod.c | |
parent | 5b9bd473e3b8a8c6c4ae99be475e6e9b27568555 (diff) |
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: Oleg 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/kmod.c')
-rw-r--r-- | kernel/kmod.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/kernel/kmod.c b/kernel/kmod.c index 685b246b13b0..56a29e812ff0 100644 --- a/kernel/kmod.c +++ b/kernel/kmod.c | |||
@@ -60,6 +60,21 @@ static DECLARE_RWSEM(umhelper_sem); | |||
60 | */ | 60 | */ |
61 | char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe"; | 61 | char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe"; |
62 | 62 | ||
63 | static int call_modprobe(char *module_name, int wait) | ||
64 | { | ||
65 | static char *envp[] = { | ||
66 | "HOME=/", | ||
67 | "TERM=linux", | ||
68 | "PATH=/sbin:/usr/sbin:/bin:/usr/bin", | ||
69 | NULL | ||
70 | }; | ||
71 | |||
72 | char *argv[] = { modprobe_path, "-q", "--", module_name, NULL }; | ||
73 | |||
74 | return call_usermodehelper_fns(modprobe_path, argv, envp, | ||
75 | wait, NULL, NULL, NULL); | ||
76 | } | ||
77 | |||
63 | /** | 78 | /** |
64 | * __request_module - try to load a kernel module | 79 | * __request_module - try to load a kernel module |
65 | * @wait: wait (or not) for the operation to complete | 80 | * @wait: wait (or not) for the operation to complete |
@@ -81,11 +96,6 @@ int __request_module(bool wait, const char *fmt, ...) | |||
81 | char module_name[MODULE_NAME_LEN]; | 96 | char module_name[MODULE_NAME_LEN]; |
82 | unsigned int max_modprobes; | 97 | unsigned int max_modprobes; |
83 | int ret; | 98 | int ret; |
84 | char *argv[] = { modprobe_path, "-q", "--", module_name, NULL }; | ||
85 | static char *envp[] = { "HOME=/", | ||
86 | "TERM=linux", | ||
87 | "PATH=/sbin:/usr/sbin:/bin:/usr/bin", | ||
88 | NULL }; | ||
89 | static atomic_t kmod_concurrent = ATOMIC_INIT(0); | 99 | static atomic_t kmod_concurrent = ATOMIC_INIT(0); |
90 | #define MAX_KMOD_CONCURRENT 50 /* Completely arbitrary value - KAO */ | 100 | #define MAX_KMOD_CONCURRENT 50 /* Completely arbitrary value - KAO */ |
91 | static int kmod_loop_msg; | 101 | static int kmod_loop_msg; |
@@ -128,9 +138,7 @@ int __request_module(bool wait, const char *fmt, ...) | |||
128 | 138 | ||
129 | trace_module_request(module_name, wait, _RET_IP_); | 139 | trace_module_request(module_name, wait, _RET_IP_); |
130 | 140 | ||
131 | ret = call_usermodehelper_fns(modprobe_path, argv, envp, | 141 | ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC); |
132 | wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC, | ||
133 | NULL, NULL, NULL); | ||
134 | 142 | ||
135 | atomic_dec(&kmod_concurrent); | 143 | atomic_dec(&kmod_concurrent); |
136 | return ret; | 144 | return ret; |