code: mafs

ref: 9b76881a8e11c44aae5dfd447e1cd1bc074ec9f3
dir: /tests/check.rc/

View raw version
#!/bin/rc

t=$1
disk=$2
nblocks=$3

# check the contents
#for(b in `{seq 0 1 `{echo $nblocks ' 1 - p' | dc}}){
#	file=$t/blocks/^$b
#	test -f $file &&
#		@{ # to avoid warning: process exceeds 200 file descriptors
#			> /tmp/^$t^.out >[2]/tmp/^$t^.err \
#			diff <{grep -v '^mtime' $file} \
#				<{disk/block $disk $b | grep -v '^mtime'} ||
#			{
#				echo $file
#				cat /tmp/^$t^.out
#				cat /tmp/^$t^.err
#			}
#		}
#}
#rm /tmp/^$t^*

for(file in $t/blocks/*){
	diff <{grep -v '^mtime' $file} \
		<{disk/block $disk `{basename $file} | grep -v '^mtime'} ||
			echo '	' $file failed
}

# reconcile the used and free blocks
echo reconcile $disk $nblocks
disk/reconcile -u <{disk/used $disk} -F <{disk/free $disk} $nblocks

diff <{disk/unused $nblocks <{disk/used $disk}} \
	 <{disk/free $disk} || echo unused and free do not match up