-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmount.fusefile
108 lines (103 loc) · 1.69 KB
/
mount.fusefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
# This is a wrapper for 'fusefile'
# providing interface for standard tools like 'mount' command and fstab
# place it to /sbin/mount.fusefile then commands like this will work:
# mount -t fusefile ./file1 ./mountpoint'
warnx()
{
echo "$@" >&2
}
declare -a my_opts
declare -a fuse_opts
command="exec fusefile"
fake_command="warnx fusefile"
isset_fuse_fsname=no
access_mode=''
param1=''
param2=''
while [ -n "$1" ]
do
case "$1" in
-o)
shift
for opt in ${1//,/ }
do
case "$opt" in
rw)
access_mode=-w
;;
ro)
access_mode=-r
;;
offset=*|size=*|mode=*)
opt_chr=${opt:0:1}
opt_chr=${opt_chr^^}
opt_val=${opt#*=}
my_opts+=(-$opt_chr "$opt_val")
;;
writeonly)
access_mode=-W
;;
readappend)
access_mode=-a
;;
appendonly)
access_mode=-A
;;
*)
#echo "mount.fusefile: unknown option: -o $opt" >&2
#exit -1
fuse_opts+=(-o "$opt")
if [ "${opt:0:7}" = "fsname=" ]
then
isset_fuse_fsname=yes
fi
;;
esac
done
;;
-v)
set -x
;;
-f)
command=$fake_command
;;
-n)
true
;;
--help)
echo "mount.fusefile -o OPTIONS FILE MOUNTPOINT
Options:
rw, ro, writeonly, readappend, appendonly,
offset=OFFSET, size=SIZE, mode=MODE, FUSE-options
"
exit -1
;;
--)
shift
break
;;
-*)
echo "mount.fusefile: unknown option: $1" >&2
exit -1
;;
*)
if [ -z "$param1" ]
then
param1=$1
if [ $isset_fuse_fsname = no ]
then
fuse_opts+=(-o "fsname=$1")
fi
elif [ -z "$param2" ]
then
param2=$1
else
echo "mount.fusefile: too many parameter: $1" >&2
exit -1
fi
;;
esac
shift
done
$command "$param1" "$param2" $access_mode "${my_opts[@]}" "${fuse_opts[@]}"