diff options
author | Alexey Gladkov <gladkov.alexey@gmail.com> | 2019-11-08 18:25:23 +0100 |
---|---|---|
committer | Lucas De Marchi <lucas.demarchi@intel.com> | 2019-12-18 16:57:14 -0800 |
commit | e7e2cb61fa9f1db3429d91ef6accff549500d268 (patch) | |
tree | 3237de2619201fcff7a8dea3c72fa24eac7095f0 /tools | |
parent | b866b2165ae6cf18fb26b635f4a7ee57c0334731 (diff) | |
download | kmod-e7e2cb61fa9f1db3429d91ef6accff549500d268.tar.gz kmod-e7e2cb61fa9f1db3429d91ef6accff549500d268.tar.bz2 kmod-e7e2cb61fa9f1db3429d91ef6accff549500d268.zip |
modinfo: Show information about built-in modules
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/modinfo.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/tools/modinfo.c b/tools/modinfo.c index 86ac04b..0231bb0 100644 --- a/tools/modinfo.c +++ b/tools/modinfo.c @@ -172,18 +172,33 @@ static int modinfo_do(struct kmod_module *mod) { struct kmod_list *l, *list = NULL; struct param *params = NULL; - int err; + int err, is_builtin; + const char *filename = kmod_module_get_path(mod); + + is_builtin = (filename == NULL); + + if (is_builtin) { + printf("%-16s%s%c", "name:", kmod_module_get_name(mod), separator); + filename = "(builtin)"; + } if (field != NULL && streq(field, "filename")) { - printf("%s%c", kmod_module_get_path(mod), separator); + printf("%s%c", filename, separator); return 0; } else if (field == NULL) { printf("%-16s%s%c", "filename:", - kmod_module_get_path(mod), separator); + filename, separator); } err = kmod_module_get_info(mod, &list); if (err < 0) { + if (is_builtin && err == -ENOENT) { + /* + * This is an old kernel that does not have a file + * with information about built-in modules. + */ + return 0; + } ERR("could not get modinfo from '%s': %s\n", kmod_module_get_name(mod), strerror(-err)); return err; @@ -276,7 +291,7 @@ static int modinfo_path_do(struct kmod_ctx *ctx, const char *path) static int modinfo_alias_do(struct kmod_ctx *ctx, const char *alias) { - struct kmod_list *l, *filtered, *list = NULL; + struct kmod_list *l, *list = NULL; int err = kmod_module_new_from_lookup(ctx, alias, &list); if (err < 0) { ERR("Module alias %s not found.\n", alias); @@ -288,26 +303,14 @@ static int modinfo_alias_do(struct kmod_ctx *ctx, const char *alias) return -ENOENT; } - err = kmod_module_apply_filter(ctx, KMOD_FILTER_BUILTIN, list, &filtered); - kmod_module_unref_list(list); - if (err < 0) { - ERR("Failed to filter list: %m\n"); - return err; - } - - if (filtered == NULL) { - ERR("Module %s not found.\n", alias); - return -ENOENT; - } - - kmod_list_foreach(l, filtered) { + kmod_list_foreach(l, list) { struct kmod_module *mod = kmod_module_get_module(l); int r = modinfo_do(mod); kmod_module_unref(mod); if (r < 0) err = r; } - kmod_module_unref_list(filtered); + kmod_module_unref_list(list); return err; } |