summaryrefslogtreecommitdiff
path: root/libkmod/libkmod-config.c
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@profusion.mobi>2011-11-29 18:48:02 -0200
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2011-11-29 18:48:02 -0200
commit81cf2060e067240ad8c4b9493e1fc1df3d12c956 (patch)
tree91bec8dfbd4a12fab91079fed6123281633549e2 /libkmod/libkmod-config.c
parent7c2ab358fd1b05be52a3a1d23fe74c7d101a69f9 (diff)
downloadkmod-81cf2060e067240ad8c4b9493e1fc1df3d12c956.tar.gz
kmod-81cf2060e067240ad8c4b9493e1fc1df3d12c956.tar.bz2
kmod-81cf2060e067240ad8c4b9493e1fc1df3d12c956.zip
Parse blacklists in config files
Diffstat (limited to 'libkmod/libkmod-config.c')
-rw-r--r--libkmod/libkmod-config.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/libkmod/libkmod-config.c b/libkmod/libkmod-config.c
index 9cc024c..46ea24f 100644
--- a/libkmod/libkmod-config.c
+++ b/libkmod/libkmod-config.c
@@ -70,6 +70,28 @@ static struct kmod_list *free_alias(struct kmod_ctx *ctx, struct kmod_list *l)
return kmod_list_remove(l);
}
+static struct kmod_list *add_blacklist(struct kmod_ctx *ctx,
+ struct kmod_list *blacklists,
+ const char *modname)
+{
+ struct kmod_blacklist *blacklist;
+ char *p;
+
+ DBG(ctx, "modname=%s\n", modname);
+
+ p = strdup(modname);
+
+ return kmod_list_append(blacklists, p);
+}
+
+static struct kmod_list *free_blacklist(struct kmod_ctx *ctx,
+ struct kmod_list *l)
+{
+ free(l->data);
+ return kmod_list_remove(l);
+}
+
+
int kmod_parse_config_file(struct kmod_ctx *ctx, const char *filename,
struct kmod_config *config)
{
@@ -102,13 +124,21 @@ int kmod_parse_config_file(struct kmod_ctx *ctx, const char *filename,
config->aliases = add_alias(ctx, config->aliases,
alias, modname);
+ } else if (!strcmp(cmd, "blacklist")) {
+ char *modname = strtok(NULL, "\t ");
+
+ if (modname == NULL)
+ goto syntax_error;
+
+ config->blacklists = add_blacklist(ctx,
+ config->blacklists, modname);
} else if (!strcmp(cmd, "include") || !strcmp(cmd, "options")
|| !strcmp(cmd, "install")
- || !strcmp(cmd, "blacklist")
|| !strcmp(cmd, "remove")
|| !strcmp(cmd, "softdep")
|| !strcmp(cmd, "config")) {
- DBG(ctx, "Command %s not implemented yet\n", cmd);
+ INFO(ctx, "%s: command %s not implemented yet\n",
+ filename, cmd);
} else {
syntax_error:
ERR(ctx, "%s line %u: ignoring bad line starting with '%s'\n",
@@ -128,6 +158,9 @@ void kmod_free_config(struct kmod_ctx *ctx, struct kmod_config *config)
{
while (config->aliases)
config->aliases = free_alias(ctx, config->aliases);
+
+ while (config->blacklists)
+ config->blacklists = free_blacklist(ctx, config->blacklists);
}
static bool conf_files_filter(struct kmod_ctx *ctx, const char *path,