Lines 65-86
usage( const char* exename )
Link Here
|
65 |
" Remove the lock on <device> for process <pid> again.\n\n"), |
65 |
" Remove the lock on <device> for process <pid> again.\n\n"), |
66 |
exename); |
66 |
exename); |
67 |
puts( _("Options:\n" |
67 |
puts( _("Options:\n" |
68 |
" -r : force <device> to be mounted read-only\n" |
68 |
" -r : force <device> to be mounted read-only\n" |
69 |
" -w : force <device> to be mounted read-write\n" |
69 |
" -w : force <device> to be mounted read-write\n" |
70 |
" -s, --sync : mount <device> with the 'sync' option (default: 'async')\n" |
70 |
" -s, --sync : mount <device> with the 'sync' option (default: 'async')\n" |
71 |
" --noatime : mount <device> with the 'noatime' option (default: 'atime')\n" |
71 |
" --noatime : mount <device> with the 'noatime' option (default: 'atime')\n" |
72 |
" -e, --exec : mount <device> with the 'exec' option (default: 'noexec')\n" |
72 |
" -e, --exec : mount <device> with the 'exec' option (default: 'noexec')\n" |
73 |
" -t <fs> : mount as file system type <fs> (default: autodetected)\n" |
73 |
" -t <fs> : mount as file system type <fs> (default: autodetected)\n" |
74 |
" -c <charset>: use given I/O character set (default: 'utf8' if called\n" |
74 |
" -c <charset> : use given I/O character set (default: 'utf8' if called\n" |
75 |
" in an UTF-8 locale, otherwise mount default)\n" |
75 |
" in an UTF-8 locale, otherwise mount default)\n" |
76 |
" -u <umask> : use specified umask instead of the default (only for\n" |
76 |
" -P <codepage>: use given codepage set\n" |
77 |
" file sytems which actually support umask setting)\n" |
77 |
" -u <umask> : use specified umask instead of the default (only for\n" |
|
|
78 |
" file sytems which actually support umask setting)\n" |
78 |
" --passphrase <file>\n" |
79 |
" --passphrase <file>\n" |
79 |
" read passphrase from file instead of the terminal\n" |
80 |
" read passphrase from file instead of the terminal\n" |
80 |
" (only for LUKS encrypted devices)\n" |
81 |
" (only for LUKS encrypted devices)\n" |
81 |
" -d, --debug : enable debug output (very verbose)\n" |
82 |
" -d, --debug : enable debug output (very verbose)\n" |
82 |
" -h, --help : print help message and exit successfuly\n" |
83 |
" -h, --help : print help message and exit successfuly\n" |
83 |
" --version : print version number and exit successfully") ); |
84 |
" --version : print version number and exit successfully") ); |
84 |
} |
85 |
} |
85 |
|
86 |
|
86 |
/** |
87 |
/** |
Lines 200-205
do_mount_fstab( const char* device )
Link Here
|
200 |
* @param force_write 1 for forced r/w, 0 for forced r/o, -1 for kernel default |
201 |
* @param force_write 1 for forced r/w, 0 for forced r/o, -1 for kernel default |
201 |
* @param iocharset charset to use for file name conversion; NULL for mount |
202 |
* @param iocharset charset to use for file name conversion; NULL for mount |
202 |
* default |
203 |
* default |
|
|
204 |
* @param codepage codepage to use for file name conversion; NULL for mount |
205 |
* default |
203 |
* @param umask User specified umask (NULL for default) |
206 |
* @param umask User specified umask (NULL for default) |
204 |
* @param suppress_errors: if true, stderr is redirected to /dev/null |
207 |
* @param suppress_errors: if true, stderr is redirected to /dev/null |
205 |
* @return exit status of mount, or -1 on failure. |
208 |
* @return exit status of mount, or -1 on failure. |
Lines 207-218
do_mount_fstab( const char* device )
Link Here
|
207 |
int |
210 |
int |
208 |
do_mount( const char* device, const char* mntpt, const char* fsname, int async, |
211 |
do_mount( const char* device, const char* mntpt, const char* fsname, int async, |
209 |
int noatime, int exec, int force_write, const char* iocharset, const |
212 |
int noatime, int exec, int force_write, const char* iocharset, const |
210 |
char* umask, int suppress_errors ) |
213 |
char* codepage, const char* umask, int suppress_errors ) |
211 |
{ |
214 |
{ |
212 |
const struct FS* fs; |
215 |
const struct FS* fs; |
213 |
char ugid_opt[100]; |
216 |
char ugid_opt[100]; |
214 |
char umask_opt[100]; |
217 |
char umask_opt[100]; |
215 |
char iocharset_opt[100]; |
218 |
char iocharset_opt[100]; |
|
|
219 |
char codepage_opt[100]; |
216 |
const char* sync_opt = ",sync"; |
220 |
const char* sync_opt = ",sync"; |
217 |
const char* atime_opt = ",atime"; |
221 |
const char* atime_opt = ",atime"; |
218 |
const char* exec_opt = ",noexec"; |
222 |
const char* exec_opt = ",noexec"; |
Lines 238-244
do_mount( const char* device, const char
Link Here
|
238 |
} |
242 |
} |
239 |
|
243 |
|
240 |
/* assemble option string */ |
244 |
/* assemble option string */ |
241 |
*ugid_opt = *umask_opt = *iocharset_opt = 0; |
245 |
*ugid_opt = *umask_opt = *iocharset_opt = *codepage_opt = 0; |
242 |
if( fs->support_ugid ) |
246 |
if( fs->support_ugid ) |
243 |
snprintf( ugid_opt, sizeof( ugid_opt ), ",uid=%i,gid=%i", |
247 |
snprintf( ugid_opt, sizeof( ugid_opt ), ",uid=%i,gid=%i", |
244 |
getuid(), getgid() ); |
248 |
getuid(), getgid() ); |
Lines 271-279
do_mount( const char* device, const char
Link Here
|
271 |
snprintf( iocharset_opt, sizeof( iocharset_opt ), ",iocharset=%s", iocharset ); |
275 |
snprintf( iocharset_opt, sizeof( iocharset_opt ), ",iocharset=%s", iocharset ); |
272 |
} |
276 |
} |
273 |
|
277 |
|
274 |
snprintf( options, sizeof( options ), "%s%s%s%s%s%s%s%s", |
278 |
if( codepage && fs->support_codepage ) { |
|
|
279 |
if( !is_word_str( codepage ) ) { |
280 |
fprintf( stderr, _("Error: invalid codepage name '%s'\n"), codepage ); |
281 |
return -1; |
282 |
} |
283 |
snprintf( codepage_opt, sizeof( codepage_opt ), ",codepage=%s", codepage ); |
284 |
} |
285 |
|
286 |
snprintf( options, sizeof( options ), "%s%s%s%s%s%s%s%s%s", |
275 |
fs->options, sync_opt, atime_opt, exec_opt, access_opt, ugid_opt, |
287 |
fs->options, sync_opt, atime_opt, exec_opt, access_opt, ugid_opt, |
276 |
umask_opt, iocharset_opt ); |
288 |
umask_opt, iocharset_opt, codepage_opt ); |
277 |
|
289 |
|
278 |
/* go for it */ |
290 |
/* go for it */ |
279 |
return spawnl( SPAWN_EROOT | SPAWN_RROOT | (suppress_errors ? SPAWN_NO_STDERR : 0 ), |
291 |
return spawnl( SPAWN_EROOT | SPAWN_RROOT | (suppress_errors ? SPAWN_NO_STDERR : 0 ), |
Lines 293-305
do_mount( const char* device, const char
Link Here
|
293 |
* @param force_write 1 for forced r/w, 0 for forced r/o, -1 for kernel default |
305 |
* @param force_write 1 for forced r/w, 0 for forced r/o, -1 for kernel default |
294 |
* @param iocharset charset to use for file name conversion; NULL for mount |
306 |
* @param iocharset charset to use for file name conversion; NULL for mount |
295 |
* default |
307 |
* default |
|
|
308 |
* @param codepage codepage to use for file name conversion; NULL for mount |
309 |
* default |
296 |
* @param umask User specified umask (NULL for default) |
310 |
* @param umask User specified umask (NULL for default) |
297 |
* @return last return value of do_mount (i. e. 0 on success, != 0 on error) |
311 |
* @return last return value of do_mount (i. e. 0 on success, != 0 on error) |
298 |
*/ |
312 |
*/ |
299 |
int |
313 |
int |
300 |
do_mount_auto( const char* device, const char* mntpt, int async, |
314 |
do_mount_auto( const char* device, const char* mntpt, int async, |
301 |
int noatime, int exec, int force_write, const char* iocharset, |
315 |
int noatime, int exec, int force_write, const char* iocharset, |
302 |
const char* umask ) |
316 |
const char* codepage, const char* umask ) |
303 |
{ |
317 |
{ |
304 |
const struct FS* fs; |
318 |
const struct FS* fs; |
305 |
int nostderr = 1; |
319 |
int nostderr = 1; |
Lines 310-323
do_mount_auto( const char* device, const
Link Here
|
310 |
if( (fs+1)->fsname == NULL ) |
324 |
if( (fs+1)->fsname == NULL ) |
311 |
nostderr = 0; |
325 |
nostderr = 0; |
312 |
result = do_mount( device, mntpt, fs->fsname, async, noatime, exec, |
326 |
result = do_mount( device, mntpt, fs->fsname, async, noatime, exec, |
313 |
force_write, iocharset, umask, nostderr ); |
327 |
force_write, iocharset, codepage, umask, nostderr ); |
314 |
if( result == 0 ) |
328 |
if( result == 0 ) |
315 |
break; |
329 |
break; |
316 |
|
330 |
|
317 |
/* sometimes VFAT fails when using iocharset; try again without */ |
331 |
/* sometimes VFAT fails when using iocharset; try again without */ |
318 |
if( iocharset ) |
332 |
if( iocharset ) |
319 |
result = do_mount( device, mntpt, fs->fsname, async, noatime, exec, |
333 |
result = do_mount( device, mntpt, fs->fsname, async, noatime, exec, |
320 |
force_write, NULL, umask, nostderr ); |
334 |
force_write, NULL, NULL, umask, nostderr ); |
321 |
if( result <= 0 ) |
335 |
if( result <= 0 ) |
322 |
break; |
336 |
break; |
323 |
} |
337 |
} |
Lines 485-490
main( int argc, char** argv )
Link Here
|
485 |
int force_write = -1; /* 0: ro, 1: rw, -1: default */ |
499 |
int force_write = -1; /* 0: ro, 1: rw, -1: default */ |
486 |
const char* use_fstype = NULL; |
500 |
const char* use_fstype = NULL; |
487 |
const char* iocharset = NULL; |
501 |
const char* iocharset = NULL; |
|
|
502 |
const char* codepage = NULL; |
488 |
const char* umask = NULL; |
503 |
const char* umask = NULL; |
489 |
const char* passphrase = NULL; |
504 |
const char* passphrase = NULL; |
490 |
int result; |
505 |
int result; |
Lines 502-507
main( int argc, char** argv )
Link Here
|
502 |
{ "exec", 0, NULL, 'e' }, |
517 |
{ "exec", 0, NULL, 'e' }, |
503 |
{ "type", 1, NULL, 't' }, |
518 |
{ "type", 1, NULL, 't' }, |
504 |
{ "charset", 1, NULL, 'c' }, |
519 |
{ "charset", 1, NULL, 'c' }, |
|
|
520 |
{ "codepage", 1, NULL, 'P' }, |
505 |
{ "umask", 1, NULL, 'u' }, |
521 |
{ "umask", 1, NULL, 'u' }, |
506 |
{ "passphrase", 1, NULL, 'p' }, |
522 |
{ "passphrase", 1, NULL, 'p' }, |
507 |
{ "read-only", 0, NULL, 'r' }, |
523 |
{ "read-only", 0, NULL, 'r' }, |
Lines 549-554
main( int argc, char** argv )
Link Here
|
549 |
|
565 |
|
550 |
case 'c': iocharset = optarg; break; |
566 |
case 'c': iocharset = optarg; break; |
551 |
|
567 |
|
|
|
568 |
case 'P': codepage = optarg; break; |
569 |
|
552 |
case 'u': umask = optarg; break; |
570 |
case 'u': umask = optarg; break; |
553 |
|
571 |
|
554 |
case 'p': passphrase = optarg; break; |
572 |
case 'p': passphrase = optarg; break; |
Lines 684-693
main( int argc, char** argv )
Link Here
|
684 |
/* off we go */ |
702 |
/* off we go */ |
685 |
if( use_fstype ) |
703 |
if( use_fstype ) |
686 |
result = do_mount( decrypted_device, mntpt, use_fstype, async, noatime, |
704 |
result = do_mount( decrypted_device, mntpt, use_fstype, async, noatime, |
687 |
exec, force_write, iocharset, umask, 0 ); |
705 |
exec, force_write, iocharset, codepage, umask, 0 ); |
688 |
else |
706 |
else |
689 |
result = do_mount_auto( decrypted_device, mntpt, async, noatime, exec, |
707 |
result = do_mount_auto( decrypted_device, mntpt, async, noatime, exec, |
690 |
force_write, iocharset, umask ); |
708 |
force_write, iocharset, codepage, umask ); |
691 |
|
709 |
|
692 |
/* unlock the mount point again */ |
710 |
/* unlock the mount point again */ |
693 |
debug( "unlocking mount point directory\n" ); |
711 |
debug( "unlocking mount point directory\n" ); |