dedup

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

commit 90f2ff9fcf896060da4be75c70cd148f18be28e9
parent 7af43f80bce1e8a11967d0d83f1346e028a2f240
Author: sin <sin@2f30.org>
Date:   Sun, 17 Feb 2019 11:52:38 +0000

Rename write_blk to append_blk

write_blk gave the impression that it could write anywhere (and it
could) but the store is append only so we really don't want to write
anywhere.

Diffstat:
Mdedup.c | 14++++----------
1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/dedup.c b/dedup.c @@ -341,19 +341,13 @@ read_blk(uint8_t *buf, struct bdescr *bdescr) } void -write_blk(uint8_t *buf, struct bdescr *bdescr) +append_blk(uint8_t *buf, struct bdescr *bdescr) { - lseek(sfd, bdescr->offset, SEEK_SET); + lseek(sfd, enthdr.store_size, SEEK_SET); xwrite(sfd, buf, bdescr->size); enthdr.store_size += bdescr->size; } -off_t -store_size(void) -{ - return enthdr.store_size; -} - int lookup_blk(uint8_t *md) { @@ -392,7 +386,7 @@ dedup(int fd, char *msg) blksiz = n; memcpy(bdescr.md, md, sizeof(bdescr)); - bdescr.offset = store_size(); + bdescr.offset = enthdr.store_size; bdescr.size = blksiz; hash_blk(bp, bdescr.size, bdescr.md); @@ -409,7 +403,7 @@ dedup(int fd, char *msg) ent->bdescr[ent->nblks++] = bdescr; /* Store block */ - write_blk(bp, &bdescr); + append_blk(bp, &bdescr); /* Create a cache entry for this block */ cent = alloc_cent();