projects/aports·blob master · refs

70 lines · 1.8 KiB

1From 49f3e46bb8b2f23b3267a70318605adf50b5903f Mon Sep 17 00:00:00 2001
2From: Kaarle Ritvanen <[email protected]>
3Date: Sat, 29 Sep 2018 16:54:33 +0300
4Subject: [PATCH] allow command line argument order used by mount(8)
5
6The mount spec and directory are passed as the first and second
7arguments to the helper, followed by the options.
8
9The current implementation works on glibc but fails on POSIX-conforming
10C libraries such as musl.
11---
12 fuse/main.c | 20 ++++++++++++++++----
13 1 file changed, 16 insertions(+), 4 deletions(-)
14
15diff --git a/fuse/main.c b/fuse/main.c
16index c645390..50b6787 100644
17--- a/fuse/main.c
18+++ b/fuse/main.c
19@@ -512,9 +512,17 @@ static int fuse_exfat_main(char* mount_options, char* mount_point)
20 &fuse_exfat_ops, NULL);
21 }
22
23+static void read_arg(char **param, int *argc, char ***argv) {
24+ if (!*param && *argc > optind && (*argv)[optind][0] != '-') {
25+ *param = (*argv)[optind];
26+ ((*argv)++)[1] = (*argv)[0];
27+ (*argc)--;
28+ }
29+}
30+
31 int main(int argc, char* argv[])
32 {
33- const char* spec = NULL;
34+ char* spec = NULL;
35 char* mount_point = NULL;
36 char* fuse_options;
37 char* exfat_options;
38@@ -523,6 +531,9 @@ int main(int argc, char* argv[])
39
40 printf("FUSE exfat %s\n", VERSION);
41
42+ read_arg(&spec, &argc, &argv);
43+ read_arg(&mount_point, &argc, &argv);
44+
45 fuse_options = strdup("allow_other,"
46 #if defined(__linux__) || defined(__FreeBSD__)
47 "big_writes,"
48@@ -573,15 +584,16 @@ int main(int argc, char* argv[])
49 usage(argv[0]);
50 break;
51 }
52+
53+ read_arg(&spec, &argc, &argv);
54+ read_arg(&mount_point, &argc, &argv);
55 }
56- if (argc - optind != 2)
57+ if (!mount_point || argc > optind)
58 {
59 free(exfat_options);
60 free(fuse_options);
61 usage(argv[0]);
62 }
63- spec = argv[optind];
64- mount_point = argv[optind + 1];
65
66 if (exfat_mount(&ef, spec, exfat_options) != 0)
67 {
68--
692.14.4
70