#!/bin/sh

iterations=1000
d1=/dev/loop1
d2=/dev/loop2
d3=/dev/loop3
d4=/dev/loop4


#Forward parity
#d3 d4  d1   d2
order="\
    $d4 $d1 $d2 \
$d3     $d1 $d2 \
$d3 $d4     $d2 \
$d3 $d4 $d1    "

#Backward parity
#d3 d4  d1   d2
order="\
$d3 $d4 $d1     \
$d3 $d4     $d2 \
$d3     $d1 $d2 \
    $d4 $d1 $d2"
sector=1K
outfile=/mnt/sdb1/buffalo-rips/unstriped-raid.fs

rm -f $outfile
cnt=0
loop=0
while [ $cnt -lt $iterations ]; do
  for i in $order; do
    echo "loop=$loop cnt=$cnt"
#    echo dd if=$i bs=$sector skip=$cnt count=1
    dd if=$i bs=$sector skip=$cnt count=1 >> $outfile 2> /dev/null
    loop=$(($loop+1))
    if [ $loop -eq 3 ]; then
      cnt=$(($cnt + 1))
      loop=0
    fi
  done
done