iRename struct snapshot to struct snap and related constants - dedup - deduplicating backup program Err bitreich.org 70 hgit clone git://bitreich.org/dedup/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/dedup/ URL:git://bitreich.org/dedup/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/dedup/ bitreich.org 70 1Log /scm/dedup/log.gph bitreich.org 70 1Files /scm/dedup/files.gph bitreich.org 70 1Refs /scm/dedup/refs.gph bitreich.org 70 1Tags /scm/dedup/tag bitreich.org 70 1README /scm/dedup/file/README.gph bitreich.org 70 1LICENSE /scm/dedup/file/LICENSE.gph bitreich.org 70 i--- Err bitreich.org 70 1commit c90df19c4abc00fea111be13b164216a33e5339d /scm/dedup/commit/c90df19c4abc00fea111be13b164216a33e5339d.gph bitreich.org 70 1parent 1f0640de77e4cf3d4227dd824d556f09e2bb4200 /scm/dedup/commit/1f0640de77e4cf3d4227dd824d556f09e2bb4200.gph bitreich.org 70 hAuthor: sin URL:mailto:sin@2f30.org bitreich.org 70 iDate: Tue, 26 Mar 2019 16:14:15 +0000 Err bitreich.org 70 i Err bitreich.org 70 iRename struct snapshot to struct snap and related constants Err bitreich.org 70 i Err bitreich.org 70 iDiffstat: Err bitreich.org 70 i M dedup.c | 51 ++++++++++++++++--------------- Err bitreich.org 70 i M dedup.h | 24 ++++++++++++------------ Err bitreich.org 70 i M types.c | 16 ++++++++-------- Err bitreich.org 70 i Err bitreich.org 70 i3 files changed, 46 insertions(+), 45 deletions(-) Err bitreich.org 70 i--- Err bitreich.org 70 1diff --git a/dedup.c b/dedup.c /scm/dedup/file/dedup.c.gph bitreich.org 70 i@@ -28,7 +28,7 @@ struct extract_args { Err bitreich.org 70 i int ret; Err bitreich.org 70 i }; Err bitreich.org 70 i Err bitreich.org 70 i-static struct snapshot_hdr snap_hdr; Err bitreich.org 70 i+static struct snap_hdr snap_hdr; Err bitreich.org 70 i static struct blk_hdr blk_hdr; Err bitreich.org 70 i static struct cache *cache; Err bitreich.org 70 i static int ifd; Err bitreich.org 70 i@@ -72,10 +72,10 @@ print_stats(struct stats *st) Err bitreich.org 70 i fprintf(stderr, "Cache misses: %llu\n", cache_misses); Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i-static struct snapshot * Err bitreich.org 70 i+static struct snap * Err bitreich.org 70 i alloc_snap(void) Err bitreich.org 70 i { Err bitreich.org 70 i- struct snapshot *snap; Err bitreich.org 70 i+ struct snap *snap; Err bitreich.org 70 i Err bitreich.org 70 i snap = calloc(1, sizeof(*snap)); Err bitreich.org 70 i if (snap == NULL) Err bitreich.org 70 i@@ -84,7 +84,7 @@ alloc_snap(void) Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i static void Err bitreich.org 70 i-free_snap(struct snapshot *snap) Err bitreich.org 70 i+free_snap(struct snap *snap) Err bitreich.org 70 i { Err bitreich.org 70 i free(snap); Err bitreich.org 70 i } Err bitreich.org 70 i@@ -94,7 +94,7 @@ free_snap(struct snapshot *snap) Err bitreich.org 70 i * hash of its block descriptors. Err bitreich.org 70 i */ Err bitreich.org 70 i static void Err bitreich.org 70 i-hash_snap(struct snapshot *snap, uint8_t *md) Err bitreich.org 70 i+hash_snap(struct snap *snap, uint8_t *md) Err bitreich.org 70 i { Err bitreich.org 70 i blake2b_state ctx; Err bitreich.org 70 i uint64_t i; Err bitreich.org 70 i@@ -109,8 +109,8 @@ hash_snap(struct snapshot *snap, uint8_t *md) Err bitreich.org 70 i blake2b_final(&ctx, md, MDSIZE); Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i-static struct snapshot * Err bitreich.org 70 i-grow_snap(struct snapshot *snap, uint64_t nr_blk_descs) Err bitreich.org 70 i+static struct snap * Err bitreich.org 70 i+grow_snap(struct snap *snap, uint64_t nr_blk_descs) Err bitreich.org 70 i { Err bitreich.org 70 i size_t size; Err bitreich.org 70 i Err bitreich.org 70 i@@ -129,7 +129,7 @@ grow_snap(struct snapshot *snap, uint64_t nr_blk_descs) Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i static void Err bitreich.org 70 i-append_snap(struct snapshot *snap) Err bitreich.org 70 i+append_snap(struct snap *snap) Err bitreich.org 70 i { Err bitreich.org 70 i if (snap->nr_blk_descs > UINT64_MAX / BLK_DESC_SIZE) Err bitreich.org 70 i errx(1, "%s: overflow", __func__); Err bitreich.org 70 i@@ -140,16 +140,16 @@ append_snap(struct snapshot *snap) Err bitreich.org 70 i snap->size += SNAPSHOT_SIZE; Err bitreich.org 70 i Err bitreich.org 70 i xlseek(ifd, snap_hdr.size, SEEK_SET); Err bitreich.org 70 i- write_snapshot(ifd, snap); Err bitreich.org 70 i- write_snapshot_blk_descs(ifd, snap); Err bitreich.org 70 i+ write_snap(ifd, snap); Err bitreich.org 70 i+ write_snap_blk_descs(ifd, snap); Err bitreich.org 70 i Err bitreich.org 70 i if (snap_hdr.size > UINT64_MAX - snap->size) Err bitreich.org 70 i errx(1, "%s: overflow", __func__); Err bitreich.org 70 i snap_hdr.size += snap->size; Err bitreich.org 70 i Err bitreich.org 70 i- if (snap_hdr.nr_snapshots > UINT64_MAX - 1) Err bitreich.org 70 i+ if (snap_hdr.nr_snaps > UINT64_MAX - 1) Err bitreich.org 70 i errx(1, "%s: overflow", __func__); Err bitreich.org 70 i- snap_hdr.nr_snapshots++; Err bitreich.org 70 i+ snap_hdr.nr_snaps++; Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i static uint8_t * Err bitreich.org 70 i@@ -204,7 +204,7 @@ append_blk(uint8_t *buf, struct blk_desc *blk_desc) Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i static void Err bitreich.org 70 i-dedup_chunk(struct snapshot *snap, uint8_t *chunkp, size_t chunk_size) Err bitreich.org 70 i+dedup_chunk(struct snap *snap, uint8_t *chunkp, size_t chunk_size) Err bitreich.org 70 i { Err bitreich.org 70 i uint8_t md[MDSIZE]; Err bitreich.org 70 i struct blk_desc blk_desc; Err bitreich.org 70 i@@ -248,7 +248,7 @@ dedup_chunk(struct snapshot *snap, uint8_t *chunkp, size_t chunk_size) Err bitreich.org 70 i static void Err bitreich.org 70 i dedup(int fd, char *msg) Err bitreich.org 70 i { Err bitreich.org 70 i- struct snapshot *snap; Err bitreich.org 70 i+ struct snap *snap; Err bitreich.org 70 i struct chunker *chunker; Err bitreich.org 70 i Err bitreich.org 70 i snap = alloc_snap(); Err bitreich.org 70 i@@ -284,7 +284,7 @@ dedup(int fd, char *msg) Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i static int Err bitreich.org 70 i-extract(struct snapshot *snap, void *arg) Err bitreich.org 70 i+extract(struct snap *snap, void *arg) Err bitreich.org 70 i { Err bitreich.org 70 i uint8_t *buf[2]; Err bitreich.org 70 i struct extract_args *args = arg; Err bitreich.org 70 i@@ -311,11 +311,12 @@ extract(struct snapshot *snap, void *arg) Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i /* Err bitreich.org 70 i- * For each snapshot, hash every block and check if the hash Err bitreich.org 70 i- * matches the one in the corresponding block descriptor. Err bitreich.org 70 i+ * Hash every block referenced by the given snapshot Err bitreich.org 70 i+ * and compare its hash with the one stored in the corresponding Err bitreich.org 70 i+ * block descriptor. Err bitreich.org 70 i */ Err bitreich.org 70 i static int Err bitreich.org 70 i-check_snap(struct snapshot *snap, void *arg) Err bitreich.org 70 i+check_snap(struct snap *snap, void *arg) Err bitreich.org 70 i { Err bitreich.org 70 i uint8_t *buf; Err bitreich.org 70 i int *ret = arg; Err bitreich.org 70 i@@ -361,7 +362,7 @@ check_snap(struct snapshot *snap, void *arg) Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i static int Err bitreich.org 70 i-build_cache(struct snapshot *snap, void *arg) Err bitreich.org 70 i+build_cache(struct snap *snap, void *arg) Err bitreich.org 70 i { Err bitreich.org 70 i uint8_t *buf; Err bitreich.org 70 i uint64_t i; Err bitreich.org 70 i@@ -378,7 +379,7 @@ build_cache(struct snapshot *snap, void *arg) Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i static int Err bitreich.org 70 i-list(struct snapshot *snap, void *arg) Err bitreich.org 70 i+list(struct snap *snap, void *arg) Err bitreich.org 70 i { Err bitreich.org 70 i print_md(stdout, snap->md, sizeof(snap->md)); Err bitreich.org 70 i if (snap->msg[0] != '\0') Err bitreich.org 70 i@@ -390,19 +391,19 @@ list(struct snapshot *snap, void *arg) Err bitreich.org 70 i Err bitreich.org 70 i /* Walk through all snapshots and call fn() on each one */ Err bitreich.org 70 i static void Err bitreich.org 70 i-walk_snap(int (*fn)(struct snapshot *, void *), void *arg) Err bitreich.org 70 i+walk_snap(int (*fn)(struct snap *, void *), void *arg) Err bitreich.org 70 i { Err bitreich.org 70 i uint64_t i; Err bitreich.org 70 i Err bitreich.org 70 i xlseek(ifd, SNAP_HDR_SIZE, SEEK_SET); Err bitreich.org 70 i- for (i = 0; i < snap_hdr.nr_snapshots; i++) { Err bitreich.org 70 i- struct snapshot *snap; Err bitreich.org 70 i+ for (i = 0; i < snap_hdr.nr_snaps; i++) { Err bitreich.org 70 i+ struct snap *snap; Err bitreich.org 70 i int ret; Err bitreich.org 70 i Err bitreich.org 70 i snap = alloc_snap(); Err bitreich.org 70 i- read_snapshot(ifd, snap); Err bitreich.org 70 i+ read_snap(ifd, snap); Err bitreich.org 70 i snap = grow_snap(snap, snap->nr_blk_descs); Err bitreich.org 70 i- read_snapshot_descs(ifd, snap); Err bitreich.org 70 i+ read_snap_descs(ifd, snap); Err bitreich.org 70 i Err bitreich.org 70 i ret = (*fn)(snap, arg); Err bitreich.org 70 i free(snap); Err bitreich.org 70 1diff --git a/dedup.h b/dedup.h /scm/dedup/file/dedup.h.gph bitreich.org 70 i@@ -38,10 +38,10 @@ struct stats { Err bitreich.org 70 i uint64_t reserved[4]; Err bitreich.org 70 i }; Err bitreich.org 70 i Err bitreich.org 70 i-struct snapshot_hdr { Err bitreich.org 70 i+struct snap_hdr { Err bitreich.org 70 i uint64_t flags; /* bottom 16 bits are maj/min version */ Err bitreich.org 70 i uint64_t size; /* size of snapshots file */ Err bitreich.org 70 i- uint64_t nr_snapshots; Err bitreich.org 70 i+ uint64_t nr_snaps; Err bitreich.org 70 i struct stats st; Err bitreich.org 70 i }; Err bitreich.org 70 i Err bitreich.org 70 i@@ -56,10 +56,10 @@ struct blk_desc { Err bitreich.org 70 i uint64_t size; /* size of block */ Err bitreich.org 70 i }; Err bitreich.org 70 i Err bitreich.org 70 i-struct snapshot { Err bitreich.org 70 i- uint64_t size; /* size of snapshot (including block descriptors) */ Err bitreich.org 70 i- uint8_t msg[MSGSIZE]; /* arbitrary message attached to snapshot */ Err bitreich.org 70 i- uint8_t md[MDSIZE]; /* hash of snapshot */ Err bitreich.org 70 i+struct snap { Err bitreich.org 70 i+ uint64_t size; /* size of snap (including block descriptors) */ Err bitreich.org 70 i+ uint8_t msg[MSGSIZE]; /* arbitrary message attached to snap */ Err bitreich.org 70 i+ uint8_t md[MDSIZE]; /* hash of snap */ Err bitreich.org 70 i uint64_t nr_blk_descs; Err bitreich.org 70 i struct blk_desc blk_desc[]; Err bitreich.org 70 i }; Err bitreich.org 70 i@@ -97,16 +97,16 @@ int pack(unsigned char *dst, char *fmt, ...); Err bitreich.org 70 i int unpack(unsigned char *src, char *fmt, ...); Err bitreich.org 70 i Err bitreich.org 70 i /* types.c */ Err bitreich.org 70 i-void read_snap_hdr(int fd, struct snapshot_hdr *hdr); Err bitreich.org 70 i-void write_snap_hdr(int fd, struct snapshot_hdr *hdr); Err bitreich.org 70 i+void read_snap_hdr(int fd, struct snap_hdr *hdr); Err bitreich.org 70 i+void write_snap_hdr(int fd, struct snap_hdr *hdr); Err bitreich.org 70 i void read_blk_hdr(int fd, struct blk_hdr *hdr); Err bitreich.org 70 i void write_blk_hdr(int fd, struct blk_hdr *hdr); Err bitreich.org 70 i void read_blk_desc(int fd, struct blk_desc *desc); Err bitreich.org 70 i void write_blk_desc(int fd, struct blk_desc *desc); Err bitreich.org 70 i-void read_snapshot(int fd, struct snapshot *snap); Err bitreich.org 70 i-void read_snapshot_descs(int fd, struct snapshot *snap); Err bitreich.org 70 i-void write_snapshot(int fd, struct snapshot *snap); Err bitreich.org 70 i-void write_snapshot_blk_descs(int fd, struct snapshot *snap); Err bitreich.org 70 i+void read_snap(int fd, struct snap *snap); Err bitreich.org 70 i+void read_snap_descs(int fd, struct snap *snap); Err bitreich.org 70 i+void write_snap(int fd, struct snap *snap); Err bitreich.org 70 i+void write_snap_blk_descs(int fd, struct snap *snap); Err bitreich.org 70 i Err bitreich.org 70 i /* utils.c */ Err bitreich.org 70 i void str2bin(char *s, uint8_t *d); Err bitreich.org 70 1diff --git a/types.c b/types.c /scm/dedup/file/types.c.gph bitreich.org 70 i@@ -9,7 +9,7 @@ Err bitreich.org 70 i #include "dedup.h" Err bitreich.org 70 i Err bitreich.org 70 i void Err bitreich.org 70 i-read_snap_hdr(int fd, struct snapshot_hdr *hdr) Err bitreich.org 70 i+read_snap_hdr(int fd, struct snap_hdr *hdr) Err bitreich.org 70 i { Err bitreich.org 70 i uint8_t buf[SNAP_HDR_SIZE]; Err bitreich.org 70 i int n; Err bitreich.org 70 i@@ -20,7 +20,7 @@ read_snap_hdr(int fd, struct snapshot_hdr *hdr) Err bitreich.org 70 i n = unpack(buf, "qqq", Err bitreich.org 70 i &hdr->flags, Err bitreich.org 70 i &hdr->size, Err bitreich.org 70 i- &hdr->nr_snapshots); Err bitreich.org 70 i+ &hdr->nr_snaps); Err bitreich.org 70 i Err bitreich.org 70 i n += unpack(&buf[n], "qqqqqq", Err bitreich.org 70 i &hdr->st.orig_size, Err bitreich.org 70 i@@ -40,7 +40,7 @@ read_snap_hdr(int fd, struct snapshot_hdr *hdr) Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i void Err bitreich.org 70 i-write_snap_hdr(int fd, struct snapshot_hdr *hdr) Err bitreich.org 70 i+write_snap_hdr(int fd, struct snap_hdr *hdr) Err bitreich.org 70 i { Err bitreich.org 70 i uint8_t buf[SNAP_HDR_SIZE]; Err bitreich.org 70 i int n; Err bitreich.org 70 i@@ -48,7 +48,7 @@ write_snap_hdr(int fd, struct snapshot_hdr *hdr) Err bitreich.org 70 i n = pack(buf, "qqq", Err bitreich.org 70 i hdr->flags, Err bitreich.org 70 i hdr->size, Err bitreich.org 70 i- hdr->nr_snapshots); Err bitreich.org 70 i+ hdr->nr_snaps); Err bitreich.org 70 i Err bitreich.org 70 i n += pack(&buf[n], "qqqqqq", Err bitreich.org 70 i hdr->st.orig_size, Err bitreich.org 70 i@@ -135,7 +135,7 @@ write_blk_desc(int fd, struct blk_desc *desc) Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i void Err bitreich.org 70 i-read_snapshot(int fd, struct snapshot *snap) Err bitreich.org 70 i+read_snap(int fd, struct snap *snap) Err bitreich.org 70 i { Err bitreich.org 70 i uint8_t buf[SNAPSHOT_SIZE]; Err bitreich.org 70 i char fmt[BUFSIZ]; Err bitreich.org 70 i@@ -155,7 +155,7 @@ read_snapshot(int fd, struct snapshot *snap) Err bitreich.org 70 i }; Err bitreich.org 70 i Err bitreich.org 70 i void Err bitreich.org 70 i-read_snapshot_descs(int fd, struct snapshot *snap) Err bitreich.org 70 i+read_snap_descs(int fd, struct snap *snap) Err bitreich.org 70 i { Err bitreich.org 70 i uint64_t i; Err bitreich.org 70 i Err bitreich.org 70 i@@ -164,7 +164,7 @@ read_snapshot_descs(int fd, struct snapshot *snap) Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i void Err bitreich.org 70 i-write_snapshot(int fd, struct snapshot *snap) Err bitreich.org 70 i+write_snap(int fd, struct snap *snap) Err bitreich.org 70 i { Err bitreich.org 70 i uint8_t buf[SNAPSHOT_SIZE]; Err bitreich.org 70 i char fmt[BUFSIZ]; Err bitreich.org 70 i@@ -182,7 +182,7 @@ write_snapshot(int fd, struct snapshot *snap) Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i void Err bitreich.org 70 i-write_snapshot_blk_descs(int fd, struct snapshot *snap) Err bitreich.org 70 i+write_snap_blk_descs(int fd, struct snap *snap) Err bitreich.org 70 i { Err bitreich.org 70 i uint64_t i; Err bitreich.org 70 i Err bitreich.org 70 .