From 25c0543ff618102fde6e0b35318924f065762968 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Tue, 13 Dec 2011 14:25:29 -0200 Subject: [PATCH] Remove function kmod_resolve_alias_options() Remove function kmod_resolve_alias_options since it's not needed anymore. Test is using the following configuration file: alias blablabla ac options ac test=1 options blablabla test=2 Lookup test by module name: $ ./test/test-lookup ac libkmod version 1 Alias: 'ac' Modules matching: ac options: 'test=1' Lookup test by alias: $ ./test/test-lookup blablabla libkmod version 1 Alias: 'blablabla' Modules matching: ac options: 'test=1 test=2' --- libkmod/libkmod.c | 91 ----------------------------------------------------- libkmod/libkmod.h | 2 -- libkmod/libkmod.sym | 1 - test/test-lookup.c | 7 ----- 4 files changed, 101 deletions(-) diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c index c7dd4ce..ea1c6e0 100644 --- a/libkmod/libkmod.c +++ b/libkmod/libkmod.c @@ -645,97 +645,6 @@ KMOD_EXPORT void kmod_unload_resources(struct kmod_ctx *ctx) } } -KMOD_EXPORT int kmod_resolve_alias_options(struct kmod_ctx *ctx, - const char *given_alias, - char **options) -{ - struct kmod_list *modules = NULL, *l; - char alias[NAME_MAX]; - char *opts = NULL; - size_t optslen = 0; - int err; - - if (ctx == NULL || options == NULL) - return -ENOENT; - - if (alias_normalize(given_alias, alias, NULL) < 0) - return -EINVAL; - - err = kmod_module_new_from_lookup(ctx, alias, &modules); - if (err < 0) - return err; - - kmod_list_foreach(l, modules) { - const char *str = kmod_module_get_options(l->data); - size_t len; - void *tmp; - - if (str == NULL) - continue; - len = strlen(str); - - tmp = realloc(opts, optslen + len + 2); - if (tmp == NULL) - goto failed; - opts = tmp; - if (optslen > 0) { - opts[optslen] = ' '; - optslen++; - } - memcpy(opts + optslen, str, len); - optslen += len; - opts[optslen] = '\0'; - } - - kmod_list_foreach(l, ctx->config->options) { - const struct kmod_list *ml; - const char *modname = kmod_option_get_modname(l); - const char *str; - bool already_done = false; - size_t len; - void *tmp; - - if (fnmatch(modname, alias, 0) != 0) - continue; - - kmod_list_foreach(ml, modules) { - const char *mln = kmod_module_get_name(ml->data); - if (fnmatch(modname, mln, 0) == 0) { - already_done = true; - break; - } - } - if (already_done) - continue; - - str = kmod_option_get_options(l); - len = strlen(str); - tmp = realloc(opts, optslen + len + 2); - if (tmp == NULL) - goto failed; - opts = tmp; - if (optslen > 0) { - opts[optslen] = ' '; - optslen++; - } - memcpy(opts + optslen, str, len); - optslen += len; - opts[optslen] = '\0'; - } - - DBG(ctx, "alias=%s options='%s'\n", alias, opts); - kmod_module_unref_list(modules); - *options = opts; - return 0; - -failed: - kmod_module_unref_list(modules); - free(opts); - ERR(ctx, "out of memory\n"); - *options = NULL; - return -ENOMEM; -} - const struct kmod_list *kmod_get_options(const struct kmod_ctx *ctx) { return ctx->config->options; diff --git a/libkmod/libkmod.h b/libkmod/libkmod.h index 7ce4691..b835227 100644 --- a/libkmod/libkmod.h +++ b/libkmod/libkmod.h @@ -131,8 +131,6 @@ const char *kmod_module_get_options(const struct kmod_module *mod); const char *kmod_module_get_install_commands(const struct kmod_module *mod); const char *kmod_module_get_remove_commands(const struct kmod_module *mod); -int kmod_resolve_alias_options(struct kmod_ctx *ctx, const char *alias, char **options); - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/libkmod/libkmod.sym b/libkmod/libkmod.sym index 4bff566..dadca45 100644 --- a/libkmod/libkmod.sym +++ b/libkmod/libkmod.sym @@ -45,7 +45,6 @@ global: kmod_module_get_options; kmod_module_get_install_commands; kmod_module_get_remove_commands; - kmod_resolve_alias_options; local: *; }; diff --git a/test/test-lookup.c b/test/test-lookup.c index 34d255d..f4501b5 100644 --- a/test/test-lookup.c +++ b/test/test-lookup.c @@ -33,7 +33,6 @@ int main(int argc, char *argv[]) const char *alias = NULL; struct kmod_ctx *ctx; struct kmod_list *list = NULL, *l; - char *options; int load_resources = 0; int err; @@ -109,12 +108,6 @@ int main(int argc, char *argv[]) kmod_module_unref(mod); } - err = kmod_resolve_alias_options(ctx, alias, &options); - if (err == 0) { - printf("Alias options: '%s'\n", options); - free(options); - } - kmod_module_unref_list(list); kmod_unref(ctx); -- 2.7.4