]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
index: save timestamp of each loaded index
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Sat, 31 Dec 2011 20:53:24 +0000 (18:53 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Sun, 1 Jan 2012 08:18:16 +0000 (06:18 -0200)
libkmod/libkmod-index.c
libkmod/libkmod-index.h
libkmod/libkmod.c

index 580b0599499fb9ebe018817b4ed6ea19f13b24e7..db1ae4d62b6fb16c1c25d6f099aae38866ce80f1 100644 (file)
@@ -716,7 +716,7 @@ static void index_mm_free_node(struct index_mm_node *node)
 }
 
 struct index_mm *index_mm_open(struct kmod_ctx *ctx, const char *filename,
-                                                               bool populate)
+                               bool populate, unsigned long long *stamp)
 {
        int fd;
        int flags;
@@ -775,6 +775,8 @@ struct index_mm *index_mm_open(struct kmod_ctx *ctx, const char *filename,
        idx->ctx = ctx;
        close(fd);
 
+       *stamp = ts_usec(&st.st_mtim);
+
        return idx;
 
 fail:
index c5ae89d69705a33ced7548ef57277b2c17238bb0..3081dbe8514c8b11fb83e57e92997c3af9b777e6 100644 (file)
@@ -121,7 +121,7 @@ void index_values_free(struct index_value *values);
 /* Implementation using mmap */
 struct index_mm;
 struct index_mm *index_mm_open(struct kmod_ctx *ctx, const char *filename,
-                                                               bool populate);
+                               bool populate, unsigned long long *stamp);
 void index_mm_close(struct index_mm *index);
 char *index_mm_search(struct index_mm *idx, const char *key);
 struct index_value *index_mm_searchwild(struct index_mm *idx, const char *key);
index b4db9a517351b1f0c63da5227bfa99a6e35d9513..794cc54eb23df2c78ada0191353e9fa84701fa0b 100644 (file)
@@ -82,6 +82,7 @@ struct kmod_ctx {
        struct kmod_config *config;
        struct hash *modules_by_name;
        struct index_mm *indexes[_KMOD_INDEX_LAST];
+       unsigned long long indexes_stamp[_KMOD_INDEX_LAST];
 };
 
 void kmod_log(const struct kmod_ctx *ctx,
@@ -383,7 +384,7 @@ static int kmod_lookup_alias_from_alias_bin(struct kmod_ctx *ctx,
                        index_files[index_number], name);
                realnames = index_mm_searchwild(ctx->indexes[index_number],
                                                                        name);
-       } else{
+       } else {
                char fn[PATH_MAX];
 
                snprintf(fn, sizeof(fn), "%s/%s.bin", ctx->dirname,
@@ -642,7 +643,8 @@ KMOD_EXPORT int kmod_load_resources(struct kmod_ctx *ctx)
 
                snprintf(path, sizeof(path), "%s/%s.bin", ctx->dirname,
                                                        index_files[i]);
-               ctx->indexes[i] = index_mm_open(ctx, path, true);
+               ctx->indexes[i] = index_mm_open(ctx, path, true,
+                                               &ctx->indexes_stamp[i]);
                if (ctx->indexes[i] == NULL)
                        goto fail;
        }
@@ -680,6 +682,7 @@ KMOD_EXPORT void kmod_unload_resources(struct kmod_ctx *ctx)
                if (ctx->indexes[i] != NULL) {
                        index_mm_close(ctx->indexes[i]);
                        ctx->indexes[i] = NULL;
+                       ctx->indexes_stamp[i] = 0;
                }
        }
 }