chiark / gitweb /
bin/check-blkdev-size: Don't print the full path in witter lines.
[profile] / bin / check-blkdev-size
CommitLineData
a98bca79
MW
1#! /bin/bash
2
3set -e -o pipefail
b2e9fb7e 4prog=${0##*/}
a98bca79 5
b2e9fb7e 6case $# in 1) ;; *) echo >&2 "usage: $prog DEV"; exit 127 ;; esac
a98bca79
MW
7dev=$1
8
9typeset -i sz; sz=$(blockdev --getsize64 "$dev")
10k=$(gorp -fhex 256)
11
12## Figure out a useful block size.
13typeset -i bsz=1 nb=$sz
14for i in 2 3 5 7; do
15 while :; do
16 case $((nb%i)) in
17 0) bsz=$((bsz*i)) nb=$((nb/i)) ;;
18 *) break ;;
19 esac
20 if (( bsz >= 65536 )); then break 2; fi
21 done
22done
b2e9fb7e 23echo >&2 "$prog: using $nb blocks of size $bsz"
a98bca79
MW
24
25## Write the initial stream.
b2e9fb7e 26echo >&2 "$prog: writing pseudorandom pattern..."
a98bca79
MW
27rspit salsa20/8 -H$k -z$sz -pT | \
28 dd status=none iflag=fullblock oflag=direct bs=$bsz count=$nb of="$dev"
b2e9fb7e 29echo >&2 "$prog: writing pseudorandom pattern... done"
a98bca79
MW
30
31## Read the stream back, and check against the reference.
b2e9fb7e 32echo >&2 "$prog: checking pseudorandom pattern..."
a98bca79
MW
33cmp <(rspit salsa20/8 -H$k -z$sz -pT) \
34 <(dd status=none iflag=direct bs=$bsz count=$nb if="$dev")
b2e9fb7e
MW
35echo >&2 "$prog: checking pseudorandom pattern... done"
36echo >&2 "$prog: all ok"