dedup

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

commit 7b75cbaaac1697e2b72b971a7da69b82bc8edf52
parent 9525ea212a386cd1d65b9867948109ed80e7dd7d
Author: sin <sin@2f30.org>
Date:   Sun,  5 May 2019 20:38:05 +0100

Rework some comments

Diffstat:
Mbcompress.c | 4----
Mbencrypt.c | 4----
Mbstorage.c | 21++++-----------------
Mdup-gc.c | 2+-
Mdup-init.c | 2+-
5 files changed, 6 insertions(+), 27 deletions(-)

diff --git a/bcompress.c b/bcompress.c @@ -179,7 +179,6 @@ bcput(struct bctx *bctx, void *buf, size_t n, unsigned char *md) return -1; } - /* Allocate compressed block */ cbuf = malloc(CDSIZE + cn); if (cbuf == NULL) { bseterr("malloc: %s", strerror(errno)); @@ -244,21 +243,18 @@ bcget(struct bctx *bctx, unsigned char *md, void *buf, size_t *n) size = cn; size += CDSIZE; - /* Allocate compressed block */ cbuf = malloc(size); if (cbuf == NULL) { bseterr("malloc: %s", strerror(errno)); return -1; } - /* Read compressed block */ bops = bencryptops(); if (bops->get(bctx, md, cbuf, &size) < 0) { free(cbuf); return -1; } - /* Unpack compression descriptor */ unpackcd(cbuf, &cd); /* Decompress block */ diff --git a/bencrypt.c b/bencrypt.c @@ -120,7 +120,6 @@ becreat(struct bctx *bctx, char *path, int mode, struct bparam *bpar) return -1; } - /* Allocate and initialize encryption context */ bctx->ectx = calloc(1, sizeof(struct ectx)); if (bctx->ectx == NULL) { bseterr("calloc: %s", strerror(errno)); @@ -145,7 +144,6 @@ beopen(struct bctx *bctx, char *path, int flags, int mode, struct bparam *bpar) struct ectx *ectx; struct bops *bops; - /* Allocate and initialize encryption context */ bctx->ectx = calloc(1, sizeof(struct ectx)); if (bctx->ectx == NULL) { bseterr("calloc: %s", strerror(errno)); @@ -204,7 +202,6 @@ beput(struct bctx *bctx, void *buf, size_t n, unsigned char *md) return -1; } - /* Allocate encrypted block */ ebuf = malloc(EDSIZE + en); if (ebuf == NULL) { bseterr("malloc: %s", strerror(errno)); @@ -270,7 +267,6 @@ beget(struct bctx *bctx, unsigned char *md, void *buf, size_t *n) return -1; } - /* Read encrypted block */ bops = bstorageops(); if (bops->get(bctx, md, ebuf, &size) < 0) { free(ebuf); diff --git a/bstorage.c b/bstorage.c @@ -363,7 +363,6 @@ bscreat(struct bctx *bctx, char *path, int mode, struct bparam *bpar) bhdr->nbd = 0; sctx->fd = fd; - /* Write the block header entry to the file */ if (packbhdr(fd, bhdr) < 0) { free(sctx); close(fd); @@ -415,14 +414,12 @@ bsopen(struct bctx *bctx, char *path, int flags, int mode, struct bparam *bpar) SLIST_INIT(&sctx->gchead); bhdr = &sctx->bhdr; - /* Read block header entry from file */ if (unpackbhdr(fd, bhdr) < 0) { free(sctx); close(fd); return -1; } - /* Check magic */ if (memcmp(bhdr->magic, BHDRMAGIC, NBHDRMAGIC) != 0) { free(sctx); close(fd); @@ -476,10 +473,6 @@ bsopen(struct bctx *bctx, char *path, int flags, int mode, struct bparam *bpar) sctx->fd = fd; sctx->rdonly = flags == O_RDONLY; - /* - * Initialize block descriptor cache - * and garbage collection list. - */ if (initbdcache(sctx) < 0) { free(sctx); close(fd); @@ -528,14 +521,13 @@ bsput(struct bctx *bctx, void *buf, size_t n, unsigned char *md) return 0; } - /* New blocks are always appended to the storage file */ + /* New blocks are appended at the end of storage file */ offs = lseek(sctx->fd, 0, SEEK_END); if (offs < 0) { bseterr("lseek: %s", strerror(errno)); return -1; } - /* Allocate a new block descriptor */ bd = calloc(1, sizeof(*bd)); if (bd == NULL) { bseterr("calloc: %s", strerror(errno)); @@ -547,13 +539,11 @@ bsput(struct bctx *bctx, void *buf, size_t n, unsigned char *md) bd->refcnt = 1; memcpy(bd->md, key.md, MDSIZE); - /* Write block descriptor to storage file */ if (packbd(sctx->fd, bd) < 0) { free(bd); return -1; } - /* Append block payload to block descriptor */ if (xwrite(sctx->fd, buf, n) != n) { /* Shouldn't fail but if it does rewind storage file state */ ftruncate(sctx->fd, offs); @@ -582,7 +572,6 @@ bsget(struct bctx *bctx, unsigned char *md, void *buf, size_t *n) struct sctx *sctx; struct bd key, *bd; - /* Lookup block in the cache */ sctx = bctx->sctx; memcpy(key.md, md, MDSIZE); bd = RB_FIND(bdcache, &sctx->bdcache, &key); @@ -616,7 +605,6 @@ bsrm(struct bctx *bctx, unsigned char *md) struct bd key, *bd; off_t bdoffs; - /* Lookup block in the cache */ sctx = bctx->sctx; memcpy(key.md, md, MDSIZE); bd = RB_FIND(bdcache, &sctx->bdcache, &key); @@ -686,8 +674,8 @@ bsgc(struct bctx *bctx) } /* - * Lookup the block and rehash it. Check that the - * resulting hash matches the given hash. + * Lookup the block given hash and rehash it. + * Check that the hashes match. */ static int bscheck(struct bctx *bctx, unsigned char *md) @@ -696,7 +684,6 @@ bscheck(struct bctx *bctx, unsigned char *md) struct bd key, *bd; void *buf; - /* Lookup block in the cache */ sctx = bctx->sctx; memcpy(key.md, md, MDSIZE); bd = RB_FIND(bdcache, &sctx->bdcache, &key); @@ -738,7 +725,7 @@ bscheck(struct bctx *bctx, unsigned char *md) return 0; } -/* Sync block header to storage */ +/* Sync block header to storage file */ static int bssync(struct bctx *bctx) { diff --git a/dup-gc.c b/dup-gc.c @@ -30,7 +30,7 @@ main(int argc, char *argv[]) { char path[PATH_MAX]; unsigned char key[KEYSIZE]; - struct bctx *bctx; /* block context */ + struct bctx *bctx; struct bparam bpar; char *keyfile = NULL; char *repo; diff --git a/dup-init.c b/dup-init.c @@ -32,7 +32,7 @@ main(int argc, char *argv[]) char spath[PATH_MAX]; char bpath[PATH_MAX]; unsigned char key[KEYSIZE]; - struct bctx *bctx; /* block context */ + struct bctx *bctx; struct bparam bpar; char *keyfile = NULL; char *repo;