From 0d46743ca50e6005843d13b012db96ae7e7b2c57 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Sat, 31 Dec 2011 11:15:52 -0200 Subject: [PATCH] Move function to the right place --- libkmod/libkmod-module.c | 61 ++++++++++++++++++++++++++++++++++++++++ libkmod/libkmod.c | 56 ------------------------------------ 2 files changed, 61 insertions(+), 56 deletions(-) diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c index 8e4a26d..a94c6e2 100644 --- a/libkmod/libkmod-module.c +++ b/libkmod/libkmod-module.c @@ -500,6 +500,67 @@ KMOD_EXPORT int kmod_module_unref_list(struct kmod_list *list) return 0; } +/** + * kmod_module_get_filtered_blacklist: + * @ctx: kmod library context + * @input: list of kmod_module to be filtered with blacklist + * @output: where to save the new list + * + * Given a list @input, this function filter it out with config's blacklist + * ans save it in @output. + * + * Returns: 0 on success or < 0 otherwise. @output is saved with the updated + * list. + */ +KMOD_EXPORT int kmod_module_get_filtered_blacklist(const struct kmod_ctx *ctx, + const struct kmod_list *input, + struct kmod_list **output) +{ + const struct kmod_list *li; + const struct kmod_list *blacklist; + + if (ctx == NULL || output == NULL) + return -ENOENT; + + *output = NULL; + if (input == NULL) + return 0; + + blacklist = kmod_get_blacklists(ctx); + kmod_list_foreach(li, input) { + struct kmod_module *mod = li->data; + const struct kmod_list *lb; + struct kmod_list *node; + bool filtered = false; + + kmod_list_foreach(lb, blacklist) { + const char *name = lb->data; + + if (streq(name, kmod_module_get_name(mod))) { + filtered = true; + break; + } + } + + if (filtered) + continue; + + node = kmod_list_append(*output, mod); + if (node == NULL) + goto fail; + + *output = node; + kmod_module_ref(mod); + } + + return 0; + +fail: + kmod_module_unref_list(*output); + *output = NULL; + return -ENOMEM; +} + static const struct kmod_list *module_get_dependencies_noref(const struct kmod_module *mod) { if (!mod->init.dep) { diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c index 1090507..163de3f 100644 --- a/libkmod/libkmod.c +++ b/libkmod/libkmod.c @@ -610,62 +610,6 @@ int kmod_lookup_alias_from_commands(struct kmod_ctx *ctx, const char *name, return nmatch; } -/** - * kmod_module_get_filtered_blacklist: - * @ctx: kmod library context - * @input: list of kmod_module to be filtered with blacklist - * @output: where to save the new list - * - * Given a list @input, this function filter it out with config's blacklist - * ans save it in @output. - * - * Returns: 0 on success or < 0 otherwise. @output is saved with the updated - * list. - */ -KMOD_EXPORT int kmod_module_get_filtered_blacklist(const struct kmod_ctx *ctx, - const struct kmod_list *input, - struct kmod_list **output) -{ - const struct kmod_config *config; - const struct kmod_list *li; - - if (ctx == NULL || output == NULL) - return -ENOENT; - - *output = NULL; - if (input == NULL) - return 0; - - config = ctx->config; - kmod_list_foreach(li, input) { - struct kmod_module *mod = li->data; - const struct kmod_list *lb; - struct kmod_list *node; - bool filtered = false; - kmod_list_foreach(lb, config->blacklists) { - const char *name = lb->data; - if (streq(name, kmod_module_get_name(mod))) { - filtered = true; - break; - } - } - if (filtered) - continue; - - node = kmod_list_append(*output, mod); - if (node == NULL) - goto fail; - *output = node; - kmod_module_ref(mod); - } - return 0; - -fail: - kmod_module_unref_list(*output); - *output = NULL; - return -ENOMEM; -} - /** * kmod_load_resources: * @ctx: kmod library context