Commit ce2e6104 authored by Jakob Unterwurzacher's avatar Jakob Unterwurzacher

OSX compat: replace fusermount calls with fuse-unmount.bash

Mac OS X does not have fusermount and uses umount instead.
The fuse-unmount.bash calls the appropriate command.
parent 6be78089
......@@ -4,6 +4,7 @@
cd "$(dirname "$0")"
MYNAME=$(basename "$0")
source tests/fuse-unmount.bash
# Download /tmp/linux-3.0.tar.gz
./tests/dl-linux-tarball.bash
......@@ -29,7 +30,7 @@ gocryptfs -q -init -reverse -extpass="echo test" -scryptn=10 $PLAIN
MNT=$(mktemp -d /tmp/linux-3.0.reverse.mnt.XXX)
# Cleanup trap
trap "rm -f $PLAIN/.gocryptfs.reverse.conf ; fusermount -u -z $MNT ; rmdir $MNT" EXIT
trap "rm -f $PLAIN/.gocryptfs.reverse.conf ; fuse-unmount -z $MNT ; rmdir $MNT" EXIT
# Mount
gocryptfs -q -reverse -extpass="echo test" $PLAIN $MNT
......
......@@ -5,6 +5,7 @@
cd "$(dirname "$0")"
MYNAME=$(basename "$0")
source tests/fuse-unmount.bash
function usage {
echo "Usage: $MYNAME [-encfs] [-openssl=true] [-openssl=false] [DIR]"
......@@ -70,7 +71,7 @@ else
fi
# Cleanup trap
trap "cd /; fusermount -u -z $MNT; rm -rf $CRYPT $MNT" EXIT
trap "cd /; fuse-unmount -z $MNT; rm -rf $CRYPT $MNT" EXIT
# Benchmarks
./tests/canonical-benchmarks.bash $MNT
......
#!/bin/bash -eu
#
# Mac OS X does not have fusermount. Put this script into
# your $PATH to emulate it using umount.
#
cd "$(dirname "$0")"
MYNAME=$(basename "$0")
if [[ $# -lt 1 ]] ; then
echo "$PWD/$MYNAME: missing argument"
exit 1
fi
# Get the mount point from the last argument, ignore everything else
M=${@: -1}
exec umount "$M"
......@@ -18,9 +18,10 @@ if ! flock --nonblock 200 ; then
fi
# Clean up dangling filesystems
source tests/fuse-unmount.bash
for i in $(cat /proc/mounts | grep $TESTDIR | cut -f2 -d" "); do
echo "Warning: unmounting leftover filesystem: $i"
fusermount -u $i
fuse-unmount $i
done
source build-without-openssl.bash
......
#!/bin/bash -eu
#
# Compatability wrapper around "fusermount" on Linux and "umount" on
# Mac OS X and friends.
#
# This script can be sourced or executed directly.
#
function fuse-unmount {
local MYNAME=$(basename "$BASH_SOURCE")
if [[ $# -eq 0 ]] ; then
echo "$MYNAME: missing argument"
exit 1
fi
if [[ $OSTYPE == linux* ]] ; then
fusermount -u "$@"
else
# Mountpoint is in last argument, ignore anything else
# (like additional flags for fusermount).
local MNT=${@:$#}
umount "$MNT"
fi
}
# If the process name and the source file name is identical
# we have been executed, not sourced.
if [[ $(basename "$0") == $(basename "$BASH_SOURCE") ]] ; then
fuse-unmount "$@"
fi
......@@ -5,6 +5,7 @@ set -eu
cd "$(dirname "$0")"
MD5="$PWD/../stress_tests/linux-3.0.md5sums"
MYNAME=$(basename "$0")
source ../fuse-unmount.bash
# Setup dirs
cd /tmp
......@@ -12,7 +13,7 @@ wget -nv --show-progress -c https://www.kernel.org/pub/linux/kernel/v3.0/linux-3
WD=$(mktemp -d /tmp/$MYNAME.XXX)
# Cleanup trap
trap "set +u; cd /; fusermount -u -z $WD/c; fusermount -u -z $WD/b; rm -rf $WD" EXIT
trap "set +u; cd /; fuse-unmount -z $WD/c; fuse-unmount -z $WD/b; rm -rf $WD" EXIT
cd $WD
mkdir a b c
......
......@@ -14,6 +14,7 @@ set -eu
cd "$(dirname "$0")"
MD5="$PWD/linux-3.0.md5sums"
MYNAME=$(basename "$0")
source ../fuse-unmount.bash
# Setup dirs
cd /tmp
......@@ -49,8 +50,8 @@ ln -sTf $CSV /tmp/extractloop.csv
# Cleanup trap
# Note: gocryptfs may have already umounted itself because bash relays SIGINT
# Just ignore fusermount errors.
trap "cd /; fusermount -u -z $MNT; rm -rf $CRYPT $MNT" EXIT
# Just ignore unmount errors.
trap "cd /; fuse-unmount -z $MNT; rm -rf $CRYPT $MNT" EXIT
function loop {
# Note: In a subshell, $$ returns the PID of the parent shell.
......
......@@ -14,6 +14,10 @@
set -eu
cd "$(dirname "$0")"
MYNAME=$(basename $0)
source ../fuse-unmount.bash
# Backing directory
DIR=$(mktemp -d /tmp/fsstress.XXX)
# Mountpoint
......@@ -28,13 +32,12 @@ then
fi
# Setup
fusermount -u -z $MNT &> /dev/null || true
fuse-unmount -z $MNT &> /dev/null || true
mkdir -p $DIR $MNT
rm -Rf $DIR/*
rm -Rf $MNT/*
# FS-specific compile and mount
MYNAME=$(basename $0)
if [ $MYNAME = fsstress-loopback.bash ]; then
echo "Recompile go-fuse loopback"
cd $GOPATH/src/github.com/hanwen/go-fuse/example/loopback
......@@ -62,7 +65,7 @@ done
echo
# Cleanup trap
trap "kill %1 ; cd /; fusermount -u -z $MNT; rm -rf $DIR $MNT" EXIT
trap "kill %1 ; cd /; fuse-unmount -z $MNT; rm -rf $DIR $MNT" EXIT
echo "Starting fsstress loop"
N=1
......
......@@ -11,6 +11,7 @@ set -eu
cd "$(dirname "$0")"
MD5="$PWD/linux-3.0.md5sums"
MYNAME=$(basename $0)
source ../fuse-unmount.bash
# Setup
cd /tmp
......@@ -22,8 +23,8 @@ mkdir $PING.mnt $PONG.mnt
# Cleanup trap
# Note: gocryptfs may have already umounted itself because bash relays SIGINT
# Just ignore fusermount errors.
trap "set +e ; cd /tmp; fusermount -u -z $PING.mnt ; fusermount -u -z $PONG.mnt ; rm -rf $PING $PONG $PING.mnt $PONG.mnt" EXIT
# Just ignore unmount errors.
trap "set +e ; cd /tmp; fuse-unmount -z $PING.mnt ; fuse-unmount -z $PONG.mnt ; rm -rf $PING $PONG $PING.mnt $PONG.mnt" EXIT
gocryptfs -q -init -extpass="echo test" -scryptn=10 $PING
gocryptfs -q -init -extpass="echo test" -scryptn=10 $PONG
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment