/**
* 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
}
/**
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;
}