X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=fusefile.c;h=5f7850ba106e2dd9d60278d9bfc2ceb5208f3070;hb=5521fd27f847da8a2ad924d1efe29cb64c9c7fe0;hp=f886287b3f806bd70da4cc7fa9830a55b5fe0f21;hpb=d45b7f29190174659d597b966e09662afd820bad;p=rrq%2Ffusefile.git 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