#! /opt/bin/dash # # os/prog/raid/post.sh # uses non-standard -d,--dups option to avoid duplicate addresses export PATH="/opt/bin:/bin:/usr/bin" echo "Content-type: text/html\n\n
$in\n" #exit n="6"; R="25" case "$h" in "L1R") p="L1R"; L="1"; r="-r"; s="123456789";; "L1") p="L1"; L="1"; r=""; s="123456789";; "L0R") p="L0R"; L="0"; r="-r"; s="123456789";; *) p="L0"; L="0"; r=""; s="123456789";; esac if [ -n "$useed" ]; then seed="$useed" msg="- seed = $seed" else x=$(perl -e "print unpack(\"C*\",$user);"); seed="${s}${x}" #echo "
s = $s, x = $x, seed = $seed" msg="" fi echo "$user - raid results $msg
green = correct |
red = wrong |
4 disks: RAID Level $L
" #echo "
" #python3 ./raid.py -d -s "$seed" -n "$n" -R "$R" -L "$L" "$r" -c | egrep '^(LOGICAL| read)' #echo "" out=$( (echo "$in"; python3 ./raid.py -d -s "$seed" -n "$n" -R "$R" -L "$L" "$r" -c) | awk -v "r=$r" 'BEGIN { v=0; print "
Address | Disk | Offset | Disk | Offset | Address | "; } { # user input: U name value # raid.py input: LOGICAL READ from addr:4205 size:4096 # or: read [disk 1, offset 1051] if( $1 != "") { if( $1 == "U") u[$2]=$3; else if( $1 == "LOGICAL") { split($4,t,":"); a=t[2]; } else if( $1 == "read") { d=$3; o=$5; gsub(/[^[:digit:]]/,"",d); gsub(/[^[:digit:]]/,"",o); if(r=="") { print "
---|---|---|
"a" | "; x=u["v"v"d"]; if( x != "" && x == d) color="#90EE90"; else color="#FF6347"; print ""x" | "; x=u["v"v"o"]; if( x != "" && x == o) color="#90EE90"; else color="#FF6347"; print ""x" | "; } else { print "
"d" | "o" | "; x=u["v"v"a"]; if( x != "" && x == a) color="#90EE90"; else color="#FF6347"; print ""x" | "; } print "