iUse fstat to get the size of the file - 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 d44390527612ca94178f33bd6ce15d999c7cd220 /scm/dedup/commit/d44390527612ca94178f33bd6ce15d999c7cd220.gph bitreich.org 70 1parent 705d45cf7f4bf7006081d44dc0a6439ec90dcede /scm/dedup/commit/705d45cf7f4bf7006081d44dc0a6439ec90dcede.gph bitreich.org 70 hAuthor: sin URL:mailto:sin@2f30.org bitreich.org 70 iDate: Wed, 21 Mar 2018 17:33:20 +0000 Err bitreich.org 70 i Err bitreich.org 70 iUse fstat to get the size of the file Err bitreich.org 70 i Err bitreich.org 70 iDiffstat: Err bitreich.org 70 i M dedup.c | 14 +++++++++++--- Err bitreich.org 70 i Err bitreich.org 70 i1 file changed, 11 insertions(+), 3 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@@ -232,13 +232,21 @@ grow_ent(struct ent *ent, uint64_t nblks) Err bitreich.org 70 i uint64_t Err bitreich.org 70 i storefile_nblks(void) Err bitreich.org 70 i { Err bitreich.org 70 i- return lseek(sfd, 0, SEEK_END) / sizeof(struct blk); Err bitreich.org 70 i+ struct stat sb; Err bitreich.org 70 i+ Err bitreich.org 70 i+ if (fstat(sfd, &sb) == -1) Err bitreich.org 70 i+ err(1, "fstat"); Err bitreich.org 70 i+ return sb.st_size / sizeof(struct blk); Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i uint64_t Err bitreich.org 70 i cachefile_nblks(void) Err bitreich.org 70 i { Err bitreich.org 70 i- return lseek(cfd, 0, SEEK_END) / sizeof(struct cache_data); Err bitreich.org 70 i+ struct stat sb; Err bitreich.org 70 i+ Err bitreich.org 70 i+ if (fstat(cfd, &sb) == -1) Err bitreich.org 70 i+ err(1, "fstat"); Err bitreich.org 70 i+ return sb.st_size / sizeof(struct cache_data); Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i void Err bitreich.org 70 i@@ -495,7 +503,7 @@ init(void) Err bitreich.org 70 i err(1, "open %s", CACHEF); Err bitreich.org 70 i Err bitreich.org 70 i if (fstat(ifd, &sb) == -1) Err bitreich.org 70 i- err(1, "stat %s", INDEXF); Err bitreich.org 70 i+ err(1, "fstat %s", INDEXF); Err bitreich.org 70 i if (sb.st_size != 0) Err bitreich.org 70 i xread(ifd, &enthdr, sizeof(enthdr)); Err bitreich.org 70 i Err bitreich.org 70 .