From: Gustavo Sverzut Barbieri Date: Mon, 19 Dec 2011 14:45:22 +0000 (-0200) Subject: kmod-modprobe: implement --dump-modversions X-Git-Tag: v2~39 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0e3e2f436e64d27e237cf57cd30306589f390492;p=thirdparty%2Fkmod.git kmod-modprobe: implement --dump-modversions --- diff --git a/TODO b/TODO index e6451af9..0708a7e7 100644 --- a/TODO +++ b/TODO @@ -18,7 +18,6 @@ Features: * Add functions list all modules known by modules.dep * provide 1:1 compatibility with module-init-tools's modprobe - - show modversions (needs elf manipulation) - dump configuration * provide modules.archive, a cache file with all modules compressed diff --git a/tools/kmod-modprobe.c b/tools/kmod-modprobe.c index 4680a580..f7fbaff2 100644 --- a/tools/kmod-modprobe.c +++ b/tools/kmod-modprobe.c @@ -232,15 +232,30 @@ static int show_config(struct kmod_ctx *ctx) static int show_modversions(struct kmod_ctx *ctx, const char *filename) { - ERR("TODO - modversions is missing in kmod.\n"); - /* - needs: - struct kmod_list *kmod_module_get_modversions(struct kmod_module *mod); - kmod_module_modversion_get_address() [needs better naming?] - kmod_module_modversion_get_name() [needs better naming?] - kmod_module_modversion_unref_list() - */ - return -ENOENT; + struct kmod_list *l, *list = NULL; + struct kmod_module *mod; + int err = kmod_module_new_from_path(ctx, filename, &mod); + if (err < 0) { + LOG("Module %s not found.\n", filename); + return err; + } + + err = kmod_module_get_versions(mod, &list); + if (err < 0) { + LOG("Could not get modversions of %s: %s\n", + filename, strerror(-err)); + kmod_module_unref(mod); + return err; + } + + kmod_list_foreach(l, list) { + const char *symbol = kmod_module_version_get_symbol(l); + uint64_t crc = kmod_module_version_get_crc(l); + printf("0x%08"PRIx64"\t%s\n", crc, symbol); + } + kmod_module_versions_free_list(list); + kmod_module_unref(mod); + return 0; } static int command_do(struct kmod_module *module, const char *type, const char *command, const char *cmdline_opts)