new mirror
[hband-tools.git] / mount / mount.xattrovlfs
blob6816f588a3a12a306b91c47728eb95cbff8daace
1 #!/bin/bash
3 # fstab-compatible mount script for fuse-xattrs -overlay fs
5 set -e
6 set -o pipefail
7 set -u
9 sourcestring=$1
10 shift
11 targetdir=$1
12 shift
13 options=''
15 while [ $# -gt 0 ]
17 case "$1" in
18 -o)
19 shift
20 options=$1
23 echo "mount.xattrovlfs: unknown parameter: $1" >&2
24 exit 1
26 esac
27 shift
28 done
30 if [[ $sourcestring =~ xattrovl:(.+) ]]
31 then
32 sourcedir=${BASH_REMATCH[1]}
33 else
34 sourcedir=$sourcestring
37 fsname="xattr-overlay($sourcedir)"
39 declare -a fuse_options=()
40 IFS=','
41 for opt in $options
43 case "$opt" in
44 default|rw) true;; # ignore
45 ro) echo "mount.xattrovlfs: readonly is not supported" >&2
46 exit 2
48 *) fuse_options+=(-o "$opt")
50 esac
51 done
52 IFS=$' \t\n'
54 fuse-xattrs "$sourcedir" "$targetdir" -o fsname="$fsname" "${fuse_options[@]}"