diff toys/other/modinfo.c @ 923:aff9fa1075eb

Upgrade modinfo to support multiple modules, and add tests, from Isaac Dunham.
author Rob Landley <rob@landley.net>
date Sun, 16 Jun 2013 02:23:59 -0500
parents ac9991f66d0d
children a81921ce4930
line wrap: on
line diff
--- a/toys/other/modinfo.c	Sat Jun 15 00:49:06 2013 -0500
+++ b/toys/other/modinfo.c	Sun Jun 16 02:23:59 2013 -0500
@@ -16,6 +16,8 @@
 
 GLOBALS(
   char *field;
+
+  long mod;
 )
 
 static char *modinfo_tags[] = {
@@ -69,10 +71,9 @@
 static int check_module(struct dirtree *new)
 {
   if (S_ISREG(new->st.st_mode)) {
-    char **ss;
+    char *s;
 
-    for (ss = toys.optargs; *ss; ss++) {
-      char *s = *ss;
+    for (s = toys.optargs[TT.mod]; *s; s++) {
       int len = 0;
 
       // The kernel treats - and _ the same, so we should too.
@@ -97,5 +98,7 @@
   if (uname(&uts) < 0) perror_exit("bad uname");
   sprintf(toybuf, "/lib/modules/%s", uts.release);
 
-  dirtree_read(toybuf, check_module);
+  for(TT.mod = 0; TT.mod<toys.optc; TT.mod++) {
+    dirtree_read(toybuf, check_module);
+  }
 }