[PATCH] modprobe: add --resolve-alias option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The --resolve-alias option prints all module names that match the
alias given on the commandline and exits. If no valid alias is specified,
it does nothing.
---
 doc/modprobe.sgml |    9 +++++++++
 modprobe.c        |   12 +++++++++++-
 2 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/doc/modprobe.sgml b/doc/modprobe.sgml
index fde8ca7..69b2d84 100644
--- a/doc/modprobe.sgml
+++ b/doc/modprobe.sgml
@@ -367,6 +367,15 @@
         </listitem>
       </varlistentry>
       <varlistentry>
+        <term><option>--resolve-alias</option>
+        </term>
+        <listitem>
+          <para>
+	    Print all module names matching an alias.
+	  </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
         <term><option>-o</option> <option>--name</option>
         </term>
         <listitem>
diff --git a/modprobe.c b/modprobe.c
index 21a3111..a34709e 100644
--- a/modprobe.c
+++ b/modprobe.c
@@ -69,7 +69,8 @@ typedef enum
 	mit_ignore_commands = 16,
 	mit_ignore_loaded = 32,
 	mit_strip_vermagic = 64,
-	mit_strip_modversion = 128
+	mit_strip_modversion = 128,
+	mit_resolve_alias = 256
 
 } modprobe_flags_t;
 
@@ -1335,6 +1336,11 @@ int do_modprobe(char *modname,
 	}
 
 	aliases = apply_blacklist(aliases, blacklist);
+	if(flags & mit_resolve_alias) {
+		for(; aliases; aliases=aliases->next)
+			printf("%s\n", aliases->module);
+		return 0;
+	}
 	if (aliases) {
 		errfn_t err = error;
 
@@ -1373,6 +1379,7 @@ static struct option options[] = { { "version", 0, NULL, 'V' },
 				   { "show", 0, NULL, 'n' },
 				   { "dry-run", 0, NULL, 'n' },
 				   { "show-depends", 0, NULL, 'D' },
+				   { "resolve-alias", 0, NULL, 'R' },
 				   { "dirname", 1, NULL, 'd' },
 				   { "set-version", 1, NULL, 'S' },
 				   { "config", 1, NULL, 'C' },
@@ -1453,6 +1460,9 @@ int main(int argc, char *argv[])
 			flags |= mit_ignore_loaded;
 			verbose = 1;
 			break;
+		case 'R':
+			flags |= mit_resolve_alias;
+			break;
 		case 'o':
 			newname = optarg;
 			break;
-- 
1.6.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-modules" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux