#include <unistd.h>
#include <time.h>
#include <errno.h>
+#include <sys/ioctl.h>
+#include <linux/fs.h>
struct Region {
off_t beg;
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) ) {
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