dedup

deduplicating backup program
git clone git://git.2f30.org/dedup
Log | Files | Refs | README | LICENSE

commit 13bf2f947a35134d17043151e3a07f7aa86155b1
parent bea0c2a2d0e5dd3b04fd7888bcaf6ab3eb87fa79
Author: sin <sin@2f30.org>
Date:   Sun,  3 Mar 2019 13:24:04 +0000

Store store compression status in the store header

Diffstat:
Mdedup.c | 10++++++++++
Mdedup.h | 3+++
2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/dedup.c b/dedup.c @@ -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 diff --git a/dedup.h b/dedup.h @@ -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;