From 6bd0b8d01df7912cd6a7f209db822feff393b59f Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Wed, 7 Dec 2011 14:08:01 -0200 Subject: [PATCH] kmod_module: treat module creation by path with same names If a module with the same name already exists, try to reference it if paths are the same. Otherwise fail. --- libkmod/libkmod-module.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c index 0aee3ee..3acd5b0 100644 --- a/libkmod/libkmod-module.c +++ b/libkmod/libkmod-module.c @@ -202,7 +202,17 @@ KMOD_EXPORT int kmod_module_new_from_path(struct kmod_ctx *ctx, m = kmod_pool_get_module(ctx, name); if (m != NULL) { - free(abspath); + if (m->path == NULL) + m->path = abspath; + else if (streq(m->path, abspath)) + free(abspath); + else { + ERR(ctx, "kmod_module '%s' already exists with different path\n", + name); + free(abspath); + return -EEXIST; + } + *mod = kmod_module_ref(m); return 0; } -- 2.7.4