X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;ds=sidebyside;f=fusefile.c;h=a976660e29fb56a5c73297e27e24ab0e212db5a7;hb=9c63c2c9b00d4e1faa0482f5cc2dc21a26ff2c03;hp=476ca9d8fb1ffa847e094150b44223a816ed7603;hpb=a83a2cd9258ecb0420a019bb5d4cd32db8a444ac;p=rrq%2Ffusefile.git diff --git a/fusefile.c b/fusefile.c index 476ca9d..a976660 100644 --- a/fusefile.c +++ b/fusefile.c @@ -269,8 +269,8 @@ static int write_block(off_t off,const char *buf,size_t size) { return -EIO; // past EOF } struct Source *source = &sources.array[ index ]; - off_t from = off - source->start; - off_t max = source->to - source->from - from; + off_t from = off - source->start + source->from; + off_t max = source->to - from; if ( lseek( source->fd, from, SEEK_SET ) < 0 ) { return -EIO; } @@ -420,28 +420,31 @@ static void usage() { /** * Set up the arguments for the fuse_main call, adding our own. + * argv[argc] is the mount point argument */ static int setup_argv(int argc,char ***argv) { + // note: (*argv)[ argc ] is the mount point argument char *OURS[] = { "-odefault_permissions", - (*argv)[ --argc ] // note: (*argv)[ argc-1 ] = the mount point + (*argv)[ argc ] }; #define OURSN ( sizeof( OURS ) / sizeof( char* ) ) - int N = argc + OURSN; // new argv-tobe size, excluding null - char **out = malloc( ( N + 1 ) * sizeof( char* ) ); + int N = argc + OURSN; + // Allocate new arg array plus terminating null pointer + char **out = malloc( ( N + 1 ) * sizeof( char* ) ); int i; for ( i = 0; i < argc; i++ ) { out[ i ] = (*argv)[i]; - fprintf( stderr, " %s", out[ i ] ); + //fprintf( stderr, " %s", out[ i ] ); } for ( i = 0; i < OURSN; i++ ) { out[ argc + i ] = OURS[i]; - fprintf( stderr, " %s", out[ i ] ); + //fprintf( stderr, " %s", out[ i ] ); } out[ N ] = 0; - fprintf( stderr, "\n" ); + //fprintf( stderr, "\n" ); (*argv) = out; - return N; + return N; // Don't include the terminating null pointer } /** @@ -466,8 +469,8 @@ int main(int argc, char *argv[]) if ( i > argc - 2 ) { // At least mount point plus one source usage(); } - mnt = argv[ i++ ]; // First non-option argument is the mount pount fuseargc = i; + mnt = argv[ i++ ]; // First non-option argument is the mount pount if ( setup_sources( argv, i, argc-i ) ) { return 1; }