Skip to content

Commit c9d8f71

Browse files
committed
fix command line argument order
The mount spec and directory are passed as the first and second arguments to the helper, followed by the options. The current implementation works on glibc but fails on POSIX-conforming C libraries such as musl.
1 parent 2ce337d commit c9d8f71

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

fuse/main.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ static void fuse_exfat_destroy(void* unused)
359359

360360
static void usage(const char* prog)
361361
{
362-
fprintf(stderr, "Usage: %s [-d] [-o options] [-V] <device> <dir>\n", prog);
362+
fprintf(stderr, "Usage: %s <device> <dir> [-d] [-o options] [-V]\n", prog);
363363
exit(1);
364364
}
365365

@@ -523,6 +523,13 @@ int main(int argc, char* argv[])
523523

524524
printf("FUSE exfat %s\n", VERSION);
525525

526+
if (argc < 3) usage(argv[0]);
527+
spec = argv[1];
528+
mount_point = argv[2];
529+
argv[2] = argv[0];
530+
argc -= 2;
531+
argv += 2;
532+
526533
fuse_options = strdup("allow_other,"
527534
#if defined(__linux__) || defined(__FreeBSD__)
528535
"big_writes,"
@@ -574,14 +581,12 @@ int main(int argc, char* argv[])
574581
break;
575582
}
576583
}
577-
if (argc - optind != 2)
584+
if (argc > optind)
578585
{
579586
free(exfat_options);
580587
free(fuse_options);
581588
usage(argv[0]);
582589
}
583-
spec = argv[optind];
584-
mount_point = argv[optind + 1];
585590

586591
if (exfat_mount(&ef, spec, exfat_options) != 0)
587592
{

0 commit comments

Comments
 (0)