[OpenWrt-Devel] [OpenWrt-Devel V2 1/2] kmodloader: added -v arg to modeprobe

Gerard Ryan g.m0n3y.2503 at gmail.com
Sun Oct 20 02:01:11 EDT 2019


This is primarily to satiate the usage by docker/libnetwork.

Signed-off-by: Gerard Ryan <G.M0N3Y.2503 at gmail.com>
---
Compile tested: x86_x64, Hyper-V, OpenWrt Master
Run tested: x86_x64, Hyper-V, OpenWrt Master

You can also find this patch on GitHub if you prefer.
https://github.com/G-M0N3Y-2503/openwrt-ubox-mirror/tree/feature_extend_modprobe_options

Since https://patchwork.ozlabs.org/patch/1175792/ I adjusted some whitespace to indent more consistently and split the patch by the args they implement.

 kmodloader.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/kmodloader.c b/kmodloader.c
index 422c895..07b6700 100644
--- a/kmodloader.c
+++ b/kmodloader.c
@@ -678,7 +678,10 @@ static int print_insmod_usage(void)

 static int print_modprobe_usage(void)
 {
-	ULOG_INFO("Usage:\n\tmodprobe [-q] filename\n");
+	ULOG_INFO(
+		"Usage:\n"
+		"\tmodprobe [-q] [-v] filename\n"
+	);

 	return -1;
 }
@@ -855,14 +858,18 @@ static int main_modprobe(int argc, char **argv)
 	struct module *m;
 	char *name;
 	char *mod = NULL;
+	int log_level = LOG_WARNING;
 	int opt;
 	bool quiet = false;

-	while ((opt = getopt(argc, argv, "q")) != -1 ) {
+	while ((opt = getopt(argc, argv, "qv")) != -1 ) {
 		switch (opt) {
 			case 'q': /* shhhh! */
 				quiet = true;
 				break;
+			case 'v':
+				log_level = LOG_DEBUG;
+				break;
 			default: /* '?' */
 				return print_modprobe_usage();
 				break;
@@ -872,6 +879,9 @@ static int main_modprobe(int argc, char **argv)
 	if (optind >= argc)
 		return print_modprobe_usage(); /* expected module after options */

+	/* after print_modprobe_usage() so it won't be filtered out */
+	ulog_threshold(log_level);
+
 	mod = argv[optind];

 	if (scan_module_folders())
--
2.17.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list