dedup

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

commit f08d3792bd0dc9154b8a0e09b339d9d80845b71f
parent d0cf858ff772267664f2286a69e133972f00520d
Author: sin <sin@2f30.org>
Date:   Thu,  7 Mar 2019 17:17:51 +0000

Detect short reads

This can happen if the store is truncated.

Diffstat:
Mdedup.c | 9+++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/dedup.c b/dedup.c @@ -211,9 +211,14 @@ hash_blk(uint8_t *buf, size_t size, uint8_t *md) static void read_blk(uint8_t *buf, struct blk_desc *blk_desc) { + ssize_t n; + xlseek(sfd, blk_desc->offset, SEEK_SET); - if (xread(sfd, buf, blk_desc->size) == 0) - errx(1, "read: unexpected EOF"); + n = xread(sfd, buf, blk_desc->size); + if (n == 0) + errx(1, "read_blk: unexpected EOF"); + if (n != blk_desc->size) + errx(1, "read_blk: short read"); } static void