From 3e67676617e6dc70510011f4bf004a1230b66318 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Wed, 14 Dec 2011 03:53:43 -0200 Subject: [PATCH] Log and break early if index is already open --- libkmod/libkmod.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c index acd7738..ab6415c 100644 --- a/libkmod/libkmod.c +++ b/libkmod/libkmod.c @@ -615,26 +615,29 @@ KMOD_EXPORT int kmod_load_resources(struct kmod_ctx *ctx) return -ENOENT; for (i = 0; i < ARRAY_SIZE(index_files); i++) { + const char *fn = index_files[i]; + size_t fnlen = strlen(fn); + const char *prefix = ""; + const char *suffix = ""; + if (ctx->indexes[i] == NULL) { - const char *fn = index_files[i]; - size_t fnlen = strlen(fn); - const char *prefix = ""; - const char *suffix = ""; - - if (fn[0] != '/') - prefix = ctx->dirname; - - if (fnlen < 4 || !streq(fn + fnlen - 4, ".bin")) - suffix = ".bin"; - - snprintf(path, sizeof(path), "%s/%s%s", - prefix, fn, suffix); - fn = path; - - ctx->indexes[i] = index_mm_open(ctx, fn, true); - if (ctx->indexes[i] == NULL) - goto fail; + INFO(ctx, "Index %s already loaded\n", fn); + continue; } + + if (fn[0] != '/') + prefix = ctx->dirname; + + if (fnlen < 4 || !streq(fn + fnlen - 4, ".bin")) + suffix = ".bin"; + + snprintf(path, sizeof(path), "%s/%s%s", + prefix, fn, suffix); + fn = path; + + ctx->indexes[i] = index_mm_open(ctx, fn, true); + if (ctx->indexes[i] == NULL) + goto fail; } return 0;