summaryrefslogtreecommitdiff
path: root/kernel/kmod.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@home.transmeta.com>2003-05-16 22:39:18 -0700
committerLinus Torvalds <torvalds@home.transmeta.com>2003-05-16 22:39:18 -0700
commitd847507434bbeda3e22b5f2c1cd5c486905ec1ab (patch)
tree85f325877503394edba7a77fd9cd40cc34d534c9 /kernel/kmod.c
parent3584199aaf995eea33b57fb1e933711c0fffe5cf (diff)
Make request_module() take a printf-like vararg argument instead of a string.
This is what a lot of the callers really wanted.
Diffstat (limited to 'kernel/kmod.c')
-rw-r--r--kernel/kmod.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/kernel/kmod.c b/kernel/kmod.c
index 971fc7438a6b..64a6d9ff86c3 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -58,11 +58,14 @@ char modprobe_path[256] = "/sbin/modprobe";
* If module auto-loading support is disabled then this function
* becomes a no-operation.
*/
-int request_module(const char *module_name)
+#define MODULENAME_SIZE 32
+int request_module(const char *fmt, ...)
{
+ va_list args;
+ char module_name[MODULENAME_SIZE];
unsigned int max_modprobes;
int ret;
- char *argv[] = { modprobe_path, "--", (char*)module_name, NULL };
+ char *argv[] = { modprobe_path, "--", module_name, NULL };
static char *envp[] = { "HOME=/",
"TERM=linux",
"PATH=/sbin:/usr/sbin:/bin:/usr/bin",
@@ -71,6 +74,12 @@ int request_module(const char *module_name)
#define MAX_KMOD_CONCURRENT 50 /* Completely arbitrary value - KAO */
static int kmod_loop_msg;
+ va_start(args, fmt);
+ ret = vsnprintf(module_name, MODULENAME_SIZE, fmt, args);
+ va_end(args);
+ if (ret >= MODULENAME_SIZE)
+ return -ENAMETOOLONG;
+
/* If modprobe needs a service that is in a module, we get a recursive
* loop. Limit the number of running kmod threads to max_threads/2 or
* MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
@@ -80,7 +89,6 @@ int request_module(const char *module_name)
* and it is not worth changing the proc code just to handle this case.
* KAO.
*
-
* "trace the ppid" is simple, but will fail if someone's
* parent exits. I think this is as good as it gets. --RR
*/