From cd8b719d663c908b9049c5c67f98130d5f2bdb23 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Tue, 9 Aug 2011 19:38:16 +0000 Subject: [PATCH] Made releng/auto_printsize ready for FreeBSD ("bash" linked to /bin/sh) --- releng/auto_printsize | 46 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/releng/auto_printsize b/releng/auto_printsize index 223ff870..fd00fab5 100755 --- a/releng/auto_printsize +++ b/releng/auto_printsize @@ -55,14 +55,51 @@ FILE_UPPER=10 printf "\n${SELF}: Generating sample tree in ${GEN_DATA_DIR} :\n" count=0 date -for ((i1=0; i1 < ${DIR_UPPER}/4; i1++)) + +# Hopefully the for-loops are much faster than while-loops with arithmetics +# This needs 7/4*DIR_UPPER+FILE_UPPER (= 66) while-iterations +# +i1_list= +i1=0 +o1=$(expr ${DIR_UPPER} / 4) +while test $i1 -lt $o1 do - for ((i2=0; i2 < ${DIR_UPPER}/2; i2++)) + i1_list="$i1_list $i1" + i1=$(expr $i1 + 1) +done +i2_list= +i2=0 +o2=$(expr ${DIR_UPPER} / 2) +while test $i2 -lt $o2 +do + i2_list="$i2_list $i2" + i2=$(expr $i2 + 1) +done +i3_list= +i3=0 +while test $i3 -lt ${DIR_UPPER} +do + i3_list="$i3_list $i3" + i3=$(expr $i3 + 1) +done +i_file_list= +i_file=0 +while test $i_file -lt ${FILE_UPPER} +do + i_file_list="$i_file_list $i_file" + i_file=$(expr $i_file + 1) +done +# +# plus 1/8*DIR_UPPER*DIR_UPPER*DIR_UPPER*FILE_UPPER (= 40960) for-iterations +# +for i1 in $i1_list +do + for i2 in $i2_list do - for ((i3=0; i3 < ${DIR_UPPER}; i3++)) + for i3 in $i3_list do mkdir -p ${GEN_DATA_DIR}/DirOne$i1/DirTwo$i2/DirThree$i3 - for ((i_file=0; i_file < ${FILE_UPPER}; i_file++)) + for i_file in $i_file_list do echo -n \ > ${GEN_DATA_DIR}/DirOne$i1/DirTwo$i2/DirThree$i3/File_${i_file} @@ -72,6 +109,7 @@ do done echo " ${count} files created ..." done + printf "done.\n" date du -s "${GEN_DATA_DIR}"