changeset 933:a81921ce4930

Patch that assumes that the presence of the string ".ko" indicates use of a path to a module (*.ko.xz and similar included, but not supported).
author Isaac Dunham <idunham@lavabit.com>
date Sun, 23 Jun 2013 14:02:16 -0500
parents 58b5263d63bf
children d0ab54f62346
files toys/other/modinfo.c
diffstat 1 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/toys/other/modinfo.c	Sat Jun 22 23:30:07 2013 -0500
+++ b/toys/other/modinfo.c	Sun Jun 23 14:02:16 2013 -0500
@@ -38,7 +38,7 @@
   xputc((toys.optflags & FLAG_0) ? 0 : '\n');
 }
 
-static void modinfo_file(struct dirtree *dir)
+static int modinfo_file(struct dirtree *dir)
 {
   int fd, len, i;
   char *buf, *pos, *full_name;
@@ -49,8 +49,10 @@
   free(full_name);
 
   len = fdlength(fd);
-  if (!(buf = mmap(0, len, PROT_READ, MAP_SHARED, fd, 0)))
-    perror_exit("mmap %s", full_name);
+  if (!(buf = mmap(0, len, PROT_READ, MAP_SHARED, fd, 0))) {
+    perror_msg("mmap %s", full_name);
+    return 1;
+  } 
 
   for (pos = buf; pos < buf+len; pos++) {
     if (*pos) continue;
@@ -66,6 +68,7 @@
 
   munmap(buf, len);
   close(fd);
+  return 0;
 }
 
 static int check_module(struct dirtree *new)
@@ -99,6 +102,10 @@
   sprintf(toybuf, "/lib/modules/%s", uts.release);
 
   for(TT.mod = 0; TT.mod<toys.optc; TT.mod++) {
-    dirtree_read(toybuf, check_module);
+    if (strstr(toys.optargs[TT.mod], ".ko")) { 
+      dirtree_read(toys.optargs[TT.mod], modinfo_file);
+    } else {
+      dirtree_read(toybuf, check_module);
+    }
   }
 }