[PATCH] modprobe: Restore "-D" option, add long options

Serj Kalichev serj.kalichev at gmail.com
Mon Dec 27 16:04:18 UTC 2010


From: pkun <pkun at pkunistan.(none)>

I have restored "-D" option for the several reasons:
* The modern module-init-tools 3.12 has "-D" options and this option works. For
example in Archlinux. The buildroot uses version 3.12, so it has this option too.
The code from the upstream modprobe.c:
" { "show-depends", 0, NULL, 'D' },"
With the "-D" the busybox will be more compatible with newer module-init-tools.
* Without short option the simple (in implementation) feature will be lost if
the long options is disabled.
* The "D" is better than any random symbol.

The --show-depends and -a options can be used together due to upstream modprobe
behaviour.

Additionally I add long options for the other modprobe parameters. All of these
long options are documented within modprobe's manpage. It will be more
compatible.

Signed-off-by: pkun <pkun at pkunistan.(none)>
---
 modutils/modprobe.c |   64 +++++++++++++++++++++++++++++++++-----------------
 1 files changed, 42 insertions(+), 22 deletions(-)

diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index 8e83f41..00b7384 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -72,21 +72,37 @@
 //usage:       "   from the command line\n"
 //usage:
 //usage:#define modprobe_trivial_usage
-//usage:	"[-alrqvs" IF_FEATURE_MODPROBE_BLACKLIST("b") "]"
-//usage:	IF_LONG_OPTS(" [--show-depends]") " MODULE [symbol=value]..."
+//usage:	"[-alrqvsD" IF_FEATURE_MODPROBE_BLACKLIST("b") "]"
+//usage:	IF_LONG_OPTS(
+//usage:	" [--all] [--list] [--remove] [--quiet] [--verbose] [--syslog]"
+//usage:	" [--show-depends]" IF_FEATURE_MODPROBE_BLACKLIST(" [--use-blacklist]")
+//usage:	)
+//usage:	" MODULE [symbol=value]..."
 //usage:#define modprobe_full_usage "\n\n"
 //usage:       "Options:"
-//usage:     "\n	-a		Load multiple MODULEs"
-//usage:     "\n	-l		List (MODULE is a pattern)"
-//usage:     "\n	-r		Remove MODULE (stacks) or do autoclean"
-//usage:     "\n	-q		Quiet"
-//usage:     "\n	-v		Verbose"
-//usage:     "\n	-s		Log to syslog"
+//usage:	IF_NOT_LONG_OPTS(
+//usage:     "\n	-a			Load multiple MODULEs"
+//usage:     "\n	-l			List (MODULE is a pattern)"
+//usage:     "\n	-r			Remove MODULE (stacks) or do autoclean"
+//usage:     "\n	-q			Quiet"
+//usage:     "\n	-v			Verbose"
+//usage:     "\n	-s			Log to syslog"
+//usage:     "\n	-D			Show dependencies"
 //usage:	IF_FEATURE_MODPROBE_BLACKLIST(
-//usage:     "\n	-b		Apply blacklist to module names too"
+//usage:     "\n	-b			Apply blacklist to module names too"
+//usage:	)
 //usage:	)
 //usage:	IF_LONG_OPTS(
-//usage:     "\n	--show-depends	Show dependencies"
+//usage:     "\n	-a, --all		Load multiple MODULEs"
+//usage:     "\n	-l, --list		List (MODULE is a pattern)"
+//usage:     "\n	-r, --remove		Remove MODULE (stacks) or do autoclean"
+//usage:     "\n	-q, --quiet		Quiet"
+//usage:     "\n	-v, --verbose		Verbose"
+//usage:     "\n	-s, --syslog		Log to syslog"
+//usage:     "\n	-D, --show-depends	Show dependencies"
+//usage:	IF_FEATURE_MODPROBE_BLACKLIST(
+//usage:     "\n	-b, --use-blacklist	Apply blacklist to module names too"
+//usage:	)
 //usage:	)
 //usage:#endif /* !ENABLE_MODPROBE_SMALL */
 
@@ -106,17 +122,22 @@
 
 /* Note that usage text doesn't document various 2.4 options
  * we pull in through INSMOD_OPTS define */
-#define MODPROBE_OPTS  "alr" IF_FEATURE_MODPROBE_BLACKLIST("b")
-#undef SD
+#define MODPROBE_OPTS  "alrD" IF_FEATURE_MODPROBE_BLACKLIST("b")
 #if ENABLE_LONG_OPTS
 static const char modprobe_longopts[] ALIGN1 =
-        "show-depends\0" No_argument "\xff"
-        ;
-# define SD "\xff"
-#else
-# define SD ""
+	"all\0"          No_argument "a"
+	"list\0"         No_argument "l"
+	"remove\0"       No_argument "r"
+	"quiet\0"        No_argument "q"
+	"verbose\0"      No_argument "v"
+	"syslog\0"       No_argument "s"
+	"show-depends\0" No_argument "D"
+	IF_FEATURE_MODPROBE_BLACKLIST(
+	"use-blacklist\0" No_argument "b"
+	)
+	;
 #endif
-#define MODPROBE_COMPLEMENTARY ("q-v:v-q:l--ar"SD":a--lr"SD":r--al"SD IF_LONG_OPTS(":\xff--arl"))
+#define MODPROBE_COMPLEMENTARY ("q-v:v-q:l--arD:a--lr:r--alD:D--rl")
 //#define MODPROBE_OPTS  "acd:lnrt:C:" IF_FEATURE_MODPROBE_BLACKLIST("b")
 //#define MODPROBE_COMPLEMENTARY "q-v:v-q:l--acr:a--lr:r--al"
 enum {
@@ -128,10 +149,9 @@ enum {
 	OPT_REMOVE       = (INSMOD_OPT_UNUSED << 2), /* r */
 	//OPT_RESTRICT   = (INSMOD_OPT_UNUSED << x), /* t */
 	//OPT_VERONLY    = (INSMOD_OPT_UNUSED << x), /* V */
-	//OPT_CONFIGFILE =(INSMOD_OPT_UNUSED << x), /* C */
-	OPT_BLACKLIST    = (INSMOD_OPT_UNUSED << 3) * ENABLE_FEATURE_MODPROBE_BLACKLIST,
-	OPTBIT_SHOW_DEPS = (3 + ENABLE_FEATURE_MODPROBE_BLACKLIST),
-	OPT_SHOW_DEPS    = (INSMOD_OPT_UNUSED << OPTBIT_SHOW_DEPS) * ENABLE_LONG_OPTS,
+	//OPT_CONFIGFILE = (INSMOD_OPT_UNUSED << x), /* C */
+	OPT_SHOW_DEPS    = (INSMOD_OPT_UNUSED << 3), /* D */
+	OPT_BLACKLIST    = (INSMOD_OPT_UNUSED << 4) * ENABLE_FEATURE_MODPROBE_BLACKLIST,
 };
 
 #define MODULE_FLAG_LOADED              0x0001
-- 
1.6.3.3



More information about the busybox mailing list