Skip to content

Commit

Permalink
fix command line argument order
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kunkku committed Sep 26, 2018
1 parent 2ce337d commit c9d8f71
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions fuse/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ static void fuse_exfat_destroy(void* unused)

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

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

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

if (argc < 3) usage(argv[0]);
spec = argv[1];
mount_point = argv[2];
argv[2] = argv[0];
argc -= 2;
argv += 2;

fuse_options = strdup("allow_other,"
#if defined(__linux__) || defined(__FreeBSD__)
"big_writes,"
Expand Down Expand Up @@ -574,14 +581,12 @@ int main(int argc, char* argv[])
break;
}
}
if (argc - optind != 2)
if (argc > optind)
{
free(exfat_options);
free(fuse_options);
usage(argv[0]);
}
spec = argv[optind];
mount_point = argv[optind + 1];

if (exfat_mount(&ef, spec, exfat_options) != 0)
{
Expand Down

0 comments on commit c9d8f71

Please sign in to comment.