Print repo hash/compression algorithm in verbose mode - 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 08ce46a1676cb97679211c88693d6687ec02d4be DIR parent c52bbd0d5dd0fb73d5c2c95aaa9734aea1951081 HTML Author: sin <sin@2f30.org> Date: Sat, 13 Apr 2019 10:00:46 +0100 Print repo hash/compression algorithm in verbose mode Diffstat: M compress.c | 13 +++++++++++++ M dedup.c | 8 ++++++++ M dedup.h | 2 ++ M hash.c | 13 +++++++++++++ 4 files changed, 36 insertions(+), 0 deletions(-) --- DIR 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; +} DIR 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 DIR 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); DIR 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; +}