From 0df8fcce46695d24edea6218bb460cce0818b0d0 Mon Sep 17 00:00:00 2001 From: Ralph Ronnquist Date: Wed, 28 Jun 2023 16:06:26 +1000 Subject: [PATCH 1/1] Fix size dubbling. Handle block device fragment. --- fusefile.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/fusefile.c b/fusefile.c index f886287..5f7850b 100644 --- a/fusefile.c +++ b/fusefile.c @@ -33,6 +33,8 @@ #include #include #include +#include +#include struct Region { off_t beg; @@ -313,6 +315,15 @@ static int setup_source(struct Source *p,char *frag) { fprintf( stderr, "** %s opened read-only\n", p->filename ); } p->from = 0; + if ( S_ISBLK( filestat.st_mode ) ) { + // Block devices report size differently: + if ( ioctl( p->fd, BLKGETSIZE64, &filestat.st_size ) < 0 ) { + perror( p->filename ); + } +#if DEBUG + fprintf( stderr, "block device size = %ld\n", filestat.st_size ); +#endif + } p->to = filestat.st_size; // Process any range variation if ( range && *(++range) ) { @@ -375,8 +386,6 @@ static int setup_sources(char **argv,int i,int n) { if ( setup_source( p, argv[i] ) ) { return 1; } - p->start = sources.size; // the fusefile position of fragment - sources.size += p->to - p->from; #if DEBUG print_source( p ); #endif -- 2.39.2