Rework bsopen() handling of compression/hash algos - 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 eb053ea02848331d866e5fd13be344b5029eb9d3 DIR parent 98a7453a356991af73217db01723e0cb5de0c2aa HTML Author: sin <sin@2f30.org> Date: Thu, 25 Apr 2019 13:54:10 +0100 Rework bsopen() handling of compression/hash algos Diffstat: M bstorage.c | 35 ++----------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) --- DIR diff --git a/bstorage.c b/bstorage.c @@ -42,9 +42,6 @@ #define BDTYPE 0x100 #define BDSIZE (8 + 8 + 8 + (MDSIZE)) -#define CSNAPPYTYPE 0 -#define HBLAKE2BTYPE 0 - extern int pack(unsigned char *dst, char *fmt, ...); extern int unpack(unsigned char *src, char *fmt, ...); @@ -370,7 +367,6 @@ bsopen(struct bctx *bctx, char *path, int flags, int mode, struct bparam *bpar) { struct sctx *sctx; struct bhdr *bhdr; - char **algo; int fd, calgo, halgo; fd = open(path, flags, mode); @@ -399,37 +395,10 @@ bsopen(struct bctx *bctx, char *path, int flags, int mode, struct bparam *bpar) return -1; } - /* Get compression algorithm */ calgo = (bhdr->flags >> CALGOSHIFT) & CALGOMASK; - for (algo = ctbl; *algo; algo++) { - uint64_t v = algo - ctbl; - - if (v == calgo) { - bpar->calgo = ctbl[v]; - break; - } - } - if (*algo == NULL) { - free(sctx); - close(fd); - return -1; - } - - /* Get hash algorithm */ + bpar->calgo = ctbl[calgo]; halgo = (bhdr->flags >> CALGOSHIFT) & CALGOMASK; - for (algo = htbl; *algo; algo++) { - uint64_t v = algo - htbl; - - if (v == halgo) { - bpar->halgo = htbl[v]; - break; - } - } - if (*algo == NULL) { - free(sctx); - close(fd); - return -1; - } + bpar->halgo = ctbl[halgo]; sctx->fd = fd; sctx->rdonly = flags == O_RDONLY;