From: Jo-Philipp Wich Date: Sat, 28 Sep 2013 16:32:29 +0000 (+0000) Subject: kmodloader: use the name of the found module struct for modinfo X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fubox.git;a=commitdiff_plain;h=887256e92838ef94eeea8d7ba06ff078c7e05296;hp=187013f7ce107791c0ea891e63188d699727224a kmodloader: use the name of the found module struct for modinfo 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. --- diff --git a/kmodloader.c b/kmodloader.c index 417d121..623a169 100644 --- a/kmodloader.c +++ b/kmodloader.c @@ -583,18 +583,29 @@ static int main_lsmod(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"); - 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; } - 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; }