Lines 24-29
Link Here
|
24 |
KEY_HELP, |
24 |
KEY_HELP, |
25 |
KEY_HELP_NOHEADER, |
25 |
KEY_HELP_NOHEADER, |
26 |
KEY_VERSION, |
26 |
KEY_VERSION, |
|
|
27 |
KEY_CHARSET, |
27 |
}; |
28 |
}; |
28 |
|
29 |
|
29 |
struct helper_opts { |
30 |
struct helper_opts { |
Lines 31-36
Link Here
|
31 |
int foreground; |
32 |
int foreground; |
32 |
int fsname; |
33 |
int fsname; |
33 |
char *mountpoint; |
34 |
char *mountpoint; |
|
|
35 |
char *charset; |
34 |
}; |
36 |
}; |
35 |
|
37 |
|
36 |
#define FUSE_HELPER_OPT(t, p) { t, offsetof(struct helper_opts, p), 1 } |
38 |
#define FUSE_HELPER_OPT(t, p) { t, offsetof(struct helper_opts, p), 1 } |
Lines 41-46
Link Here
|
41 |
FUSE_HELPER_OPT("-f", foreground), |
43 |
FUSE_HELPER_OPT("-f", foreground), |
42 |
FUSE_HELPER_OPT("-s", singlethread), |
44 |
FUSE_HELPER_OPT("-s", singlethread), |
43 |
FUSE_HELPER_OPT("fsname=", fsname), |
45 |
FUSE_HELPER_OPT("fsname=", fsname), |
|
|
46 |
FUSE_HELPER_OPT("charset=", charset), |
44 |
|
47 |
|
45 |
FUSE_OPT_KEY("-h", KEY_HELP), |
48 |
FUSE_OPT_KEY("-h", KEY_HELP), |
46 |
FUSE_OPT_KEY("--help", KEY_HELP), |
49 |
FUSE_OPT_KEY("--help", KEY_HELP), |
Lines 50-55
Link Here
|
50 |
FUSE_OPT_KEY("-d", FUSE_OPT_KEY_KEEP), |
53 |
FUSE_OPT_KEY("-d", FUSE_OPT_KEY_KEEP), |
51 |
FUSE_OPT_KEY("debug", FUSE_OPT_KEY_KEEP), |
54 |
FUSE_OPT_KEY("debug", FUSE_OPT_KEY_KEEP), |
52 |
FUSE_OPT_KEY("fsname=", FUSE_OPT_KEY_KEEP), |
55 |
FUSE_OPT_KEY("fsname=", FUSE_OPT_KEY_KEEP), |
|
|
56 |
FUSE_OPT_KEY("charset=", KEY_CHARSET), |
53 |
FUSE_OPT_END |
57 |
FUSE_OPT_END |
54 |
}; |
58 |
}; |
55 |
|
59 |
|
Lines 72-77
Link Here
|
72 |
" -d -o debug enable debug output (implies -f)\n" |
76 |
" -d -o debug enable debug output (implies -f)\n" |
73 |
" -f foreground operation\n" |
77 |
" -f foreground operation\n" |
74 |
" -s disable multi-threaded operation\n" |
78 |
" -s disable multi-threaded operation\n" |
|
|
79 |
" -o charset=CHARSET assume filename encoding\n" |
75 |
"\n" |
80 |
"\n" |
76 |
); |
81 |
); |
77 |
} |
82 |
} |
Lines 99-104
Link Here
|
99 |
helper_version(); |
104 |
helper_version(); |
100 |
return 1; |
105 |
return 1; |
101 |
|
106 |
|
|
|
107 |
case KEY_CHARSET: { |
108 |
char *charset = strchr(arg, '='); |
109 |
if (charset == NULL) |
110 |
charset = arg; |
111 |
else |
112 |
charset++; |
113 |
hopts->charset = strdup(charset); |
114 |
return 0; |
115 |
} |
116 |
|
102 |
case FUSE_OPT_KEY_NONOPT: |
117 |
case FUSE_OPT_KEY_NONOPT: |
103 |
if (!hopts->mountpoint) { |
118 |
if (!hopts->mountpoint) { |
104 |
char mountpoint[PATH_MAX]; |
119 |
char mountpoint[PATH_MAX]; |
Lines 139-145
Link Here
|
139 |
} |
154 |
} |
140 |
|
155 |
|
141 |
int fuse_parse_cmdline(struct fuse_args *args, char **mountpoint, |
156 |
int fuse_parse_cmdline(struct fuse_args *args, char **mountpoint, |
142 |
int *multithreaded, int *foreground) |
157 |
int *multithreaded, int *foreground, char **charset) |
143 |
{ |
158 |
{ |
144 |
int res; |
159 |
int res; |
145 |
struct helper_opts hopts; |
160 |
struct helper_opts hopts; |
Lines 159-164
Link Here
|
159 |
else |
174 |
else |
160 |
free(hopts.mountpoint); |
175 |
free(hopts.mountpoint); |
161 |
|
176 |
|
|
|
177 |
if (charset) |
178 |
*charset = hopts.charset; |
179 |
else |
180 |
free(hopts.charset); |
181 |
|
162 |
if (multithreaded) |
182 |
if (multithreaded) |
163 |
*multithreaded = !hopts.singlethread; |
183 |
*multithreaded = !hopts.singlethread; |
164 |
if (foreground) |
184 |
if (foreground) |
Lines 167-172
Link Here
|
167 |
|
187 |
|
168 |
err: |
188 |
err: |
169 |
free(hopts.mountpoint); |
189 |
free(hopts.mountpoint); |
|
|
190 |
free(hopts.charset); |
170 |
return -1; |
191 |
return -1; |
171 |
} |
192 |
} |
172 |
|
193 |
|
Lines 237-244
Link Here
|
237 |
struct fuse *fuse; |
258 |
struct fuse *fuse; |
238 |
int foreground; |
259 |
int foreground; |
239 |
int res; |
260 |
int res; |
|
|
261 |
char *charset; |
240 |
|
262 |
|
241 |
res = fuse_parse_cmdline(&args, mountpoint, multithreaded, &foreground); |
263 |
res = fuse_parse_cmdline(&args, mountpoint, multithreaded, &foreground, &charset); |
242 |
if (res == -1) |
264 |
if (res == -1) |
243 |
return NULL; |
265 |
return NULL; |
244 |
|
266 |
|
Lines 264-269
Link Here
|
264 |
if (fd) |
286 |
if (fd) |
265 |
*fd = fuse_chan_fd(ch); |
287 |
*fd = fuse_chan_fd(ch); |
266 |
|
288 |
|
|
|
289 |
fuse_iconv_open(charset, foreground); |
267 |
return fuse; |
290 |
return fuse; |
268 |
|
291 |
|
269 |
err_unmount: |
292 |
err_unmount: |
Lines 289-294
Link Here
|
289 |
struct fuse_chan *ch = fuse_session_next_chan(se, NULL); |
312 |
struct fuse_chan *ch = fuse_session_next_chan(se, NULL); |
290 |
fuse_remove_signal_handlers(se); |
313 |
fuse_remove_signal_handlers(se); |
291 |
fuse_unmount_common(mountpoint, ch); |
314 |
fuse_unmount_common(mountpoint, ch); |
|
|
315 |
fuse_iconv_close(); |
292 |
fuse_destroy(fuse); |
316 |
fuse_destroy(fuse); |
293 |
free(mountpoint); |
317 |
free(mountpoint); |
294 |
} |
318 |
} |