tStore store compression status in the store header - dedup - deduplicating backup program
 (HTM) git clone git://git.z3bra.org/dedup.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 13bf2f947a35134d17043151e3a07f7aa86155b1
 (DIR) parent bea0c2a2d0e5dd3b04fd7888bcaf6ab3eb87fa79
 (HTM) Author: sin <sin@2f30.org>
       Date:   Sun,  3 Mar 2019 13:24:04 +0000
       
       Store store compression status in the store header
       
       Diffstat:
         M dedup.c                             |      10 ++++++++++
         M dedup.h                             |       3 +++
       
       2 files changed, 13 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/dedup.c b/dedup.c
       t@@ -511,15 +511,25 @@ static void
        init_blk_hdr(void)
        {
                blk_hdr.flags = (VER_MAJ << VER_MAJ_SHIFT) | VER_MIN;
       +        blk_hdr.flags |= compr_enabled << COMPR_ENABLED_SHIFT;
                blk_hdr.size = BLK_HDR_SIZE;
        }
        
        static void
        load_blk_hdr(void)
        {
       +        uint64_t v;
       +
                xlseek(sfd, 0, SEEK_SET);
                read_blk_hdr(sfd, &blk_hdr);
                match_ver(blk_hdr.flags);
       +
       +        v = blk_hdr.flags >> COMPR_ENABLED_SHIFT;
       +        v &= COMPR_ENABLED_MASK;
       +        if (v != compr_enabled)
       +                errx(1, "store is %s but dedup was invoked %s",
       +                     v ? "compressed" : "not compressed",
       +                     compr_enabled ? "with compression" : "without compression");
        }
        
        static void
 (DIR) diff --git a/dedup.h b/dedup.h
       t@@ -23,6 +23,9 @@
        #define VER_MAJ_SHIFT        8
        #define VER_MAJ_MASK        0xff
        
       +#define COMPR_ENABLED_SHIFT        16
       +#define COMPR_ENABLED_MASK        0x1
       +
        struct cache;
        struct chunker;