diff options
author | Jakob Unterwurzacher | 2017-02-15 23:02:01 +0100 |
---|---|---|
committer | Jakob Unterwurzacher | 2017-02-15 23:02:01 +0100 |
commit | ce2e610428c940c2bd5ca1790e7375117b1f6015 (patch) | |
tree | 08563c5e36b8d285390f897cd122e7e1aa8f6fc4 | |
parent | 6be7808992a1d9562b113b13831cd6d6a40114d6 (diff) |
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.
-rwxr-xr-x | benchmark-reverse.bash | 3 | ||||
-rwxr-xr-x | benchmark.bash | 3 | ||||
-rwxr-xr-x | contrib/fusermount | 14 | ||||
-rwxr-xr-x | test.bash | 3 | ||||
-rwxr-xr-x | tests/fuse-unmount.bash | 27 | ||||
-rwxr-xr-x | tests/reverse/linux-tarball-test.bash | 3 | ||||
-rwxr-xr-x | tests/stress_tests/extractloop.bash | 5 | ||||
-rwxr-xr-x | tests/stress_tests/fsstress-gocryptfs.bash | 9 | ||||
-rwxr-xr-x | tests/stress_tests/pingpong.bash | 5 |
9 files changed, 47 insertions, 25 deletions
diff --git a/benchmark-reverse.bash b/benchmark-reverse.bash index e5f375d..2cb1e94 100755 --- a/benchmark-reverse.bash +++ b/benchmark-reverse.bash @@ -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 diff --git a/benchmark.bash b/benchmark.bash index d53e718..b1c334e 100755 --- a/benchmark.bash +++ b/benchmark.bash @@ -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 diff --git a/contrib/fusermount b/contrib/fusermount deleted file mode 100755 index 15c12a0..0000000 --- a/contrib/fusermount +++ /dev/null @@ -1,14 +0,0 @@ -#!/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 diff --git a/tests/fuse-unmount.bash b/tests/fuse-unmount.bash new file mode 100755 index 0000000..087b6fe --- /dev/null +++ b/tests/fuse-unmount.bash @@ -0,0 +1,27 @@ +#!/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 diff --git a/tests/reverse/linux-tarball-test.bash b/tests/reverse/linux-tarball-test.bash index 5fbc3fc..e8ecca6 100755 --- a/tests/reverse/linux-tarball-test.bash +++ b/tests/reverse/linux-tarball-test.bash @@ -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 diff --git a/tests/stress_tests/extractloop.bash b/tests/stress_tests/extractloop.bash index 2c139ab..18fc4ef 100755 --- a/tests/stress_tests/extractloop.bash +++ b/tests/stress_tests/extractloop.bash @@ -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. diff --git a/tests/stress_tests/fsstress-gocryptfs.bash b/tests/stress_tests/fsstress-gocryptfs.bash index 51c68db..432899a 100755 --- a/tests/stress_tests/fsstress-gocryptfs.bash +++ b/tests/stress_tests/fsstress-gocryptfs.bash @@ -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 diff --git a/tests/stress_tests/pingpong.bash b/tests/stress_tests/pingpong.bash index ebcb8c5..02aabc9 100755 --- a/tests/stress_tests/pingpong.bash +++ b/tests/stress_tests/pingpong.bash @@ -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 |