From: Ralph Ronnquist Date: Sat, 16 Jul 2022 00:02:06 +0000 (+1000) Subject: revised internal options X-Git-Tag: 0.4~9 X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=9c63c2c9b00d4e1faa0482f5cc2dc21a26ff2c03;p=rrq%2Ffusefile.git revised internal options --- diff --git a/fusefile.c b/fusefile.c index 8e09b58..a976660 100644 --- a/fusefile.c +++ b/fusefile.c @@ -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; }