From 887256e92838ef94eeea8d7ba06ff078c7e05296 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sat, 28 Sep 2013 16:32:29 +0000 Subject: [PATCH] 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. --- kmodloader.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) 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; } -- 2.30.2