dedup

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

commit fb016d2858d1d77359c56f4d67070fc8386879b6
parent bfcf7e2d112888bb42b40e2d25211edc7375f8c5
Author: sin <sin@2f30.org>
Date:   Sun,  5 May 2019 20:56:51 +0100

dup-check: Print hashes of corrupt blocks

Diffstat:
Mdup-check.1 | 3+++
Mdup-check.c | 14+++++++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/dup-check.1 b/dup-check.1 @@ -19,6 +19,9 @@ This is done by recalculating the hash of all blocks contained in the snapshot and checking whether the recorded hash of each block matches the actual hash. +.sp +If a corrupt block is detected, the hash of the +block will be printed on standard output. .Sh OPTIONS .Bl -tag -width "-k keyfile" .It Fl k Ar keyfile diff --git a/dup-check.c b/dup-check.c @@ -8,6 +8,8 @@ #include <stdlib.h> #include <unistd.h> +#include <sodium.h> + #include "arg.h" #include "block.h" #include "config.h" @@ -24,9 +26,19 @@ check(struct sctx *sctx, struct bctx *bctx) unsigned char md[MDSIZE]; int n; + if (sodium_init() < 0) + errx(1, "sodium_init: failed"); + while ((n = sget(sctx, md)) == MDSIZE) { - if (bcheck(bctx, md) < 0) + char mdstr[MDSIZE * 2 + 1]; + int r; + + if ((r = bcheck(bctx, md)) < 0) { berr("bcheck"); + } else if (r > 0) { + sodium_bin2hex(mdstr, sizeof(mdstr), md, MDSIZE); + puts(mdstr); + } } if (n < 0) serr("sget");