Re: [PATCH] Fix: check cache before dump it

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 24, 2013 at 5:21 AM, Chengwei Yang <chengwei.yang@xxxxxxxxx> wrote:
> Signed-off-by: Chengwei Yang <chengwei.yang@xxxxxxxxx>
> ---
>  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);
> +               }

why is this any different from the other functions that use the mmaped
index? If the user is not using kmod_validate_resources then it's
better to not call kmod_load_resources() and use the other
implementation that doesn't mmap the index.

Lucas De Marchi
--
To unsubscribe from this list: send the line "unsubscribe linux-modules" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux