Shorten type width to 16 bits and mark rest as reserved - dedup - deduplicating backup program HTML git clone git://bitreich.org/dedup/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/dedup/ DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit bb81bcb6bd4b4bf7dbe36d2a47087dec0c58f812 DIR parent 8728669764d059ab08e07111ca630f7fa313e51d HTML Author: sin <sin@2f30.org> Date: Wed, 1 May 2019 14:33:42 +0100 Shorten type width to 16 bits and mark rest as reserved Diffstat: M bcompress.c | 11 +++++++---- M bstorage.c | 9 ++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) --- DIR diff --git a/bcompress.c b/bcompress.c @@ -45,12 +45,13 @@ static struct bops bops = { /* Compression layer context */ struct cctx { - uint64_t type; /* compression algorithm type for new blocks */ + int type; /* compression algorithm type for new blocks */ }; /* Compression descriptor */ struct cd { - uint64_t type; /* compression algorithm type */ + uint16_t type; /* compression algorithm type */ + uint8_t reserved[6]; uint64_t size; }; @@ -60,8 +61,9 @@ unpackcd(void *buf, struct cd *cd) { int n; - n = unpack(buf, "qq", + n = unpack(buf, "s'6q", &cd->type, + cd->reserved, &cd->size); assert(n == CDSIZE); @@ -74,8 +76,9 @@ packcd(void *buf, struct cd *cd) { int n; - n = pack(buf, "qq", + n = pack(buf, "s'6q", cd->type, + cd->reserved, cd->size); assert(n == CDSIZE); DIR diff --git a/bstorage.c b/bstorage.c @@ -87,7 +87,8 @@ struct bhdr { /* Block descriptor */ struct bd { - uint64_t type; + uint16_t type; + uint8_t reserved[6]; uint64_t offset; /* offset of block */ uint64_t size; /* size of block */ uint64_t refcnt; @@ -194,9 +195,10 @@ unpackbd(int fd, struct bd *bd) if (xread(fd, buf, sizeof(buf)) != sizeof(buf)) return -1; - snprintf(fmt, sizeof(fmt), "qqqq'%d", MDSIZE); + snprintf(fmt, sizeof(fmt), "s'6qqq'%d", MDSIZE); n = unpack(buf, fmt, &bd->type, + bd->reserved, &bd->offset, &bd->size, &bd->refcnt, @@ -214,9 +216,10 @@ packbd(int fd, struct bd *bd) char fmt[BUFSIZ]; int n; - snprintf(fmt, sizeof(fmt), "qqqq'%d", MDSIZE); + snprintf(fmt, sizeof(fmt), "s'6qqq'%d", MDSIZE); n = pack(buf, fmt, bd->type, + bd->reserved, bd->offset, bd->size, bd->refcnt,