2003-04-18 22:20:46 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# $FreeBSD$
|
|
|
|
|
|
|
|
TMP=/tmp/$$.
|
|
|
|
set -e
|
2003-06-07 09:09:39 +00:00
|
|
|
for TEST in "i386 512" "i386 4096" "alpha 512"
|
2003-04-18 22:20:46 +00:00
|
|
|
do
|
2003-06-02 14:19:31 +00:00
|
|
|
set $TEST
|
|
|
|
ARCH=$1
|
|
|
|
SEC=$2
|
|
|
|
echo "ARCH $ARCH SEC $SEC"
|
|
|
|
MD=`mdconfig -a -t malloc -s 2m -S $SEC`
|
2003-05-02 19:12:20 +00:00
|
|
|
trap "exec 7</dev/null; rm -f ${TMP}* ; mdconfig -d -u ${MD}" EXIT INT TERM
|
|
|
|
|
|
|
|
./bsdlabel -m ${ARCH} -r -w $MD auto
|
|
|
|
|
2003-06-02 14:19:31 +00:00
|
|
|
dd if=/dev/$MD of=${TMP}i0 count=1 bs=8k > /dev/null 2>&1
|
2003-05-02 19:12:20 +00:00
|
|
|
if [ "$ARCH" = "alpha" ] ; then
|
|
|
|
dd if=${TMP}i0 of=${TMP}b0 iseek=1 count=15 > /dev/null 2>&1
|
|
|
|
else
|
|
|
|
cp ${TMP}i0 ${TMP}b0
|
|
|
|
fi
|
|
|
|
./bsdlabel -m ${ARCH} $MD > ${TMP}l0
|
|
|
|
|
|
|
|
sed '
|
|
|
|
/ c:/{
|
|
|
|
p
|
|
|
|
s/c:/a:/
|
|
|
|
s/4096/1024/
|
2003-06-02 14:19:31 +00:00
|
|
|
s/512/64/
|
2003-05-02 19:12:20 +00:00
|
|
|
}
|
|
|
|
' ${TMP}l0 > ${TMP}l1
|
|
|
|
|
|
|
|
./bsdlabel -m ${ARCH} -R $MD ${TMP}l1
|
|
|
|
if [ -c /dev/${MD}a ] ; then
|
|
|
|
echo "PASS: Created a: partition" 1>&2
|
2003-04-18 22:20:46 +00:00
|
|
|
else
|
2003-05-02 19:12:20 +00:00
|
|
|
echo "FAIL: Did not create a: partition" 1>&2
|
2003-04-18 22:20:46 +00:00
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
2003-05-02 19:12:20 +00:00
|
|
|
# Spoil and rediscover
|
|
|
|
|
|
|
|
true > /dev/${MD}
|
|
|
|
if [ -c /dev/${MD}a ] ; then
|
|
|
|
echo "PASS: Recreated a: partition after spoilage" 1>&2
|
|
|
|
else
|
|
|
|
echo "FAIL: Did not recreate a: partition after spoilage" 1>&2
|
2003-04-18 22:20:46 +00:00
|
|
|
exit 2
|
2003-05-02 19:12:20 +00:00
|
|
|
fi
|
|
|
|
|
2003-06-02 14:19:31 +00:00
|
|
|
dd if=/dev/$MD of=${TMP}i1 count=1 bs=8k > /dev/null 2>&1
|
2003-05-02 19:12:20 +00:00
|
|
|
sed '
|
|
|
|
/ c:/{
|
|
|
|
p
|
|
|
|
s/c:/a:/
|
|
|
|
s/4096/2048/
|
2003-06-02 14:19:31 +00:00
|
|
|
s/512/256/
|
2003-05-02 19:12:20 +00:00
|
|
|
}
|
|
|
|
' ${TMP}l0 > ${TMP}l2
|
|
|
|
|
|
|
|
./bsdlabel -m ${ARCH} -R $MD ${TMP}l2
|
2003-06-02 14:19:31 +00:00
|
|
|
dd if=/dev/$MD of=${TMP}i2 count=1 bs=8k > /dev/null 2>&1
|
2003-05-02 19:12:20 +00:00
|
|
|
|
|
|
|
exec 7< /dev/${MD}a
|
|
|
|
|
|
|
|
for t in a c
|
|
|
|
do
|
2003-06-02 14:19:31 +00:00
|
|
|
if dd if=${TMP}i2 of=/dev/${MD}$t bs=8k 2>/dev/null ; then
|
2003-05-02 19:12:20 +00:00
|
|
|
echo "PASS: Could rewrite same label to ...$t while ...a open" 1>&2
|
|
|
|
else
|
|
|
|
echo "FAIL: Could not rewrite same label to ...$t while ...a open" 1>&2
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
2003-06-02 14:19:31 +00:00
|
|
|
if dd if=${TMP}i1 of=/dev/${MD}$t bs=8k 2>/dev/null ; then
|
2003-05-02 19:12:20 +00:00
|
|
|
echo "FAIL: Could label with smaller ...a to ...$t while ...a open" 1>&2
|
|
|
|
exit 2
|
|
|
|
else
|
|
|
|
echo "PASS: Could not label with smaller ...a to ...$t while ...a open" 1>&2
|
|
|
|
fi
|
|
|
|
|
|
|
|
if dd if=${TMP}i0 of=/dev/${MD}$t 2>/dev/null ; then
|
|
|
|
echo "FAIL: Could write label missing ...a to ...$t while ...a open" 1>&2
|
|
|
|
exit 2
|
|
|
|
else
|
|
|
|
echo "PASS: Could not write label missing ...a to ...$t while ...a open" 1>&2
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
exec 7< /dev/null
|
|
|
|
|
2003-06-02 14:19:31 +00:00
|
|
|
if dd if=${TMP}i0 of=/dev/${MD}c bs=8k 2>/dev/null ; then
|
2003-05-02 19:12:20 +00:00
|
|
|
echo "PASS: Could write missing ...a label to ...c" 1>&2
|
2003-04-18 22:20:46 +00:00
|
|
|
else
|
2003-05-02 19:12:20 +00:00
|
|
|
echo "FAIL: Could not write missing ...a label to ...c" 1>&2
|
|
|
|
exit 2
|
2003-04-18 22:20:46 +00:00
|
|
|
fi
|
|
|
|
|
2003-06-02 14:19:31 +00:00
|
|
|
if dd if=${TMP}i2 of=/dev/${MD}c bs=8k 2>/dev/null ; then
|
2003-05-02 19:12:20 +00:00
|
|
|
echo "PASS: Could write large ...a label to ...c" 1>&2
|
|
|
|
else
|
|
|
|
echo "FAIL: Could not write large ...a label to ...c" 1>&2
|
2003-04-18 22:20:46 +00:00
|
|
|
exit 2
|
2003-05-02 19:12:20 +00:00
|
|
|
fi
|
|
|
|
|
2003-06-02 14:19:31 +00:00
|
|
|
if dd if=${TMP}i1 of=/dev/${MD}c bs=8k 2>/dev/null ; then
|
2003-05-02 19:12:20 +00:00
|
|
|
echo "PASS: Could write small ...a label to ...c" 1>&2
|
2003-04-18 22:20:46 +00:00
|
|
|
else
|
2003-05-02 19:12:20 +00:00
|
|
|
echo "FAIL: Could not write small ...a label to ...c" 1>&2
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
2003-06-02 14:19:31 +00:00
|
|
|
if dd if=${TMP}i2 of=/dev/${MD}a bs=8k 2>/dev/null ; then
|
2003-05-02 19:12:20 +00:00
|
|
|
echo "PASS: Could increase size of ...a by writing to ...a" 1>&2
|
|
|
|
else
|
|
|
|
echo "FAIL: Could not increase size of ...a by writing to ...a" 1>&2
|
|
|
|
exit 2
|
2003-04-18 22:20:46 +00:00
|
|
|
fi
|
|
|
|
|
2003-06-02 14:19:31 +00:00
|
|
|
if dd if=${TMP}i1 of=/dev/${MD}a bs=8k 2>/dev/null ; then
|
2003-05-02 19:12:20 +00:00
|
|
|
echo "FAIL: Could decrease size of ...a by writing to ...a" 1>&2
|
|
|
|
exit 2
|
|
|
|
else
|
|
|
|
echo "PASS: Could not decrease size of ...a by writing to ...a" 1>&2
|
|
|
|
fi
|
|
|
|
|
2003-06-02 14:19:31 +00:00
|
|
|
if dd if=${TMP}i0 of=/dev/${MD}a bs=8k 2>/dev/null ; then
|
2003-05-02 19:12:20 +00:00
|
|
|
echo "FAIL: Could delete ...a by writing to ...a" 1>&2
|
|
|
|
exit 2
|
|
|
|
else
|
|
|
|
echo "PASS: Could not delete ...a by writing to ...a" 1>&2
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ./bsdlabel -m ${ARCH} -B -b ${TMP}b0 ${MD} ; then
|
|
|
|
if [ ! -c /dev/${MD}a ] ; then
|
|
|
|
echo "FAILED: Writing bootcode killed ...a" 1>&2
|
|
|
|
exit 2
|
|
|
|
else
|
|
|
|
echo "PASS: Could write bootcode while closed" 1>&2
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "FAILED: Could not write bootcode while closed" 1>&2
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
exec 7> /dev/${MD}c
|
2003-06-01 09:30:53 +00:00
|
|
|
if ./bsdlabel -m ${ARCH} -B -b ${TMP}b0 ${MD} ; then
|
2003-05-02 19:12:20 +00:00
|
|
|
if [ ! -c /dev/${MD}a ] ; then
|
|
|
|
echo "FAILED: Writing bootcode killed ...a" 1>&2
|
|
|
|
exit 2
|
|
|
|
else
|
|
|
|
echo "PASS: Could write bootcode while open" 1>&2
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "FAILED: Could not write bootcode while open" 1>&2
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
exec 7> /dev/null
|
|
|
|
|
2003-06-02 14:19:31 +00:00
|
|
|
if dd if=${TMP}i0 of=/dev/${MD}c bs=8k 2>/dev/null ; then
|
2003-05-02 19:12:20 +00:00
|
|
|
echo "PASS: Could delete ...a by writing to ...c" 1>&2
|
|
|
|
else
|
|
|
|
echo "FAIL: Could not delete ...a by writing to ...c" 1>&2
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
# XXX: need to add a 'b' partition and check for overlaps.
|
|
|
|
|
|
|
|
rm -f ${TMP}*
|
|
|
|
mdconfig -d -u ${MD}
|
|
|
|
|
|
|
|
done
|
|
|
|
trap "" EXIT INT TERM
|
2003-04-18 22:20:46 +00:00
|
|
|
exit 0
|