Commit eddef4fe authored by Rusty Russell's avatar Rusty Russell Committed by Linus Torvalds

[PATCH] modprobe -q: quieter when modules missing

The kernel invokes "modprobe" on modules which might not exist:
rightfully, modprobe complains by default when this happens.  So the
correct response is to invoke "modprobe -q", which is silent on such
errors (but still reports other errors such as config errors). 

Also, use MODULE_NAME_LEN from module.h instead of inventing our own.
parent 4cf01742
...@@ -60,12 +60,11 @@ char modprobe_path[256] = "/sbin/modprobe"; ...@@ -60,12 +60,11 @@ char modprobe_path[256] = "/sbin/modprobe";
*/ */
int request_module(const char *fmt, ...) int request_module(const char *fmt, ...)
{ {
#define MODULENAME_SIZE 32
va_list args; va_list args;
char module_name[MODULENAME_SIZE]; char module_name[MODULE_NAME_LEN];
unsigned int max_modprobes; unsigned int max_modprobes;
int ret; int ret;
char *argv[] = { modprobe_path, "--", module_name, NULL }; char *argv[] = { modprobe_path, "-q", "--", module_name, NULL };
static char *envp[] = { "HOME=/", static char *envp[] = { "HOME=/",
"TERM=linux", "TERM=linux",
"PATH=/sbin:/usr/sbin:/bin:/usr/bin", "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
...@@ -75,9 +74,9 @@ int request_module(const char *fmt, ...) ...@@ -75,9 +74,9 @@ int request_module(const char *fmt, ...)
static int kmod_loop_msg; static int kmod_loop_msg;
va_start(args, fmt); va_start(args, fmt);
ret = vsnprintf(module_name, MODULENAME_SIZE, fmt, args); ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
va_end(args); va_end(args);
if (ret >= MODULENAME_SIZE) if (ret >= MODULE_NAME_LEN)
return -ENAMETOOLONG; return -ENAMETOOLONG;
/* If modprobe needs a service that is in a module, we get a recursive /* If modprobe needs a service that is in a module, we get a recursive
......
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