[LEDE-DEV] [PATCH ubox 3/6] kmodloader: modprobe: skip possible command line arguments

Yousong Zhou yszhou4tech at gmail.com
Wed Jan 11 03:54:07 PST 2017


The kernel may invocate user mode modprobe with the following scheme

    modprobe -q -- <module_name>

Signed-off-by: Yousong Zhou <yszhou4tech at gmail.com>
---
 kmodloader.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/kmodloader.c b/kmodloader.c
index b20de6e..b5dc4d1 100644
--- a/kmodloader.c
+++ b/kmodloader.c
@@ -719,8 +719,17 @@ static int main_modprobe(int argc, char **argv)
 {
 	struct module *m;
 	char *name;
+	char *mod = NULL;
+	int i;
 
-	if (argc != 2)
+	if (argc < 2)
+		return print_usage("modprobe");
+	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 +738,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.6.4




More information about the Lede-dev mailing list