shell scripts: fix shellcheck warnings

This commit is contained in:
a1346054 2021-08-31 17:01:47 +00:00 committed by rfjakob
parent c505e73a13
commit c63f7e9f64
22 changed files with 140 additions and 140 deletions

View File

@ -1,16 +1,16 @@
#!/bin/bash #!/bin/bash
set -eu set -eu
cd $(dirname "$0") cd "$(dirname "$0")"
# Render Markdown to a proper man(1) manpage # Render Markdown to a proper man(1) manpage
function render { render() {
IN=$1 IN=$1
OUT=$2 OUT=$2
echo "Rendering $IN to $OUT" echo "Rendering $IN to $OUT"
echo ".\\\" This man page was generated from $IN. View it using 'man ./$OUT'" > $OUT echo ".\\\" This man page was generated from $IN. View it using 'man ./$OUT'" > "$OUT"
echo ".\\\"" >> $OUT echo ".\\\"" >> "$OUT"
pandoc "$IN" -s -t man >> $OUT pandoc "$IN" -s -t man >> "$OUT"
} }
render MANPAGE.md gocryptfs.1 render MANPAGE.md gocryptfs.1

View File

@ -14,18 +14,18 @@ PLAIN=linux-3.0
SIZE=0 SIZE=0
if [[ -d $PLAIN ]]; then if [[ -d $PLAIN ]]; then
SIZE=$(du -s --apparent-size $PLAIN | cut -f1) SIZE=$(du -s --apparent-size "$PLAIN" | cut -f1)
fi fi
if [[ $SIZE -ne 412334 ]] ; then if [[ $SIZE -ne 412334 ]] ; then
echo "Extracting linux-3.0.tar.gz" echo "Extracting linux-3.0.tar.gz"
rm -Rf $PLAIN rm -Rf "$PLAIN"
tar xf linux-3.0.tar.gz tar xf linux-3.0.tar.gz
fi fi
rm -f $PLAIN/.gocryptfs.reverse.conf rm -f "$PLAIN/.gocryptfs.reverse.conf"
gocryptfs -q -init -reverse -extpass="echo test" -scryptn=10 $PLAIN gocryptfs -q -init -reverse -extpass="echo test" -scryptn=10 "$PLAIN"
MNT=$(mktemp -d /tmp/linux-3.0.reverse.mnt.XXX) MNT=$(mktemp -d /tmp/linux-3.0.reverse.mnt.XXX)
@ -37,7 +37,7 @@ gocryptfs -q -reverse -extpass="echo test" "$PLAIN" "$MNT"
# Execute command, discard all stdout output, print elapsed time # Execute command, discard all stdout output, print elapsed time
# (to stderr, unfortunately). # (to stderr, unfortunately).
function etime { etime() {
# Make the bash builtin "time" print out only the elapse wall clock # Make the bash builtin "time" print out only the elapse wall clock
# seconds # seconds
TIMEFORMAT=%R TIMEFORMAT=%R

View File

@ -7,7 +7,7 @@ cd "$(dirname "$0")"
MYNAME=$(basename "$0") MYNAME=$(basename "$0")
source tests/fuse-unmount.bash source tests/fuse-unmount.bash
function usage { usage() {
echo "Usage: $MYNAME [-encfs] [-openssl=true] [-openssl=false] [-dd] [DIR]" echo "Usage: $MYNAME [-encfs] [-openssl=true] [-openssl=false] [-dd] [DIR]"
} }

View File

@ -12,7 +12,7 @@
# Note that pam_mount ignores messages on stdout which is why printing # Note that pam_mount ignores messages on stdout which is why printing
# to stdout is ok. # to stdout is ok.
set -eu set -eu
MYNAME=$(basename $0) MYNAME=$(basename "$0")
if [[ $# -lt 2 || $1 == -* ]]; then if [[ $# -lt 2 || $1 == -* ]]; then
echo "Usage: $MYNAME CIPHERDIR MOUNTPOINT [-o COMMA-SEPARATED-OPTIONS]" >&2 echo "Usage: $MYNAME CIPHERDIR MOUNTPOINT [-o COMMA-SEPARATED-OPTIONS]" >&2
exit 1 exit 1

View File

@ -32,8 +32,8 @@ while true ; do
echo "error: file $PWD/$NEXT already exists" echo "error: file $PWD/$NEXT already exists"
exit 1 exit 1
fi fi
echo -n 2> /dev/null > $NEXT || break echo -n 2> /dev/null > "$NEXT" || break
rm $NEXT rm "$NEXT"
NAME="$NEXT" NAME="$NEXT"
done done
echo "${#NAME}" echo "${#NAME}"
@ -47,8 +47,8 @@ if [[ $QUICK -ne 1 ]]; then
NAME="" NAME=""
while true ; do while true ; do
NEXT="${NAME}x" NEXT="${NAME}x"
mkdir $NEXT 2> /dev/null || break mkdir "$NEXT" 2> /dev/null || break
rmdir $NEXT rmdir "$NEXT"
NAME="$NEXT" NAME="$NEXT"
done done
MAX_DIRNAME=${#NAME} MAX_DIRNAME=${#NAME}

View File

@ -2,7 +2,7 @@
MNT=/mnt/ext4-ramdisk MNT=/mnt/ext4-ramdisk
if mountpoint $MNT ; then if mountpoint "$MNT" ; then
exit 1 exit 1
fi fi

View File

@ -6,10 +6,10 @@ cd "$(dirname "$0")"
../tests/dl-linux-tarball.bash ../tests/dl-linux-tarball.bash
T=$(mktemp -d) T=$(mktemp -d)
mkdir $T/a $T/b mkdir "$T/a" "$T/b"
../gocryptfs -init -quiet -scryptn 10 -extpass "echo test" $T/a ../gocryptfs -init -quiet -scryptn 10 -extpass "echo test" "$T/a"
../gocryptfs -quiet -nosyslog -extpass "echo test" $T/a $T/b ../gocryptfs -quiet -nosyslog -extpass "echo test" "$T/a" "$T/b"
# Cleanup trap # Cleanup trap
trap "cd /; fusermount -u -z $T/b; rm -Rf $T/a" EXIT trap "cd /; fusermount -u -z $T/b; rm -Rf $T/a" EXIT
@ -17,20 +17,20 @@ trap "cd /; fusermount -u -z $T/b; rm -Rf $T/a" EXIT
echo "Creating 40000 empty files (linux-3.0.tar.gz contains 36782 files)..." echo "Creating 40000 empty files (linux-3.0.tar.gz contains 36782 files)..."
SECONDS=0 SECONDS=0
for dir in $(seq -w 1 200); do for dir in $(seq -w 1 200); do
mkdir $T/b/$dir mkdir "$T/b/$dir"
( cd $T/b/$dir ; touch $(seq -w 1 200) ) ( cd "$T/b/$dir" ; touch $(seq -w 1 200) )
done done
echo "done, $SECONDS seconds" echo "done, $SECONDS seconds"
echo "Remount..." echo "Remount..."
fusermount -u $T/b fusermount -u "$T/b"
../gocryptfs -quiet -nosyslog -extpass "echo test" -cpuprofile $T/cprof -memprofile $T/mprof \ ../gocryptfs -quiet -nosyslog -extpass "echo test" -cpuprofile "$T/cprof" -memprofile "$T/mprof" \
$T/a $T/b "$T/a" "$T/b"
echo "Running ls under profiler (3x)..." echo "Running ls under profiler (3x)..."
for i in 1 2 3; do for i in 1 2 3; do
SECONDS=0 SECONDS=0
ls -lR $T/b > /dev/null ls -lR "$T/b" > /dev/null
echo "$i done, $SECONDS seconds" echo "$i done, $SECONDS seconds"
done done

View File

@ -3,25 +3,25 @@
cd "$(dirname "$0")" cd "$(dirname "$0")"
T=$(mktemp -d) T=$(mktemp -d)
mkdir $T/a $T/b mkdir "$T/a" "$T/b"
../gocryptfs -init -quiet -scryptn 10 -extpass "echo test" $T/a ../gocryptfs -init -quiet -scryptn 10 -extpass "echo test" "$T/a"
../gocryptfs -quiet -extpass "echo test" $T/a $T/b ../gocryptfs -quiet -extpass "echo test" "$T/a" "$T/b"
# Cleanup trap # Cleanup trap
trap "cd /; fusermount -u -z $T/b; rm -Rf $T/a" EXIT trap "cd /; fusermount -u -z $T/b; rm -Rf $T/a" EXIT
# Write 100MB test file # Write 100MB test file
dd if=/dev/zero of=$T/b/zero bs=1M count=100 status=none dd if=/dev/zero of="$T/b/zero" bs=1M count=100 status=none
# Remount with profiling # Remount with profiling
fusermount -u $T/b fusermount -u "$T/b"
../gocryptfs -quiet -extpass "echo test" -cpuprofile $T/cprof -memprofile $T/mprof \ ../gocryptfs -quiet -extpass "echo test" -cpuprofile "$T/cprof" -memprofile "$T/mprof" \
$T/a $T/b "$T/a" "$T/b"
# Read 10 x 100MB instead of 1 x 1GB to keep the used disk space low # Read 10 x 100MB instead of 1 x 1GB to keep the used disk space low
for i in $(seq 1 10); do for i in $(seq 1 10); do
dd if=$T/b/zero of=/dev/null bs=1M count=100 dd if="$T/b/zero" of=/dev/null bs=1M count=100
done done
echo echo

View File

@ -3,18 +3,18 @@
cd "$(dirname "$0")" cd "$(dirname "$0")"
T=$(mktemp -d) T=$(mktemp -d)
mkdir $T/a $T/b mkdir "$T/a" "$T/b"
../gocryptfs -init -quiet -scryptn 10 -extpass "echo test" $T/a ../gocryptfs -init -quiet -scryptn 10 -extpass "echo test" "$T/a"
../gocryptfs -quiet -extpass "echo test" -cpuprofile $T/cprof -memprofile $T/mprof \ ../gocryptfs -quiet -extpass "echo test" -cpuprofile "$T/cprof" -memprofile "$T/mprof" \
$T/a $T/b "$T/a" "$T/b"
# Cleanup trap # Cleanup trap
trap "cd /; fusermount -u -z $T/b; rm -Rf $T/a" EXIT trap "cd /; fusermount -u -z $T/b; rm -Rf $T/a" EXIT
# Write 10 x 100MB instead of 1 x 1GB to keep the used disk space low # Write 10 x 100MB instead of 1 x 1GB to keep the used disk space low
for i in $(seq 1 10); do for i in $(seq 1 10); do
dd if=/dev/zero of=$T/b/zero bs=1M count=100 dd if=/dev/zero of="$T/b/zero" bs=1M count=100
done done
echo echo

View File

@ -6,17 +6,17 @@ cd "$(dirname "$0")"
../tests/dl-linux-tarball.bash ../tests/dl-linux-tarball.bash
T=$(mktemp -d) T=$(mktemp -d)
mkdir $T/a $T/b mkdir "$T/a" "$T/b"
../gocryptfs -init -quiet -scryptn 10 -extpass "echo test" $T/a ../gocryptfs -init -quiet -scryptn 10 -extpass "echo test" "$T/a"
../gocryptfs -quiet -extpass "echo test" -cpuprofile $T/cprof -memprofile $T/mprof \ ../gocryptfs -quiet -extpass "echo test" -cpuprofile "$T/cprof" -memprofile "$T/mprof" \
$T/a $T/b "$T/a" "$T/b"
# Cleanup trap # Cleanup trap
trap "cd /; fusermount -u -z $T/b; rm -Rf $T/a" EXIT trap "cd /; fusermount -u -z $T/b; rm -Rf $T/a" EXIT
echo "Extracting..." echo "Extracting..."
time tar xzf /tmp/linux-3.0.tar.gz -C $T/b time tar xzf /tmp/linux-3.0.tar.gz -C "$T/b"
echo echo
echo "Hint: go tool pprof ../gocryptfs $T/cprof" echo "Hint: go tool pprof ../gocryptfs $T/cprof"

View File

@ -6,17 +6,17 @@
cd "$(dirname "$0")" cd "$(dirname "$0")"
T=$(mktemp -d) T=$(mktemp -d)
mkdir $T/a $T/b mkdir "$T/a" "$T/b"
../gocryptfs -init -quiet -scryptn 10 -extpass "echo test" $T/a ../gocryptfs -init -quiet -scryptn 10 -extpass "echo test" "$T/a"
../gocryptfs -quiet -extpass "echo test" -trace $T/trace \ ../gocryptfs -quiet -extpass "echo test" -trace "$T/trace" \
$T/a $T/b "$T/a" "$T/b"
# Cleanup trap # Cleanup trap
trap "cd /; fusermount -u -z $T/b; rm -Rf $T/a" EXIT trap "cd /; fusermount -u -z $T/b; rm -Rf $T/a" EXIT
# Write only 1x100MB, otherwise the trace gets too big. # Write only 1x100MB, otherwise the trace gets too big.
dd if=/dev/zero of=$T/b/zero bs=1M count=100 dd if=/dev/zero of="$T/b/zero" bs=1M count=100
echo echo
echo "Hint: go tool trace $T/trace" echo "Hint: go tool trace $T/trace"

View File

@ -16,7 +16,7 @@ TESTDIR=$TMPDIR/gocryptfs-test-parent-$UID
mkdir -p "$TESTDIR" mkdir -p "$TESTDIR"
LOCKFILE=$TESTDIR/$MYNAME.lock LOCKFILE=$TESTDIR/$MYNAME.lock
function unmount_leftovers { unmount_leftovers() {
RET=0 RET=0
for i in $(mount | grep "$TESTDIR" | cut -f3 -d" "); do for i in $(mount | grep "$TESTDIR" | cut -f3 -d" "); do
echo "Warning: unmounting leftover filesystem: $i" echo "Warning: unmounting leftover filesystem: $i"

View File

@ -45,7 +45,7 @@ echo -n "UNTAR: "
etime tar xzf /tmp/linux-3.0.tar.gz etime tar xzf /tmp/linux-3.0.tar.gz
sleep 0.1 sleep 0.1
echo -n "MD5: " echo -n "MD5: "
etime md5sum --quiet -c $MD5 etime md5sum --quiet -c "$MD5"
sleep 0.1 sleep 0.1
echo -n "LS: " echo -n "LS: "
etime ls -lR linux-3.0 etime ls -lR linux-3.0

View File

@ -10,18 +10,18 @@ SIZE_WANT=96675825
SIZE_ACTUAL=0 SIZE_ACTUAL=0
if [[ -e $TGZ ]]; then if [[ -e $TGZ ]]; then
if [[ $OSTYPE == linux* ]] ; then if [[ $OSTYPE == linux* ]] ; then
SIZE_ACTUAL=$(stat -c %s $TGZ) SIZE_ACTUAL=$(stat -c %s "$TGZ")
else else
# Mac OS X # Mac OS X
SIZE_ACTUAL=$(stat -f %z $TGZ) SIZE_ACTUAL=$(stat -f %z "$TGZ")
fi fi
fi fi
if [[ $SIZE_ACTUAL -ne $SIZE_WANT ]]; then if [[ $SIZE_ACTUAL -ne $SIZE_WANT ]]; then
echo "Downloading linux-3.0.tar.gz" echo "Downloading linux-3.0.tar.gz"
if command -v wget > /dev/null ; then if command -v wget > /dev/null ; then
wget -nv --show-progress -c -O $TGZ $URL wget -nv --show-progress -c -O "$TGZ" "$URL"
else else
curl -o $TGZ $URL curl -o "$TGZ" "$URL"
fi fi
fi fi

View File

@ -5,7 +5,7 @@
# #
# This script can be sourced or executed directly. # This script can be sourced or executed directly.
# #
function fuse-unmount { fuse-unmount() {
local MYNAME=$(basename "$BASH_SOURCE") local MYNAME=$(basename "$BASH_SOURCE")
if [[ $# -eq 0 ]] ; then if [[ $# -eq 0 ]] ; then
echo "$MYNAME: missing argument" echo "$MYNAME: missing argument"

View File

@ -20,10 +20,10 @@ fi
rm -f b/* rm -f b/*
while [[ $LEN -le 255 ]]; do while [[ $LEN -le 255 ]]; do
touch b/$NAME || break touch "b/$NAME" || break
ELEN=$(ls a | wc -L) ELEN=$(ls a | wc -L)
echo $LEN $ELEN echo "$LEN $ELEN"
rm b/$NAME rm "b/$NAME"
NAME="${NAME}x" NAME="${NAME}x"
LEN=${#NAME} LEN=${#NAME}
done done

View File

@ -10,12 +10,12 @@ source ../fuse-unmount.bash
# Setup dirs # Setup dirs
../dl-linux-tarball.bash ../dl-linux-tarball.bash
cd /tmp cd /tmp
WD=$(mktemp -d /tmp/$MYNAME.XXX) WD=$(mktemp -d "/tmp/$MYNAME.XXX")
# Cleanup trap # Cleanup trap
trap "set +u; cd /; fuse-unmount -z $WD/c; fuse-unmount -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 cd "$WD"
mkdir a b c mkdir a b c
echo "Extracting tarball" echo "Extracting tarball"
tar -x -f /tmp/linux-3.0.tar.gz -C a tar -x -f /tmp/linux-3.0.tar.gz -C a
@ -30,4 +30,4 @@ gocryptfs -q -extpass="echo test" b c
cd c cd c
echo "Checking md5 sums" echo "Checking md5 sums"
set -o pipefail set -o pipefail
md5sum -c $MD5 | pv -l -s 36782 -N "files checked" | (grep -v ": OK" || true) md5sum -c "$MD5" | pv -l -s 36782 -N "files checked" | (grep -v ": OK" || true)

View File

@ -2,7 +2,7 @@
set -eu set -eu
function cleanup { cleanup() {
cd "$LOCAL_TMP" cd "$LOCAL_TMP"
fusermount -u gocryptfs.mnt fusermount -u gocryptfs.mnt
rm -Rf "$SSHFS_TMP" rm -Rf "$SSHFS_TMP"
@ -11,22 +11,22 @@ function cleanup {
rm -Rf "$LOCAL_TMP" rm -Rf "$LOCAL_TMP"
} }
function prepare_mounts { prepare_mounts() {
LOCAL_TMP=$(mktemp -d -t "$MYNAME.XXX") LOCAL_TMP=$(mktemp -d -t "$MYNAME.XXX")
cd $LOCAL_TMP cd "$LOCAL_TMP"
echo "working directory: $PWD" echo "working directory: $PWD"
mkdir sshfs.mnt gocryptfs.mnt mkdir sshfs.mnt gocryptfs.mnt
sshfs $HOST:/tmp sshfs.mnt sshfs "$HOST:/tmp" sshfs.mnt
echo "sshfs mounted: $HOST:/tmp -> sshfs.mnt" echo "sshfs mounted: $HOST:/tmp -> sshfs.mnt"
trap cleanup EXIT trap cleanup EXIT
SSHFS_TMP=$(mktemp -d "sshfs.mnt/$MYNAME.XXX") SSHFS_TMP=$(mktemp -d "sshfs.mnt/$MYNAME.XXX")
mkdir $SSHFS_TMP/gocryptfs.crypt mkdir "$SSHFS_TMP/gocryptfs.crypt"
gocryptfs -q -init -extpass "echo test" -scryptn=10 $SSHFS_TMP/gocryptfs.crypt gocryptfs -q -init -extpass "echo test" -scryptn=10 "$SSHFS_TMP/gocryptfs.crypt"
gocryptfs -q -extpass "echo test" $SSHFS_TMP/gocryptfs.crypt gocryptfs.mnt gocryptfs -q -extpass "echo test" "$SSHFS_TMP/gocryptfs.crypt" gocryptfs.mnt
echo "gocryptfs mounted: $SSHFS_TMP/gocryptfs.crypt -> gocryptfs.mnt" echo "gocryptfs mounted: $SSHFS_TMP/gocryptfs.crypt -> gocryptfs.mnt"
} }
function etime { etime() {
T=$(/usr/bin/time -f %e -o /dev/stdout "$@") T=$(/usr/bin/time -f %e -o /dev/stdout "$@")
LC_ALL=C printf %20.2f "$T" LC_ALL=C printf %20.2f "$T"
} }

View File

@ -28,17 +28,17 @@ source ../fuse-unmount.bash
# Setup dirs # Setup dirs
../dl-linux-tarball.bash ../dl-linux-tarball.bash
cd $TMPDIR cd "$TMPDIR"
EXTRACTLOOP_TMPDIR=$TMPDIR/extractloop_tmpdir EXTRACTLOOP_TMPDIR=$TMPDIR/extractloop_tmpdir
mkdir -p $EXTRACTLOOP_TMPDIR mkdir -p "$EXTRACTLOOP_TMPDIR"
CRYPT=$(mktemp -d $EXTRACTLOOP_TMPDIR/XXX) CRYPT=$(mktemp -d "$EXTRACTLOOP_TMPDIR/XXX")
CSV=$CRYPT.csv CSV=$CRYPT.csv
MNT=$CRYPT.mnt MNT=$CRYPT.mnt
mkdir $MNT mkdir "$MNT"
function check_md5sums { check_md5sums() {
if command -v md5sum > /dev/null ; then if command -v md5sum > /dev/null ; then
md5sum --status -c $1 md5sum --status -c "$1"
else else
# MacOS / darwin which do not have the md5sum utility # MacOS / darwin which do not have the md5sum utility
# installed by default # installed by default
@ -52,50 +52,50 @@ FS=""
if [ $# -eq 1 ] && [ "$1" == "-encfs" ]; then if [ $# -eq 1 ] && [ "$1" == "-encfs" ]; then
FS=encfs FS=encfs
echo "Testing EncFS" echo "Testing EncFS"
encfs --extpass="echo test" --standard $CRYPT $MNT > /dev/null encfs --extpass="echo test" --standard "$CRYPT" "$MNT" > /dev/null
elif [ $# -eq 1 ] && [ "$1" == "-loopback" ]; then elif [ $# -eq 1 ] && [ "$1" == "-loopback" ]; then
FS=loopback FS=loopback
echo "Testing go-fuse loopback" echo "Testing go-fuse loopback"
rm -f /tmp/loopback*.memprof rm -f /tmp/loopback*.memprof
loopback -memprofile=/tmp/loopback $MNT $CRYPT & loopback -memprofile=/tmp/loopback "$MNT" "$CRYPT" &
FSPID=$(jobs -p) FSPID=$(jobs -p)
disown disown
else else
FS=gocryptfs FS=gocryptfs
echo "Testing gocryptfs" echo "Testing gocryptfs"
gocryptfs -q -init -extpass="echo test" -scryptn=10 $CRYPT gocryptfs -q -init -extpass="echo test" -scryptn=10 "$CRYPT"
gocryptfs -q -extpass="echo test" -nosyslog -fg $CRYPT $MNT & gocryptfs -q -extpass="echo test" -nosyslog -fg "$CRYPT" "$MNT" &
FSPID=$(jobs -p) FSPID=$(jobs -p)
disown disown
#gocryptfs -q -extpass="echo test" -nosyslog -memprofile /tmp/extractloop-mem $CRYPT $MNT #gocryptfs -q -extpass="echo test" -nosyslog -memprofile /tmp/extractloop-mem "$CRYPT" "$MNT"
fi fi
echo "Test dir: $CRYPT" echo "Test dir: $CRYPT"
# Sleep to make sure the FS is already mounted on MNT # Sleep to make sure the FS is already mounted on MNT
sleep 1 sleep 1
cd $MNT cd "$MNT"
ln -v -sTf $CSV /tmp/extractloop.csv 2> /dev/null || true # fails on MacOS, ignore ln -v -sTf "$CSV" /tmp/extractloop.csv 2> /dev/null || true # fails on MacOS, ignore
# Cleanup trap # Cleanup trap
# Note: gocryptfs may have already umounted itself because bash relays SIGINT # Note: gocryptfs may have already umounted itself because bash relays SIGINT
# Just ignore unmount errors. # Just ignore unmount errors.
trap cleanup_exit EXIT trap cleanup_exit EXIT
function cleanup_exit { cleanup_exit() {
if [[ $FS == loopback ]]; then if [[ $FS == loopback ]]; then
# SIGUSR1 causes loopback to write the memory profile to disk # SIGUSR1 causes loopback to write the memory profile to disk
kill -USR1 $FSPID kill -USR1 $FSPID
fi fi
cd / cd /
rm -Rf $CRYPT rm -Rf "$CRYPT"
fuse-unmount -z $MNT || true fuse-unmount -z "$MNT" || true
rmdir $MNT rmdir "$MNT"
} }
function loop { loop() {
ID=$1 ID=$1
mkdir $ID mkdir "$ID"
cd $ID cd "$ID"
echo "[looper $ID] Starting" echo "[looper $ID] Starting"
@ -107,20 +107,20 @@ function loop {
tar xf /tmp/linux-3.0.tar.gz --exclude linux-3.0/arch/microblaze/boot/dts/system.dts tar xf /tmp/linux-3.0.tar.gz --exclude linux-3.0/arch/microblaze/boot/dts/system.dts
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Exclude the one symlink in the tarball - causes problems on MacOS: "Can't set permissions to 0755" # Exclude the one symlink in the tarball - causes problems on MacOS: "Can't set permissions to 0755"
check_md5sums $MD5 check_md5sums "$MD5"
rm -R linux-3.0 rm -R linux-3.0
t2=$SECONDS t2=$SECONDS
delta=$((t2-t1)) delta=$((t2-t1))
if [[ $FSPID -gt 0 && -d /proc ]]; then if [[ $FSPID -gt 0 && -d /proc ]]; then
RSS=$(grep VmRSS /proc/$FSPID/status | tr -s ' ' | cut -f2 -d ' ') RSS=$(grep VmRSS /proc/$FSPID/status | tr -s ' ' | cut -f2 -d ' ')
echo "$N,$SECONDS,$RSS,$delta" >> $CSV echo "$N,$SECONDS,$RSS,$delta" >> "$CSV"
fi fi
echo "[looper $ID] Iteration $N done, $delta seconds, RSS $RSS kiB" echo "[looper $ID] Iteration $N done, $delta seconds, RSS $RSS kiB"
let N=$N+1 N=$((N+1))
done done
} }
function memprof { memprof() {
while true; do while true; do
kill -USR1 $FSPID kill -USR1 $FSPID
sleep 60 sleep 60

View File

@ -19,7 +19,7 @@ export TMPDIR=${TMPDIR:-/var/tmp}
DEBUG=${DEBUG:-0} DEBUG=${DEBUG:-0}
cd "$(dirname "$0")" cd "$(dirname "$0")"
MYNAME=$(basename $0) MYNAME=$(basename "$0")
source ../fuse-unmount.bash source ../fuse-unmount.bash
# fsstress binary # fsstress binary
@ -32,23 +32,23 @@ then
fi fi
# Backing directory # Backing directory
DIR=$(mktemp -d $TMPDIR/$MYNAME.XXX) DIR=$(mktemp -d "$TMPDIR/$MYNAME.XXX")
# Mountpoint # Mountpoint
MNT="$DIR.mnt" MNT="$DIR.mnt"
mkdir $MNT mkdir "$MNT"
# Set the GOPATH variable to the default if it is empty # Set the GOPATH variable to the default if it is empty
GOPATH=$(go env GOPATH) GOPATH=$(go env GOPATH)
# Clean up old mounts # Clean up old mounts
for i in $(mount | cut -d" " -f3 | grep $TMPDIR/$MYNAME) ; do for i in $(mount | cut -d" " -f3 | grep "$TMPDIR/$MYNAME") ; do
fusermount -u $i fusermount -u "$i"
done done
# FS-specific compile and mount # FS-specific compile and mount
if [[ $MYNAME = fsstress-loopback.bash ]]; then if [[ $MYNAME = fsstress-loopback.bash ]]; then
echo -n "Recompile go-fuse loopback: " echo -n "Recompile go-fuse loopback: "
cd $GOPATH/src/github.com/hanwen/go-fuse/example/loopback cd "$GOPATH/src/github.com/hanwen/go-fuse/example/loopback"
git describe git describe
go build && go install go build && go install
OPTS="-q" OPTS="-q"
@ -59,20 +59,20 @@ if [[ $MYNAME = fsstress-loopback.bash ]]; then
disown disown
elif [[ $MYNAME = fsstress-gocryptfs.bash ]]; then elif [[ $MYNAME = fsstress-gocryptfs.bash ]]; then
echo "Recompile gocryptfs" echo "Recompile gocryptfs"
cd $GOPATH/src/github.com/rfjakob/gocryptfs cd "$GOPATH/src/github.com/rfjakob/gocryptfs"
./build.bash # also prints the version ./build.bash # also prints the version
$GOPATH/bin/gocryptfs -q -init -extpass "echo test" -scryptn=10 $DIR $GOPATH/bin/gocryptfs -q -init -extpass "echo test" -scryptn=10 "$DIR"
$GOPATH/bin/gocryptfs -q -extpass "echo test" -nosyslog -fusedebug=$DEBUG $DIR $MNT $GOPATH/bin/gocryptfs -q -extpass "echo test" -nosyslog -fusedebug="$DEBUG" "$DIR" "$MNT"
elif [[ $MYNAME = fsstress-encfs.bash ]]; then elif [[ $MYNAME = fsstress-encfs.bash ]]; then
encfs --extpass "echo test" --standard $DIR $MNT encfs --extpass "echo test" --standard "$DIR" "$MNT"
else else
echo Unknown mode: $MYNAME echo "Unknown mode: $MYNAME"
exit 1 exit 1
fi fi
sleep 0.5 sleep 0.5
echo -n "Waiting for mount: " echo -n "Waiting for mount: "
while ! grep "$(basename $MNT) fuse" /proc/self/mounts > /dev/null while ! grep "$(basename "$MNT") fuse" /proc/self/mounts > /dev/null
do do
sleep 1 sleep 1
echo -n x echo -n x
@ -87,26 +87,26 @@ N=1
while true while true
do do
echo "$N ................................. $(date)" echo "$N ................................. $(date)"
mkdir $MNT/fsstress.1 mkdir "$MNT/fsstress.1"
echo -n " fsstress.1 " echo -n " fsstress.1 "
$FSSTRESS -r -m 8 -n 1000 -d $MNT/fsstress.1 & $FSSTRESS -r -m 8 -n 1000 -d "$MNT/fsstress.1" &
wait wait
mkdir $MNT/fsstress.2 mkdir "$MNT/fsstress.2"
echo -n " fsstress.2 " echo -n " fsstress.2 "
$FSSTRESS -p 20 -r -m 8 -n 1000 -d $MNT/fsstress.2 & $FSSTRESS -p 20 -r -m 8 -n 1000 -d "$MNT/fsstress.2" &
wait wait
mkdir $MNT/fsstress.3 mkdir "$MNT/fsstress.3"
echo -n " fsstress.3 " echo -n " fsstress.3 "
$FSSTRESS -p 4 -z -f rmdir=10 -f link=10 -f creat=10 -f mkdir=10 \ $FSSTRESS -p 4 -z -f rmdir=10 -f link=10 -f creat=10 -f mkdir=10 \
-f rename=30 -f stat=30 -f unlink=30 -f truncate=20 -m 8 \ -f rename=30 -f stat=30 -f unlink=30 -f truncate=20 -m 8 \
-n 1000 -d $MNT/fsstress.3 & -n 1000 -d "$MNT/fsstress.3" &
wait wait
echo " rm" echo " rm"
rm -Rf $MNT/* rm -Rf "$MNT"/*
let N=$N+1 N=$((N+1))
done done

View File

@ -18,32 +18,32 @@ if [[ -z $TMPDIR ]]; then
fi fi
cd "$(dirname "$0")" cd "$(dirname "$0")"
MYNAME=$(basename $0) MYNAME=$(basename "$0")
source ../fuse-unmount.bash source ../fuse-unmount.bash
# Set the GOPATH variable to the default if it is empty # Set the GOPATH variable to the default if it is empty
GOPATH=$(go env GOPATH) GOPATH=$(go env GOPATH)
# Backing directory # Backing directory
DIR=$(mktemp -d $TMPDIR/$MYNAME.XXX) DIR=$(mktemp -d "$TMPDIR/$MYNAME.XXX")
$GOPATH/bin/gocryptfs -q -init -extpass "echo test" -scryptn=10 $DIR $GOPATH/bin/gocryptfs -q -init -extpass "echo test" -scryptn=10 "$DIR"
# Mountpoint # Mountpoint
MNT="$DIR.mnt" MNT="$DIR.mnt"
mkdir $MNT mkdir "$MNT"
$GOPATH/bin/gocryptfs -q -extpass "echo test" -nosyslog $DIR $MNT $GOPATH/bin/gocryptfs -q -extpass "echo test" -nosyslog "$DIR" "$MNT"
echo "Mounted gocryptfs $DIR at $MNT" echo "Mounted gocryptfs $DIR at $MNT"
# Cleanup trap # Cleanup trap
trap "cd / ; fuse-unmount -z $MNT ; rm -rf $DIR $MNT" EXIT trap "cd / ; fuse-unmount -z $MNT ; rm -rf $DIR $MNT" EXIT
cd $MNT cd "$MNT"
SECONDS=0 SECONDS=0
echo "creating files with dd" echo "creating files with dd"
mkdir -p origin mkdir -p origin
for i in $(seq 1 778) ; do for i in $(seq 1 778) ; do
dd if=/dev/zero of=origin/file_$i bs=8192 count=1 status=none dd if=/dev/zero of="origin/file_$i" bs=8192 count=1 status=none
done done
# Perform the shell expansion only once and store the list # Perform the shell expansion only once and store the list
ORIGIN_FILES=origin/* ORIGIN_FILES=origin/*
@ -51,7 +51,7 @@ ORIGIN_FILES=origin/*
echo -n "cp starting: " echo -n "cp starting: "
for i in $(seq 1 100) ; do for i in $(seq 1 100) ; do
echo -n "$i " echo -n "$i "
(mkdir sub_$i && cp $ORIGIN_FILES sub_$i ; echo -n "$i ") & (mkdir "sub_$i" && cp $ORIGIN_FILES "sub_$i" ; echo -n "$i ") &
done done
echo echo

View File

@ -13,7 +13,7 @@ renice 19 $$
cd "$(dirname "$0")" cd "$(dirname "$0")"
MD5="$PWD/linux-3.0.md5sums" MD5="$PWD/linux-3.0.md5sums"
MYNAME=$(basename $0) MYNAME=$(basename "$0")
source ../fuse-unmount.bash source ../fuse-unmount.bash
# Setup # Setup
@ -22,48 +22,48 @@ cd /tmp
PING=$(mktemp -d ping.XXX) PING=$(mktemp -d ping.XXX)
PONG=$(mktemp -d pong.XXX) PONG=$(mktemp -d pong.XXX)
mkdir $PING.mnt $PONG.mnt mkdir "$PING.mnt" "$PONG.mnt"
# Cleanup trap # Cleanup trap
# Note: gocryptfs may have already umounted itself because bash relays SIGINT # Note: gocryptfs may have already umounted itself because bash relays SIGINT
# Just ignore unmount errors. # 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 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 "$PING"
gocryptfs -q -init -extpass="echo test" -scryptn=10 $PONG gocryptfs -q -init -extpass="echo test" -scryptn=10 "$PONG"
gocryptfs -q -extpass="echo test" -nosyslog $PING $PING.mnt gocryptfs -q -extpass="echo test" -nosyslog "$PING" "$PING.mnt"
gocryptfs -q -extpass="echo test" -nosyslog $PONG $PONG.mnt gocryptfs -q -extpass="echo test" -nosyslog "$PONG" "$PONG.mnt"
echo "Initial extract" echo "Initial extract"
tar xf /tmp/linux-3.0.tar.gz -C $PING.mnt tar xf /tmp/linux-3.0.tar.gz -C "$PING.mnt"
function move_and_md5 { move_and_md5() {
if [ $MYNAME = pingpong-rsync.bash ]; then if [ "$MYNAME" = "pingpong-rsync.bash" ]; then
echo -n "rsync " echo -n "rsync "
rsync -a --remove-source-files $1 $2 rsync -a --remove-source-files "$1" "$2"
find $1 -type d -delete find "$1" -type d -delete
else else
echo -n "mv " echo -n "mv "
mv $1 $2 mv "$1" "$2"
fi fi
if [ -e $1 ]; then if [ -e "$1" ]; then
echo "error: source directory $1 was not removed" echo "error: source directory $1 was not removed"
exit 1 exit 1
fi fi
cd $2 cd "$2"
echo -n "md5 " echo -n "md5 "
md5sum --status -c $MD5 md5sum --status -c "$MD5"
cd .. cd ..
} }
N=1 N=1
while true; do while true; do
echo -n "$N: " echo -n "$N: "
move_and_md5 $PING.mnt/linux-3.0 $PONG.mnt move_and_md5 "$PING.mnt/linux-3.0" "$PONG.mnt"
move_and_md5 $PONG.mnt/linux-3.0 $PING.mnt move_and_md5 "$PONG.mnt/linux-3.0" "$PING.mnt"
date +%H:%M:%S date +%H:%M:%S
let N=$N+1 N=$((N+1))
done done
wait wait