summaryrefslogtreecommitdiff
path: root/kmodloader.c
diff options
context:
space:
mode:
authorKevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk>2017-01-29 09:23:15 +0000
committerFelix Fietkau <nbd@nbd.name>2017-02-01 11:23:14 +0100
commitac2d43e7c84fa3041ee2bf5709fdf69352189317 (patch)
tree7dc424a96e38f0e625284c13cf036af4a7cb1209 /kmodloader.c
parentf8d3d1672a3ad901f0cb1ad0418cd9547450c125 (diff)
downloadubox-ac2d43e7c84fa3041ee2bf5709fdf69352189317.tar.gz
kmodloader: support '-q' quiet option
The kernel opportunistically attempts to load modules in advanced with 'predicted' module names. Often these modules don't exist and hence kmodloader produces lots of logfile noise. The kernel commandline to modprobe from kworker proceses is '-q -- modulename' where '-q' means quiet. Support suppressing that noise. Signed-off-by: Kevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk>
Diffstat (limited to 'kmodloader.c')
-rw-r--r--kmodloader.c39
1 files changed, 29 insertions, 10 deletions
diff --git a/kmodloader.c b/kmodloader.c
index 729027a..465d3de 100644
--- a/kmodloader.c
+++ b/kmodloader.c
@@ -660,6 +660,13 @@ static int print_insmod_usage(void)
return -1;
}
+static int print_modprobe_usage(void)
+{
+ ULOG_INFO("Usage:\n\tmodprobe [-q] filename\n");
+
+ return -1;
+}
+
static int print_usage(char *arg)
{
ULOG_INFO("Usage:\n\t%s module\n", arg);
@@ -824,15 +831,24 @@ static int main_modprobe(int argc, char **argv)
struct module *m;
char *name;
char *mod = NULL;
- int i;
+ int opt;
+ bool quiet = false;
+
+ while ((opt = getopt(argc, argv, "q")) != -1 ) {
+ switch (opt) {
+ case 'q': /* shhhh! */
+ quiet = true;
+ break;
+ default: /* '?' */
+ return print_modprobe_usage();
+ break;
+ }
+ }
- for (i = 1; i < argc; i++)
- if (argv[i][0] != '-') {
- mod = argv[i];
- break;
- }
- if (!mod)
- return print_usage("modprobe");
+ if (optind >= argc)
+ return print_modprobe_usage(); /* expected module after options */
+
+ mod = argv[optind];
if (scan_module_folders())
return -1;
@@ -843,10 +859,13 @@ static int main_modprobe(int argc, char **argv)
name = get_module_name(mod);
m = find_module(name);
if (m && m->state == LOADED) {
- ULOG_ERR("%s is already loaded\n", name);
+ if (!quiet)
+ ULOG_ERR("%s is already loaded\n", name);
return -1;
} else if (!m) {
- ULOG_ERR("failed to find a module named %s\n", name);
+ if (!quiet)
+ ULOG_ERR("failed to find a module named %s\n", name);
+ return -1;
} else {
int fail;