dedup

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

commit 38a52d085bd43216bf41c277c23c0ac5ebb7f0a4
parent 76740646829a96a6f4e69082141a30886a933ffe
Author: sin <sin@2f30.org>
Date:   Thu, 25 Apr 2019 16:18:02 +0100

Add some comments

Diffstat:
Mbcompress.c | 5+++--
Mblock.c | 1+
Mblock.h | 3+++
Mbstorage.c | 12++++++++----
4 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/bcompress.c b/bcompress.c @@ -37,13 +37,14 @@ static struct bops bops = { .close = bcclose, }; +/* Compression layer context */ struct cctx { - uint64_t type; + uint64_t type; /* compression algorithm type for new blocks */ }; /* Compression descriptor */ struct cd { - uint64_t type; + uint64_t type; /* compression algorithm type */ uint64_t size; }; diff --git a/block.c b/block.c @@ -1,3 +1,4 @@ +/* Top-level block layer implementation */ #include <sys/types.h> #include <sys/stat.h> diff --git a/block.h b/block.h @@ -9,6 +9,9 @@ struct bparam { char *halgo; }; +/* + * Block operations structure. + * This is implemented by each of the block layers. */ struct bops { int (*creat)(struct bctx *bctx, char *path, int mode, struct bparam *bpar); int (*open)(struct bctx *bctx, char *path, int flags, int mode, struct bparam *bpar); diff --git a/bstorage.c b/bstorage.c @@ -80,11 +80,12 @@ struct bd { }; RB_HEAD(bdcache, bd); +/* Storage layer context */ struct sctx { struct bdcache bdcache; struct bhdr bhdr; int fd; - int rdonly; + int rdonly; /* when set to 1, the bssync() operation is a no-op */ }; #define NCALGOS 2 @@ -303,7 +304,7 @@ initbdcache(struct sctx *sctx) return 0; } -/* Create a new store */ +/* Create storage */ static int bscreat(struct bctx *bctx, char *path, int mode, struct bparam *bpar) { @@ -371,7 +372,7 @@ bscreat(struct bctx *bctx, char *path, int mode, struct bparam *bpar) return 0; } -/* Open an existing store */ +/* Open storage */ static int bsopen(struct bctx *bctx, char *path, int flags, int mode, struct bparam *bpar) { @@ -405,6 +406,7 @@ bsopen(struct bctx *bctx, char *path, int flags, int mode, struct bparam *bpar) return -1; } + /* Populate bparam */ calgo = (bhdr->flags >> CALGOSHIFT) & CALGOMASK; if (calgo < 0 || calgo >= NCALGOS) { free(sctx); @@ -432,7 +434,7 @@ bsopen(struct bctx *bctx, char *path, int flags, int mode, struct bparam *bpar) return 0; } -/* Write a new block */ +/* Write a block */ static int bsput(struct bctx *bctx, void *buf, size_t n, unsigned char *md) { @@ -508,6 +510,7 @@ bsget(struct bctx *bctx, unsigned char *md, void *buf, size_t *n) return 0; } +/* Sync block header to storage */ static int bssync(struct bctx *bctx) { @@ -527,6 +530,7 @@ bssync(struct bctx *bctx) return 0; } +/* Close storage handle */ static int bsclose(struct bctx *bctx) {