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

Message ID 20191020060112.25323-1-G.M0N3Y.2503@gmail.com
State Accepted
Delegated to: John Crispin
Headers show
Series
  • [OpenWrt-Devel,OpenWrt-Devel,V2,1/2] kmodloader: added -v arg to modeprobe
Related show

Commit Message

Gerard Ryan Oct. 20, 2019, 6:01 a.m. UTC
This is primarily to satiate the usage by docker/libnetwork.

Signed-off-by: Gerard Ryan <G.M0N3Y.2503@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(-)

--
2.17.1

Patch
diff mbox series

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())