dedup

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

commit bea0c2a2d0e5dd3b04fd7888bcaf6ab3eb87fa79
parent 97d999a1a20a8e4fbe6a3c93825e94b54e4b071a
Author: sin <sin@2f30.org>
Date:   Sun,  3 Mar 2019 13:18:16 +0000

Introduce shift/mask definitions for maj/min version

Diffstat:
Mdedup.c | 8++++----
Mdedup.h | 4++++
2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/dedup.c b/dedup.c @@ -456,8 +456,8 @@ match_ver(uint64_t v) { uint8_t maj, min; - min = v & 0xff; - maj = (v >> 8) & 0xff; + min = v & VER_MIN_MASK; + maj = (v >> VER_MAJ_SHIFT) & VER_MAJ_MASK; if (maj == VER_MAJ && min == VER_MIN) return; errx(1, "format version mismatch: expected %u.%u but got %u.%u", @@ -510,7 +510,7 @@ save_cache(void) static void init_blk_hdr(void) { - blk_hdr.flags = (VER_MAJ << 8) | VER_MIN; + blk_hdr.flags = (VER_MAJ << VER_MAJ_SHIFT) | VER_MIN; blk_hdr.size = BLK_HDR_SIZE; } @@ -532,7 +532,7 @@ save_blk_hdr(void) static void init_snap_hdr(void) { - snap_hdr.flags = (VER_MAJ << 8) | VER_MIN; + snap_hdr.flags = (VER_MAJ << VER_MAJ_SHIFT) | VER_MIN; snap_hdr.size = SNAP_HDR_SIZE; snap_hdr.st.min_blk_size = compr_size(BLKSIZE_MAX); } diff --git a/dedup.h b/dedup.h @@ -19,6 +19,10 @@ #define VER_MIN 2 #define VER_MAJ 0 +#define VER_MIN_MASK 0xff +#define VER_MAJ_SHIFT 8 +#define VER_MAJ_MASK 0xff + struct cache; struct chunker;