aboutsummaryrefslogtreecommitdiffstats
path: root/fs/tabfs-wrapper
blob: 8e8523be609499ba12683c6e481d448aba11965d (plain)
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
#! /bin/sh
set -efu

# allow wrapper to find tabfs executable
PATH=$(dirname "$0")${PATH:+:$PATH}

if test -n "${TABFS_MOUNTPOINT-}"; then
  mountpoint=$TABFS_MOUNTPOINT
elif test -n "${XDG_RUNTIME_DIR-}"; then
  mountpoint=$XDG_RUNTIME_DIR/tabfs/mnt
elif test -n "${HOME-}"; then
  mountpoint=$HOME/.tabfs/mnt
else
  mountpoint=mnt
fi

pgrep tabfs | grep -v ^$$\$ | xargs kill -9 2>/dev/null || :

OS=$(uname -s)
case $OS in
  Darwin)
    diskutil umount force "$mountpoint" >/dev/null || :
    extraArgs=
    ;;
  FreeBSD)
    umount -f "$mountpoint" 2>/dev/null || :
    extraArgs=
    ;;
  Linux)
    fusermount -u "$mountpoint" 2>/dev/null || :
    extraArgs=-oauto_unmount
    ;;
  *)
    echo "tabfs-wrapper: error: unknown OS: $OS" >&2
    exit 2
esac

mkdir -p "$mountpoint"

exec tabfs -f $extraArgs -odirect_io "$mountpoint"