From a62c946ecdced9468ad16738325ee322029b0476 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Sat, 14 Jan 2017 01:00:32 +0800 Subject: [PATCH] kmodloader: modprobe: skip possible command line arguments The kernel may invocate user mode modprobe with the following scheme modprobe -q -- Signed-off-by: Yousong Zhou --- kmodloader.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/kmodloader.c b/kmodloader.c index b20de6e..065ac82 100644 --- a/kmodloader.c +++ b/kmodloader.c @@ -719,8 +719,15 @@ static int main_modprobe(int argc, char **argv) { struct module *m; char *name; + char *mod = NULL; + int i; - if (argc != 2) + for (i = 1; i < argc; i++) + if (argv[i][0] != '-') { + mod = argv[i]; + break; + } + if (!mod) return print_usage("modprobe"); if (scan_loaded_modules()) @@ -729,7 +736,7 @@ static int main_modprobe(int argc, char **argv) if (scan_module_folders()) return -1; - name = get_module_name(argv[1]); + name = get_module_name(mod); m = find_module(name); if (m && m->state == LOADED) { ULOG_ERR("%s is already loaded\n", name); -- 2.30.2