add new mount helper (virtual fstype) : mount.abshelper
[hband-tools.git] / mount / mount.abshelper
blob9136a2c0e7e99f4951a76ec0012c6611b1e10350
1 #!/bin/bash
3 # this wrapper mount script makes relative device paths to absolute.
4 # some mount fs types needs them to be absolute, but I'd like to keep
5 # the option to be able to mount different devices in different directories,
6 # only their relative paths being the same.
8 set -e
9 set -u
11 mount_opts=()
13 dev=$1
14 shift
15 moutpoint=$1
16 shift
18 while [ $# -gt 0 ]
20 case "$1" in
21 (-t)
22 shift
23 fstype=$1
24 if [[ $fstype =~ abshelper\.(.+) ]]
25 then
26 fstype_encoded=${BASH_REMATCH[1]}
27 fstype=${fstype_encoded//\//.}
29 if [[ $fstype =~ ([^.]+) ]]
30 then
31 fstype_master=${BASH_REMATCH[1]}
32 else
33 fstype_master=$fstype
36 (*)
37 mount_opts+=("$1")
39 esac
40 shift
41 done
43 if [ "${dev:0:1}" != / ]
44 then
45 dev=$PWD/$dev
48 exec /sbin/"mount.$fstype_master" "$dev" "$moutpoint" -t "$fstype" "${mount_opts[@]}"