From: Joel Rosdahl Date: Sat, 2 Mar 2013 20:17:17 +0000 (+0100) Subject: Include manifest version in the direct mode hash X-Git-Tag: v3.2~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=273fea080ac1d55137965c9cfc73adc5b86780dd;p=thirdparty%2Fccache.git Include manifest version in the direct mode hash This makes manifest file names unique per manifest version, thus avoiding ccache versions with different manifest versions overwriting each other's manifests. --- diff --git a/ccache.c b/ccache.c index fd1a49959..377bfa1d7 100644 --- a/ccache.c +++ b/ccache.c @@ -1093,6 +1093,11 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode) struct file_hash *object_hash = NULL; char *p; + if (direct_mode) { + hash_delimiter(hash, "manifest version"); + hash_int(hash, MANIFEST_VERSION); + } + /* first the arguments */ for (i = 1; i < args->argc; i++) { /* -L doesn't affect compilation. */ diff --git a/manifest.c b/manifest.c index af5c595b0..1327170d8 100644 --- a/manifest.c +++ b/manifest.c @@ -67,7 +67,6 @@ */ static const uint32_t MAGIC = 0x63436d46U; -static const uint8_t VERSION = 1; static const uint32_t MAX_MANIFEST_ENTRIES = 100; #define ccache_static_assert(e) \ @@ -251,7 +250,7 @@ read_manifest(gzFile f) return NULL; } READ_BYTE(mf->version); - if (mf->version != VERSION) { + if (mf->version != MANIFEST_VERSION) { cc_log("Manifest file has unknown version %u", mf->version); free_manifest(mf); return NULL; @@ -340,7 +339,7 @@ write_manifest(gzFile f, const struct manifest *mf) uint16_t i, j; WRITE_INT(4, MAGIC); - WRITE_INT(1, VERSION); + WRITE_INT(1, MANIFEST_VERSION); WRITE_INT(1, 16); WRITE_INT(2, 0); diff --git a/manifest.h b/manifest.h index a0c2a146f..e116c3491 100644 --- a/manifest.h +++ b/manifest.h @@ -5,6 +5,8 @@ #include "hashutil.h" #include "hashtable.h" +#define MANIFEST_VERSION 1 + struct file_hash *manifest_get(struct conf *conf, const char *manifest_path); bool manifest_put(const char *manifest_path, struct file_hash *object_hash, struct hashtable *included_files);