upload manpage
[hband-tools.git] / mount / mount.fusefile
blob7eb4469ffc86b5232bff78d10e00093a1d2b218a
1 #!/bin/bash
3 # This is a wrapper for 'fusefile'
4 # enabling to invoke from standard 'mount' command
5 # as 'mount -t fusefile ./file1 ./mountpoint'
8 warnx()
10 echo "mount.fusefile: $@" >&2
13 declare -a my_opts
14 declare -a fuse_opts
15 command="exec fusefile"
16 fake_command="warnx fusefile"
17 isset_fuse_fsname=no
18 access_mode=''
19 param1=''
20 param2=''
22 while [ -n "$1" ]
24 case "$1" in
25 -o)
26 shift
27 for opt in ${1//,/ }
29 case "$opt" in
30 rw)
31 access_mode=-w
33 ro)
34 access_mode=-r
36 offset=*|size=*|mode=*)
37 opt_chr=${opt:0:1}
38 opt_chr=${opt_chr^^}
39 opt_val=${opt#*=}
40 my_opts+=(-$opt_chr "$opt_val")
42 writeonly)
43 access_mode=-W
45 readappend)
46 access_mode=-a
48 appendonly)
49 access_mode=-A
52 #echo "mount.fusefile: unknown option: -o $opt" >&2
53 #exit -1
54 fuse_opts+=(-o "$opt")
55 if [ "${opt:0:7}" = "fsname=" ]
56 then
57 isset_fuse_fsname=yes
60 esac
61 done
63 -v)
64 set -x
66 -f)
67 command=$fake_command
69 -n)
70 true
72 --help)
73 echo "mount.fusefile -o OPTIONS FILE MOUNTPOINT
74 Options:
75 rw, ro, writeonly, readappend, appendonly,
76 offset=OFFSET, size=SIZE, mode=MODE, FUSE-options
78 exit -1
80 --)
81 shift
82 break
84 -*)
85 echo "mount.fusefile: unknown option: $1" >&2
86 exit -1
89 if [ -z "$param1" ]
90 then
91 param1=$1
92 if [ $isset_fuse_fsname = no ]
93 then
94 fuse_opts+=(-o "fsname=$1")
96 elif [ -z "$param2" ]
97 then
98 param2=$1
99 else
100 echo "mount.fusefile: too many parameter: $1" >&2
101 exit -1
104 esac
105 shift
106 done
108 $command "$param1" "$param2" $access_mode "${my_opts[@]}" "${fuse_opts[@]}"