make getpeername() return the original socket address which before it was intercepted
[hband-tools.git] / mount / mount.posixovlfs
blob283549bb8e0f311a82e16fd0b809f98c9c787526
1 #!/bin/bash
3 # fstab-compatible mount script for posix-overlay fs
4 # example invocation:
5 # /sbin/mount.posixovlfs /mnt/vol/lower /mnt/vol/upper -o rw,default
7 set -e
8 set -o pipefail
9 set -u
11 sourcestring=$1
12 shift
13 targetdir=$1
14 shift
15 options=''
17 while [ $# -gt 0 ]
19 case "$1" in
20 -o)
21 shift
22 options=$1
25 echo "unknown parameter: $1" >&2
26 exit 1
28 esac
29 shift
30 done
32 if [[ $sourcestring =~ posixovl:(.+) ]]
33 then
34 sourcedir=${BASH_REMATCH[1]}
35 else
36 sourcedir=$sourcestring
39 declare -a opts=()
40 fuse_options=''
41 IFS=','
42 for opt in $options
44 case "$opt" in
45 default|rw) true;;
46 ro) echo "readonly is not supported" >&2
47 exit 2
49 assume_vfat)
50 opts+=(-F)
52 *) fuse_options="$fuse_options${fuse_options:+,}$opt"
54 esac
55 done
56 IFS=$' \t\n'
58 if [ -z "$fuse_options" ]
59 then
60 mount.posixovl "${opts[@]}" -S "$sourcedir" "$targetdir"
61 else
62 mount.posixovl "${opts[@]}" -S "$sourcedir" "$targetdir" -- "$fuse_options"