# check permission
CUR_USER=`env | grep USER= | cut -d "=" -f 2`
for i in $CUR_USER
do
    if [ $i = "root" ];then
        break
    else
        echo "require root permission(root/sudo)"
        exit
    fi
done

# create btrfs block device and mount
BLOCK_SIZE=`expr 512 \* 1024`

dd if=/dev/zero of=$HOME/test.img bs=1024 count=$BLOCK_SIZE
mkfs.btrfs -f $HOME/test.img

if [ ! -d "$HOME/tmpmnt" ]; then
	mkdir $HOME/tmpmnt
else
	rm -rf $HOME/tmpmnt
	mkdir $HOME/tmpmnt
fi

mount $HOME/test.img $HOME/tmpmnt

# implement test case
./myout

umount $HOME/tmpmnt
rm -rf $HOME/tmpmnt
rm -rf $HOME/test.img
