#!/bin/sh

# Populate a directory with lots of 8KB blocks

if [ $# -eq 0 ]
then
  echo "Error - number missing from command line argument"
  echo "Syntax: $0 numblocks"
  exit 1
fi
count=$1

set +x

TESTDIR=/disk/se1/fubob/testdir
SFSRODB=/disk/se1/fubob/build-O2/sfsrodb/sfsrodb
SFSHOSTKEY=/disk/se1/fubob/sfs_host_key
MYDB=/disk/se1/fubob/tests/chefs.rodb
CDN=sex.lcs.mit.edu
KEYMGR=@rb.lcs.mit.edu%8888,ejc5tqrrfw4j8qhemc8wrad6gsa79dxf
#TESTDIR=/Users/fubob/testdir
#SFSRODB=/Users/fubob/src/build-O2/sfsrodb/sfsrodb
#SFSHOSTKEY=/Users/fubob/sfs_host_key
#MYDB=/Users/fubob/rodb.rodb
#CDN=ring.isi.jhu.edu
#KEYMGR=@snafu.lcs.mit.edu%8888,fw49t6xtbxd6k7nh4kpfkz282smqne6n

#/bin/dd if=/dev/urandom of=$TESTDIR/0 bs=8192 count=1 conv=sync
#$SFSRODB -d $TESTDIR -s $SFSHOSTKEY -o $MYDB -h $CDN -k $KEYMGR -g 0 -f $count

i=0
while [ $i -lt $count ]
do
  echo "$i"
  /bin/dd if=/dev/urandom of=$TESTDIR/$i bs=8192 count=1 conv=sync
#  if ! $SFSRODB -d $TESTDIR -s $SFSHOSTKEY -o $MYDB -h $CDN -k $KEYMGR -g $i -u ; then
#   echo "oh no"
#   exit 1
#  fi
  i=`expr $i + 1`
done
