
umask 0

doit()
{
	echo $*
	$* || {
		echo Command $* failed
		exit 1
	}
}

mount_fs()
{
	if [ x"$*" != "x" -a x"$USER_MOUNT_OPTIONS" != x ]
	then
		OPTS="$*","$USER_MOUNT_OPTIONS"
	else
		OPTS="$*"
	fi
	date
	doit mount $DEVICE $MOUNT_POINT -t ext3 $OPTS
}

run_test_script()
{
	echo ./$TEST_SCRIPT $MOUNT_POINT
	./$TEST_SCRIPT $MOUNT_POINT &
}

wait_for_readonly()
{
	doit ../tools/wait-for-readonly $MOUNT_POINT
}

kill_test_script()
{
	things_to_kill=$(grep THINGS_TO_KILL $TEST_SCRIPT)
	things_to_kill=$(echo $things_to_kill | sed -e 's/#THINGS_TO_KILL//')
	echo killall -w $things_to_kill
	killall -w $things_to_kill
}

unmount_fs()
{
	date
	doit umount $DEVICE
}

run_e2fsck()
{
	doit e2fsck "$@" $DEVICE
}

run_chdf()
{
	DIR=$MOUNT_POINT/dbench/CLIENTS
	count=$(find $DIR -type f | wc -w)
	echo run ../tools/check-hacked-dbench-file against $count files
	../tools/check-hacked-dbench-file $(find $DIR -type f) || exit 1
}

remove_dbench_files()
{
	DIR=$MOUNT_POINT/dbench/CLIENTS
	echo rm -rf $DIR
	rm -rf $DIR
}

modify_period_of_time()
{
	PERIOD_OF_TIME=$(expr $PERIOD_OF_TIME + 100)
	if [ $PERIOD_OF_TIME -gt $MAX_JIFFIES ]
	then
		PERIOD_OF_TIME=$MIN_JIFFIES
	fi
}

