
#make bulk files, check for space free

function spaceabort()
{
 echo
 echo "ERROR: not enough free space in $bulkdir to hold temporary files."
 echo " Please create more space (e.g. by compressing some files)"
 echo " or reconfigure this program to use another filesystem (see the README file)."
 echo "At least $[$disksize / 512 ] Kb. free space is needed."
 doabort
}

echo "  [Allocating disk space for temporary storage of floppy contents.]"

#make floppy file
if ! dd if=/dev/zero of=/tmp/tbup/bulk/floppy \
     bs=1024 count=$disksizek 2>/dev/null;
 then spaceabort; fi

if [ `ls -l /tmp/tbup/bulk/floppy |gawk '{print $5}' ` != $disksize ]; 
 then spaceabort; fi

#make part file
if ! dd if=/dev/zero of=/tmp/tbup/bulk/part \
     bs=1024 count=$psizek 2>/dev/null;
 then spaceabort; fi

if [ $eccmethod = none ]; then sync; fi

if [ `ls -l /tmp/tbup/bulk/part |gawk '{print $5}' ` != $psize ]; 
 then spaceabort; fi

#make ecor file if needed
if [ $eccmethod != none ]; then

 if ! dd if=/dev/zero of=/tmp/tbup/bulk/ecor \
      bs=1024 count=$eccsizek 2>/dev/null;
  then spaceabort; fi

#for good luck
 sync

 if [ `ls -l /tmp/tbup/bulk/ecor |gawk '{print $5}' ` != $[$eccsizek * 1024] ]; 
  then spaceabort; fi

fi


unset spaceabort
