iSplit pack/unpack from write/read - 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 7c3a4a21592d3c11e418e00964caadaec81613a5 /scm/dedup/commit/7c3a4a21592d3c11e418e00964caadaec81613a5.gph bitreich.org 70
1parent ba824c61fa56f57bb37251927c5b8d2b687167af /scm/dedup/commit/ba824c61fa56f57bb37251927c5b8d2b687167af.gph bitreich.org 70
hAuthor: sin <sin@2f30.org> URL:mailto:sin@2f30.org bitreich.org 70
iDate: Sun, 12 May 2019 19:30:52 +0100 Err bitreich.org 70
i Err bitreich.org 70
iSplit pack/unpack from write/read Err bitreich.org 70
i Err bitreich.org 70
iDiffstat: Err bitreich.org 70
i M state.c | 31 ++++++++++++++----------------- Err bitreich.org 70
i Err bitreich.org 70
i1 file changed, 14 insertions(+), 17 deletions(-) Err bitreich.org 70
i--- Err bitreich.org 70
1diff --git a/state.c b/state.c /scm/dedup/file/state.c.gph bitreich.org 70
i@@ -36,42 +36,32 @@ struct shdr { Err bitreich.org 70
i uint64_t flags; Err bitreich.org 70
i }; Err bitreich.org 70
i Err bitreich.org 70
i-/* Read state header */ Err bitreich.org 70
i+/* Unpack state header */ Err bitreich.org 70
i static int Err bitreich.org 70
i-unpackshdr(int fd, struct shdr *shdr) Err bitreich.org 70
i+unpackshdr(unsigned char *buf, struct shdr *shdr) Err bitreich.org 70
i { Err bitreich.org 70
i- unsigned char buf[SHDRSIZE]; Err bitreich.org 70
i int n; Err bitreich.org 70
i Err bitreich.org 70
i- if (xread(fd, buf, SHDRSIZE) != SHDRSIZE) { Err bitreich.org 70
i- seterr("failed to read state header: %s", strerror(errno)); Err bitreich.org 70
i- return -1; Err bitreich.org 70
i- } Err bitreich.org 70
i- Err bitreich.org 70
i n = unpack(buf, "q", &shdr->flags); Err bitreich.org 70
i assert(n == SHDRSIZE); Err bitreich.org 70
i return n; Err bitreich.org 70
i } Err bitreich.org 70
i Err bitreich.org 70
i-/* Write state header */ Err bitreich.org 70
i+/* Pack state header */ Err bitreich.org 70
i static int Err bitreich.org 70
i-packshdr(int fd, struct shdr *shdr) Err bitreich.org 70
i+packshdr(unsigned char *buf, struct shdr *shdr) Err bitreich.org 70
i { Err bitreich.org 70
i- unsigned char buf[SHDRSIZE]; Err bitreich.org 70
i int n; Err bitreich.org 70
i Err bitreich.org 70
i n = pack(buf, "q", shdr->flags); Err bitreich.org 70
i assert(n == SHDRSIZE); Err bitreich.org 70
i- if (xwrite(fd, buf, n) != n) { Err bitreich.org 70
i- seterr("failed to write state header: %s", strerror(errno)); Err bitreich.org 70
i- return -1; Err bitreich.org 70
i- } Err bitreich.org 70
i return n; Err bitreich.org 70
i } Err bitreich.org 70
i Err bitreich.org 70
i int Err bitreich.org 70
i writestate(int fd, struct param *par) Err bitreich.org 70
i { Err bitreich.org 70
i+ unsigned char buf[SHDRSIZE]; Err bitreich.org 70
i struct shdr shdr; Err bitreich.org 70
i Err bitreich.org 70
i /* Set version */ Err bitreich.org 70
i@@ -99,19 +89,26 @@ writestate(int fd, struct param *par) Err bitreich.org 70
i return -1; Err bitreich.org 70
i } Err bitreich.org 70
i Err bitreich.org 70
i- if (packshdr(fd, &shdr) < 0) Err bitreich.org 70
i+ packshdr(buf, &shdr); Err bitreich.org 70
i+ if (xwrite(fd, buf, SHDRSIZE) != SHDRSIZE) { Err bitreich.org 70
i+ seterr("failed to write state header: %s", strerror(errno)); Err bitreich.org 70
i return -1; Err bitreich.org 70
i+ } Err bitreich.org 70
i return 0; Err bitreich.org 70
i } Err bitreich.org 70
i Err bitreich.org 70
i int Err bitreich.org 70
i readstate(int fd, struct param *par) Err bitreich.org 70
i { Err bitreich.org 70
i+ unsigned char buf[SHDRSIZE]; Err bitreich.org 70
i struct shdr shdr; Err bitreich.org 70
i int algo; Err bitreich.org 70
i Err bitreich.org 70
i- if (unpackshdr(fd, &shdr) < 0) Err bitreich.org 70
i+ if (xread(fd, buf, SHDRSIZE) != SHDRSIZE) { Err bitreich.org 70
i+ seterr("failed to read state header: %s", strerror(errno)); Err bitreich.org 70
i return -1; Err bitreich.org 70
i+ } Err bitreich.org 70
i+ unpackshdr(buf, &shdr); Err bitreich.org 70
i Err bitreich.org 70
i /* If the major version is different, the format is incompatible */ Err bitreich.org 70
i if (((shdr.flags >> VMAJSHIFT) & VMAJMASK) != VMAJ) { Err bitreich.org 70
.
Response:
text/plain