dedup

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

commit bf3abd9cb6cf698a89cddc3fbd635cf6d6bed45c
parent 18310c86771d40e60642614aa9b99453472484f9
Author: sin <sin@2f30.org>
Date:   Wed, 21 Mar 2018 11:10:03 +0000

Implement nblks() that returns the number of blocks in the store file

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

diff --git a/dedup.c b/dedup.c @@ -191,6 +191,12 @@ lookup_blk(struct blk *b1, uint64_t *blkidx) return -1; } +uint64_t +nblks(void) +{ + return lseek(sfd, 0, SEEK_END) / sizeof(struct blk); +} + void dedup(int fd) { @@ -215,11 +221,7 @@ dedup(int fd) ent = grow_ent(ent, ent->nblks + 1); if (lookup_blk(&blk, &blkidx) == -1) { - off_t offs; - - offs = lseek(sfd, 0, SEEK_END); - offs /= sizeof(blk); - ent->blks[ent->nblks++] = offs; + ent->blks[ent->nblks++] = nblks(); append_blk(&blk); } else {