projects
/
rrq
/
fusefile.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
1bf026d
)
Seek on the mount target to register fused size. More debugging.
author
Ralph Ronnquist
<ralph.ronnquist@gmail.com>
Sun, 31 Jul 2022 07:51:41 +0000
(17:51 +1000)
committer
Ralph Ronnquist
<ralph.ronnquist@gmail.com>
Sun, 31 Jul 2022 07:51:41 +0000
(17:51 +1000)
fusefile.c
patch
|
blob
|
history
diff --git
a/fusefile.c
b/fusefile.c
index 0936da92219a0e5877679c1bdbae2fc91d1680e6..59dcaa5fb746b13f90098c69c7e278b21b73490e 100644
(file)
--- a/
fusefile.c
+++ b/
fusefile.c
@@
-200,14
+200,28
@@
static int find_source(off_t offset) {
if ( offset >= sources.size ) {
return -1;
}
if ( offset >= sources.size ) {
return -1;
}
+#if DEBUG
+ fprintf( stderr, "find_source( %ld )\n", offset );
+#endif
while ( lo + 1 < hi ) {
int m = ( lo + hi ) / 2;
if ( offset < sources.array[ m ].start ) {
while ( lo + 1 < hi ) {
int m = ( lo + hi ) / 2;
if ( offset < sources.array[ m ].start ) {
+#if DEBUG
+ fprintf( stderr, " offset < [%d].start: %ld\n",
+ m, sources.array[ m ].start );
+#endif
hi = m;
} else {
hi = m;
} else {
+#if DEBUG
+ fprintf( stderr, " offset >= [%d].start: %ld\n",
+ m, sources.array[ m ].start );
+#endif
lo = m;
}
}
lo = m;
}
}
+#if DEBUG
+ fprintf( stderr, "found %d\n", lo );
+#endif
return lo;
}
return lo;
}
@@
-224,10
+238,10
@@
static int fusefile_read(const char *path, char *buf, size_t size,
#if DEBUG
fprintf( stderr, "read %ld %ld\n", off, size );
#endif
#if DEBUG
fprintf( stderr, "read %ld %ld\n", off, size );
#endif
- size_t rr = 0;
+ size_t rr = 0;
// total reading
while ( size > 0 ) {
#if DEBUG
while ( size > 0 ) {
#if DEBUG
- fprintf( stderr, "find_source %ld %ld\n", off, size );
+ fprintf( stderr, "
find_source %ld %ld\n", off, size );
#endif
int i = find_source( off );
if ( i < 0 ) {
#endif
int i = find_source( off );
if ( i < 0 ) {
@@
-245,16
+259,20
@@
static int fusefile_read(const char *path, char *buf, size_t size,
if ( n > size ) {
n = size;
}
if ( n > size ) {
n = size;
}
+#if DEBUG
+ fprintf( stderr, " seek fd=%d to %ld\n", sources.array[i].fd, b );
+#endif
if ( lseek( sources.array[i].fd, b, SEEK_SET ) < 0 ) {
perror( sources.array[i].filename );
return -ENOENT;
}
#if DEBUG
if ( lseek( sources.array[i].fd, b, SEEK_SET ) < 0 ) {
perror( sources.array[i].filename );
return -ENOENT;
}
#if DEBUG
- fprintf( stderr, "get %ld bytes at %ld\n", n, rr );
+ fprintf( stderr, " now read %ld from fd=%d\n",
+ n, sources.array[i].fd );
#endif
ssize_t r = read( sources.array[i].fd, buf + rr, n );
#if DEBUG
#endif
ssize_t r = read( sources.array[i].fd, buf + rr, n );
#if DEBUG
- fprintf( stderr, "got %ld bytes\n", r );
+ fprintf( stderr, "
got %ld bytes\n", r );
#endif
if ( r < 0 ) {
perror( sources.array[i].filename );
#endif
if ( r < 0 ) {
perror( sources.array[i].filename );
@@
-267,6
+285,9
@@
static int fusefile_read(const char *path, char *buf, size_t size,
off += r;
size -= r;
}
off += r;
size -= r;
}
+#if DEBUG
+ fprintf( stderr, " total reading %ld bytes\n", rr );
+#endif
return rr;
}
return rr;
}
@@
-459,7
+480,7
@@
static struct fuse_operations fusefile_oper = {
static void usage() {
char *usage =
"Usage: fusefile [ <fuse options> ] <mount> <file/from-to> ... \n"
static void usage() {
char *usage =
"Usage: fusefile [ <fuse options> ] <mount> <file/from-to> ... \n"
-"Mounts a virtual,
read-only
file that is a concatenation of file fragments\n"
+"Mounts a virtual, file that is a concatenation of file fragments\n"
;
fprintf( stderr, "%s", usage );
exit( 1 );
;
fprintf( stderr, "%s", usage );
exit( 1 );
@@
-542,6
+563,16
@@
int main(int argc, char *argv[])
times.ctime = stbuf.st_ctime;
}
times.ctime = stbuf.st_ctime;
}
+ {
+ int fd = open( mnt, O_RDWR, S_IRUSR | S_IWUSR );
+ if ( fd < 0 ) {
+ perror( mnt );
+ return 1;
+ }
+ if ( lseek( fd, sources.size, SEEK_SET ) < 0 ) {
+ return -EIO;
+ }
+ }
fuseargc = setup_argv( fuseargc, &argv );
struct fuse_args args = FUSE_ARGS_INIT( fuseargc, argv );
if ( fuse_parse_cmdline( &args, &mnt, &mt, &fg ) ) {
fuseargc = setup_argv( fuseargc, &argv );
struct fuse_args args = FUSE_ARGS_INIT( fuseargc, argv );
if ( fuse_parse_cmdline( &args, &mnt, &mt, &fg ) ) {