]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Include manifest version in the direct mode hash
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 2 Mar 2013 20:17:17 +0000 (21:17 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 2 Mar 2013 20:17:17 +0000 (21:17 +0100)
This makes manifest file names unique per manifest version, thus avoiding
ccache versions with different manifest versions overwriting each other's
manifests.

ccache.c
manifest.c
manifest.h

index fd1a4995929a71feffb6f003024786564b656c4f..377bfa1d73ce6364155678dbc0ef532f653c51aa 100644 (file)
--- 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. */
index af5c595b0c767601d813c2e7665299f3ccd387b3..1327170d800e470d3ab8e278500018cd5f438bca 100644 (file)
@@ -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);
 
index a0c2a146fc9bf3792aa640f93dd54420a170f6d1..e116c3491014b2ca73edc6079e3081248ed6428a 100644 (file)
@@ -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);