Chengwei Yang
2013-04-24 08:21:50 UTC
Signed-off-by: Chengwei Yang <chengwei.yang-***@public.gmane.org>
---
libkmod/libkmod.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
index 98cf15e..fd91469 100644
--- a/libkmod/libkmod.c
+++ b/libkmod/libkmod.c
@@ -882,9 +882,14 @@ KMOD_EXPORT int kmod_dump_index(struct kmod_ctx *ctx, enum kmod_index type,
return -ENOENT;
if (ctx->indexes[type] != NULL) {
- DBG(ctx, "use mmaped index '%s'\n", index_files[type].fn);
- index_mm_dump(ctx->indexes[type], fd,
+ char path[PATH_MAX];
+ snprintf(path, sizeof(path), "%s/%s.bin", ctx->dirname,
+ index_files[type].fn);
+ if (!is_cache_invalid(path, ctx->indexes_stamp[type])) {
+ DBG(ctx, "use mmaped index '%s'\n", index_files[type].fn);
+ index_mm_dump(ctx->indexes[type], fd,
index_files[type].prefix);
+ }
} else {
char fn[PATH_MAX];
struct index_file *idx;
---
libkmod/libkmod.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
index 98cf15e..fd91469 100644
--- a/libkmod/libkmod.c
+++ b/libkmod/libkmod.c
@@ -882,9 +882,14 @@ KMOD_EXPORT int kmod_dump_index(struct kmod_ctx *ctx, enum kmod_index type,
return -ENOENT;
if (ctx->indexes[type] != NULL) {
- DBG(ctx, "use mmaped index '%s'\n", index_files[type].fn);
- index_mm_dump(ctx->indexes[type], fd,
+ char path[PATH_MAX];
+ snprintf(path, sizeof(path), "%s/%s.bin", ctx->dirname,
+ index_files[type].fn);
+ if (!is_cache_invalid(path, ctx->indexes_stamp[type])) {
+ DBG(ctx, "use mmaped index '%s'\n", index_files[type].fn);
+ index_mm_dump(ctx->indexes[type], fd,
index_files[type].prefix);
+ }
} else {
char fn[PATH_MAX];
struct index_file *idx;
--
1.7.9.5
1.7.9.5