]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
Remove function kmod_resolve_alias_options()
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Tue, 13 Dec 2011 16:25:29 +0000 (14:25 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Tue, 13 Dec 2011 16:28:16 +0000 (14:28 -0200)
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
libkmod/libkmod.h
libkmod/libkmod.sym
test/test-lookup.c

index c7dd4ce1ea605181af2b9372e3c3059fc244de59..ea1c6e0a8ffca063211b7c38829e18deab44b6e2 100644 (file)
@@ -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;
index 7ce46917f544c20290332867ec852091f48865a5..b835227fbc45db2ba36d1d12fed92d4c07341cda 100644 (file)
@@ -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
index 4bff56694e3ef1956b17ebf2290a05c976f0f201..dadca4581128b31d150048de527dd81ee5ba47ff 100644 (file)
@@ -45,7 +45,6 @@ global:
         kmod_module_get_options;
         kmod_module_get_install_commands;
         kmod_module_get_remove_commands;
-        kmod_resolve_alias_options;
 local:
         *;
 };
index 34d255d6e90a9a30e161ab8e2a4f59264eeb0626..f4501b5f0f54367fdc9422a771053769dee5cfd7 100644 (file)
@@ -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);