From: Lucas De Marchi Date: Wed, 7 Dec 2011 16:08:01 +0000 (-0200) Subject: kmod_module: treat module creation by path with same names X-Git-Tag: v1~73 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6bd0b8d01df7912cd6a7f209db822feff393b59f;p=platform%2Fupstream%2Fkmod.git 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. --- 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; }