1#!/bin/sh 2# $FreeBSD: releng/11.0/tests/sys/geom/class/eli/readonly_test.sh 293821 2016-01-13 09:14:27Z ngie $ 3 4. $(dirname $0)/conf.sh 5 6base=`basename $0` 7sectors=100 8keyfile=`mktemp $base.XXXXXX` || exit 1 9mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1 10 11echo "1..11" 12 13dd if=/dev/random of=${keyfile} bs=512 count=16 >/dev/null 2>&1 14 15geli init -B none -P -K $keyfile md${no} 16if [ $? -eq 0 ]; then 17 echo "ok 1" 18else 19 echo "not ok 1" 20fi 21 22geli attach -r -p -k $keyfile md${no} 23if [ $? -eq 0 ]; then 24 echo "ok 2" 25else 26 echo "not ok 2" 27fi 28 29sh -c "true >/dev/md${no}.eli" 2>/dev/null 30if [ $? -ne 0 ]; then 31 echo "ok 3" 32else 33 echo "not ok 3" 34fi 35 36geli kill md${no} 37if [ $? -eq 0 ]; then 38 echo "ok 4" 39else 40 echo "not ok 4" 41fi 42 43# kill should detach provider... 44if [ ! -c /dev/md{$no}.eli ]; then 45 echo "ok 5" 46else 47 echo "not ok 5" 48fi 49 50# ...but not destroy the metadata. 51geli attach -r -p -k $keyfile md${no} 52if [ $? -eq 0 ]; then 53 echo "ok 6" 54else 55 echo "not ok 6" 56fi 57 58geli setkey -n 1 -P -K /dev/null md${no} 2>/dev/null 59if [ $? -ne 0 ]; then 60 echo "ok 7" 61else 62 echo "not ok 7" 63fi 64 65geli delkey -n 0 md${no} 2>/dev/null 66if [ $? -ne 0 ]; then 67 echo "ok 8" 68else 69 echo "not ok 8" 70fi 71 72geli delkey -f -n 0 md${no} 2>/dev/null 73if [ $? -ne 0 ]; then 74 echo "ok 9" 75else 76 echo "not ok 9" 77fi 78 79geli list md${no}.eli | egrep '^Flags: .*READ-ONLY' >/dev/null 80if [ $? -eq 0 ]; then 81 echo "ok 10" 82else 83 echo "not ok 10" 84fi 85 86geli detach md${no} 87if [ $? -eq 0 ]; then 88 echo "ok 11" 89else 90 echo "not ok 11" 91fi 92 93mdconfig -d -u $no 94rm -f $keyfile 95