Debian Codegraph @

debian/fuse-ext2

raw symbols SCIP
1 #!/bin/sh
2 usage() {
3 printf 'usage: %s [-hv] [-o ro|force|allow_others[,...]]... device|image mountpoint\n\nUse fuse2fs instead.\n' "${0##*/}"
4 exit 9
5 }
6
7 args="$(getopt -o 'hvo:' --long 'help,verbose,options:' -n "${0##*/}" -s 'sh' -- "$@")" || exit
8 eval set -- "$args"
9
10 original_options=
11 readonly=
12 force=
13 while :; do
14 case "$1" in
15 -o|--options)
16 original_options="$original_options,$2"
17 shift 2
18 ;;
19 -h|--help)
20 usage
21 shift
22 ;;
23 -v|--verbose)
24 shift
25 ;;
26 --)
27 shift
28 break
29 ;;
30 esac
31 done
32
33 [ $# -eq 2 ] || usage
34 device="$1"
35 mountpoint="$2"
36
37 # let fuse2fs check $device
38
39 options=
40 while [ -n "${original_options#,}" ]; do
41 original_options="${original_options#,}"
42 full="${original_options%%,*}"
43 original_options="${original_options#*,},"
44 case "${full%%=*}" in
45 "ro" ) readonly=y ;; # Read-only mount.
46 "rw" ) readonly= ;; # Read-write mount
47 "rw+" ) readonly=; force=y ;; # Read-write mount
48 "silent") ;; # keep silent
49 "force" ) force=y ;; # enable read/write
50 * ) options="$options,$full"; continue ;;
51 esac
52 [ "$full" = "${full%=*}" ] || {
53 printf '%s: %s: value given but not allowed\n' "${0##*/}" "$full" >&2
54 exit 254
55 }
56 done
57
58 [ -z "$readonly" ] && [ -z "$force" ] && {
59 printf '%s: Mounting %s Read-Only. Use '\''force'\'' or '\''rw+'\'' options to enable Read-Write mode\n' "${0##*/}" "$device" >&2
60 readonly=y
61 }
62
63 [ -n "$readonly" ] && options="$options,ro" || options="$options,rw"
64
65 exec /usr/bin/fuse2fs "$device" "$mountpoint" -o "${options#,}"