iAdd error wrapper for lseek - 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 742ebd2af9a3c9215afc63c276db4e9e1ba0e73c /scm/dedup/commit/742ebd2af9a3c9215afc63c276db4e9e1ba0e73c.gph bitreich.org 70 1parent 09d67581b67a79e9948d48e20b2f0f64e7fd0123 /scm/dedup/commit/09d67581b67a79e9948d48e20b2f0f64e7fd0123.gph bitreich.org 70 hAuthor: sin URL:mailto:sin@2f30.org bitreich.org 70 iDate: Tue, 19 Feb 2019 09:23:35 +0000 Err bitreich.org 70 i Err bitreich.org 70 iAdd error wrapper for lseek Err bitreich.org 70 i Err bitreich.org 70 iDiffstat: Err bitreich.org 70 i M dedup.c | 25 ++++++++++++++++++------- Err bitreich.org 70 i Err bitreich.org 70 i1 file changed, 18 insertions(+), 7 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@@ -225,6 +225,17 @@ str2bin(char *s, uint8_t *d) Err bitreich.org 70 i sscanf(s, "%2hhx", &d[i]); Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i+off_t Err bitreich.org 70 i+xlseek(int fd, off_t offset, int whence) Err bitreich.org 70 i+{ Err bitreich.org 70 i+ int ret; Err bitreich.org 70 i+ Err bitreich.org 70 i+ ret = lseek(fd, offset, whence); Err bitreich.org 70 i+ if (ret < 0) Err bitreich.org 70 i+ err(1, "lseek"); Err bitreich.org 70 i+ return ret; Err bitreich.org 70 i+} Err bitreich.org 70 i+ Err bitreich.org 70 i ssize_t Err bitreich.org 70 i xread(int fd, void *buf, size_t nbytes) Err bitreich.org 70 i { Err bitreich.org 70 i@@ -305,7 +316,7 @@ flush_cache(void) Err bitreich.org 70 i if (!cache_dirty) Err bitreich.org 70 i return; Err bitreich.org 70 i Err bitreich.org 70 i- lseek(cfd, 0, SEEK_SET); Err bitreich.org 70 i+ xlseek(cfd, 0, SEEK_SET); Err bitreich.org 70 i RB_FOREACH(cent, cache, &cache_head) Err bitreich.org 70 i xwrite(cfd, ¢->bdescr, sizeof(cent->bdescr)); Err bitreich.org 70 i } Err bitreich.org 70 i@@ -336,11 +347,11 @@ append_ent(struct ent *ent) Err bitreich.org 70 i { Err bitreich.org 70 i /* Update index header */ Err bitreich.org 70 i enthdr.nents++; Err bitreich.org 70 i- lseek(ifd, 0, SEEK_SET); Err bitreich.org 70 i+ xlseek(ifd, 0, SEEK_SET); Err bitreich.org 70 i xwrite(ifd, &enthdr, sizeof(enthdr)); Err bitreich.org 70 i Err bitreich.org 70 i /* Append entry */ Err bitreich.org 70 i- lseek(ifd, 0, SEEK_END); Err bitreich.org 70 i+ xlseek(ifd, 0, SEEK_END); Err bitreich.org 70 i ent->size = sizeof(*ent); Err bitreich.org 70 i ent->size += ent->nblks * sizeof(ent->bdescr[0]); Err bitreich.org 70 i xwrite(ifd, ent, ent->size); Err bitreich.org 70 i@@ -394,7 +405,7 @@ hash_blk(uint8_t *buf, size_t size, uint8_t *md) Err bitreich.org 70 i void Err bitreich.org 70 i read_blk(uint8_t *buf, struct bdescr *bdescr) Err bitreich.org 70 i { Err bitreich.org 70 i- lseek(sfd, bdescr->offset, SEEK_SET); Err bitreich.org 70 i+ xlseek(sfd, bdescr->offset, SEEK_SET); Err bitreich.org 70 i if (xread(sfd, buf, bdescr->size) == 0) Err bitreich.org 70 i errx(1, "read: unexpected EOF"); Err bitreich.org 70 i } Err bitreich.org 70 i@@ -402,7 +413,7 @@ read_blk(uint8_t *buf, struct bdescr *bdescr) Err bitreich.org 70 i void Err bitreich.org 70 i append_blk(uint8_t *buf, struct bdescr *bdescr) Err bitreich.org 70 i { Err bitreich.org 70 i- lseek(sfd, enthdr.store_size, SEEK_SET); Err bitreich.org 70 i+ xlseek(sfd, enthdr.store_size, SEEK_SET); Err bitreich.org 70 i xwrite(sfd, buf, bdescr->size); Err bitreich.org 70 i enthdr.store_size += bdescr->size; Err bitreich.org 70 i } Err bitreich.org 70 i@@ -620,7 +631,7 @@ walk(int (*fn)(struct ent *, void *), void *arg) Err bitreich.org 70 i uint64_t i; Err bitreich.org 70 i Err bitreich.org 70 i ent = alloc_ent(); Err bitreich.org 70 i- lseek(ifd, sizeof(enthdr), SEEK_SET); Err bitreich.org 70 i+ xlseek(ifd, sizeof(enthdr), SEEK_SET); Err bitreich.org 70 i for (i = 0; i < enthdr.nents; i++) { Err bitreich.org 70 i if (xread(ifd, ent, sizeof(*ent)) == 0) Err bitreich.org 70 i errx(1, "read: unexpected EOF"); Err bitreich.org 70 i@@ -647,7 +658,7 @@ init_cache(void) Err bitreich.org 70 i avg = 0; Err bitreich.org 70 i Err bitreich.org 70 i nents = cache_nents(); Err bitreich.org 70 i- lseek(cfd, 0, SEEK_SET); Err bitreich.org 70 i+ xlseek(cfd, 0, SEEK_SET); Err bitreich.org 70 i for (i = 0; i < nents; i++) { Err bitreich.org 70 i struct cent *cent; Err bitreich.org 70 i Err bitreich.org 70 .