dedup

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

commit 08ce46a1676cb97679211c88693d6687ec02d4be
parent c52bbd0d5dd0fb73d5c2c95aaa9734aea1951081
Author: sin <sin@2f30.org>
Date:   Sat, 13 Apr 2019 10:00:46 +0100

Print repo hash/compression algorithm in verbose mode

Diffstat:
Mcompress.c | 13+++++++++++++
Mdedup.c | 8++++++++
Mdedup.h | 2++
Mhash.c | 13+++++++++++++
4 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/compress.c b/compress.c @@ -98,3 +98,16 @@ compr_name2type(char *name) return -1; return algo->type; } + +const char * +compr_type2name(int type) +{ + struct algomap *algo; + + for (algo = &algomap[0]; algo->name != NULL; algo++) + if (algo->type == type) + break; + if (algo->name == NULL) + return NULL; + return algo->name; +} diff --git a/dedup.c b/dedup.c @@ -473,12 +473,20 @@ load_blk_hdr(void) if (compr_algo < 0 || compr_algo >= NR_COMPRS) errx(1, "unsupported compression algorithm: %d", compr_algo); + if (verbose > 0) + fprintf(stderr, "Compression algorithm: %s\n", + compr_type2name(compr_algo)); + v = blk_hdr.flags >> HASH_ALGO_SHIFT; v &= HASH_ALGO_MASK; hash_algo = v; if (hash_algo < 0 || hash_algo >= NR_HASHES) errx(1, "unsupported hash algorithm: %d", hash_algo); + + if (verbose > 0) + fprintf(stderr, "Hash algorithm: %s\n", + hash_type2name(hash_algo)); } static void diff --git a/dedup.h b/dedup.h @@ -144,6 +144,7 @@ size_t decompr(struct compr_ctx *ctx, const void *in, void *out, size_t insize, size_t outsize); int compr_final(struct compr_ctx *ctx); int compr_name2type(char *name); +const char *compr_type2name(int type); /* hash-blake2b.c */ int blake2bi(struct hash_ctx *ctx, size_t n); @@ -170,6 +171,7 @@ int hash_init(struct hash_ctx *ctx, int type, size_t n); int hash_update(struct hash_ctx *ctx, const void *buf, size_t n); int hash_final(struct hash_ctx *ctx, void *buf, size_t n); int hash_name2type(char *name); +const char *hash_type2name(int type); /* icache.c */ struct icache *alloc_icache(void); diff --git a/hash.c b/hash.c @@ -80,3 +80,16 @@ hash_name2type(char *name) return -1; return algo->type; } + +const char * +hash_type2name(int type) +{ + struct algomap *algo; + + for (algo = &algomap[0]; algo->name != NULL; algo++) + if (algo->type == type) + break; + if (algo->name == NULL) + return NULL; + return algo->name; +}