#!/bin/sh
#
# Try to reproduce HJ's problem.
#

usage()
{
	echo "Usage: hj /path/to/ext3/dir"
	exit 1
}

once()
{
	FILENAME=$EXT3_DIR/$1
	$TOOLS/owcmuowc $FILENAME.a $FILENAME.b
	if ! $TOOLS/owcmuowc $FILENAME.a $FILENAME.b
	then
		echo Creation with $FILENAME.b
		exit 1
	fi
	if ! $TOOLS/check-hacked-dbench-file $FILENAME.b
	then
		echo Check failure with $FILENAME.b
		exit 1
	fi
}

many()
{
	while true
	do
		once $1
	done
}

if [ $# != 1 ]
then
	usage
fi

EXT3_DIR=$1
TOOLS=$(/bin/pwd)/../tools

for i in 0 1 2 3 4 5 6 7 8 9
do
	many $i &
done

while true
do
	sync
done
