Implement nblks() that returns the number of blocks in the store file - dedup - deduplicating backup program
(HTM) git clone git://bitreich.org/dedup/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/dedup/
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Tags
(DIR) README
(DIR) LICENSE
---
(DIR) commit bf3abd9cb6cf698a89cddc3fbd635cf6d6bed45c
(DIR) parent 18310c86771d40e60642614aa9b99453472484f9
(HTM) 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:
M dedup.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
---
(DIR) 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 {