SCRIPTLINKS += hyperspec
SCRIPTLINKS += datasyms
SCRIPTLINKS += check-debsyms
+SCRIPTLINKS += check-blkdev-size
## Random odds and ends.
DOTLINKS += .infokey .sqliterc
--- /dev/null
+#! /bin/bash
+
+set -e -o pipefail
+
+case $# in 1) ;; *) echo >&2 "usage: $0 DEV"; exit 127 ;; esac
+dev=$1
+
+typeset -i sz; sz=$(blockdev --getsize64 "$dev")
+k=$(gorp -fhex 256)
+
+## Figure out a useful block size.
+typeset -i bsz=1 nb=$sz
+for i in 2 3 5 7; do
+ while :; do
+ case $((nb%i)) in
+ 0) bsz=$((bsz*i)) nb=$((nb/i)) ;;
+ *) break ;;
+ esac
+ if (( bsz >= 65536 )); then break 2; fi
+ done
+done
+echo >&2 "$0: using $nb blocks of size $bsz"
+
+## Write the initial stream.
+echo >&2 "$0: writing pseudorandom pattern..."
+rspit salsa20/8 -H$k -z$sz -pT | \
+ dd status=none iflag=fullblock oflag=direct bs=$bsz count=$nb of="$dev"
+echo >&2 "$0: writing pseudorandom pattern... done"
+
+## Read the stream back, and check against the reference.
+echo >&2 "$0: checking pseudorandom pattern..."
+cmp <(rspit salsa20/8 -H$k -z$sz -pT) \
+ <(dd status=none iflag=direct bs=$bsz count=$nb if="$dev")
+echo >&2 "$0: checking pseudorandom pattern... done"
+echo >&2 "$0: all ok"