kmodloader: use the name of the found module struct for modinfo
authorJo-Philipp Wich <jow@openwrt.org>
Sat, 28 Sep 2013 16:32:29 +0000 (16:32 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sat, 28 Sep 2013 16:37:25 +0000 (16:37 +0000)
The module .ko file might be called differently than the name used
by the kernel internally, e.g. "nls_iso8859-1.ko" is called
"nls_iso8859_1" in lsmmod. The print_modinfo() procedure expects the
filename spelling in order to successfully resolve the full module path.

After this change, "modinfo" supports printing module info even if the
user gives the kernel internal spelling instead of the file name one,
so that e.g. "modinfo "nls_iso8859_1" and "modinfo nls_iso8859-1.ko" will
both succeed.

kmodloader.c

index 417d121..623a169 100644 (file)
@@ -583,18 +583,29 @@ static int main_lsmod(int argc, char **argv)
 
 static int main_modinfo(int argc, char **argv)
 {
 
 static int main_modinfo(int argc, char **argv)
 {
-       char *module;
+       struct module *m;
+       char *name;
 
        if (argc != 2)
                return print_usage("modinfo");
 
 
        if (argc != 2)
                return print_usage("modinfo");
 
-       module = get_module_path(argv[1]);
-       if (!module) {
+       if (scan_module_folder())
+               return -1;
+
+       name = get_module_name(argv[1]);
+       m = find_module(name);
+       if (!m) {
                LOG("cannot find module - %s\n", argv[1]);
                return -1;
        }
 
                LOG("cannot find module - %s\n", argv[1]);
                return -1;
        }
 
-       print_modinfo(module);
+       name = get_module_path(m->name);
+       if (!name) {
+               LOG("cannot find path of module - %s\n", m->name);
+               return -1;
+       }
+
+       print_modinfo(name);
 
        return 0;
 }
 
        return 0;
 }