commit 7af43f80bce1e8a11967d0d83f1346e028a2f240
parent 7991e88c0880ae32e6f5f4e9e87eea03e7e6d5d2
Author: sin <sin@2f30.org>
Date: Sun, 17 Feb 2019 11:41:53 +0000
Remember store size in the index header
This is needed because when using disk devices directly it doesn't
make sense to lseek to the end to append to the store.
Diffstat:
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/dedup.c b/dedup.c
@@ -33,6 +33,7 @@ enum {
struct enthdr {
uint64_t flags;
uint64_t nents;
+ uint64_t store_size;
};
/* block descriptor */
@@ -344,12 +345,13 @@ write_blk(uint8_t *buf, struct bdescr *bdescr)
{
lseek(sfd, bdescr->offset, SEEK_SET);
xwrite(sfd, buf, bdescr->size);
+ enthdr.store_size += bdescr->size;
}
off_t
store_size(void)
{
- return lseek(sfd, 0, SEEK_END);
+ return enthdr.store_size;
}
int
@@ -621,6 +623,9 @@ init(void)
err(1, "fstat %s", INDEXF);
if (sb.st_size != 0)
xread(ifd, &enthdr, sizeof(enthdr));
+ if (verbose)
+ fprintf(stderr, "store size: %llu bytes\n",
+ (unsigned long long)enthdr.store_size);
if (cache_nents() != 0)
init_cache();