Pass read/write CRx registers to userspace
[freebsd-src/fkvm-freebsd.git] / tools / regression / geom_eli / delkey.t
bloba828622bb7841eca707a302b69667cba43cd1d68
1 #!/bin/sh
2 # $FreeBSD$
4 base=`basename $0`
5 no=45
6 sectors=100
7 keyfile1=`mktemp /tmp/$base.XXXXXX` || exit 1
8 keyfile2=`mktemp /tmp/$base.XXXXXX` || exit 1
9 keyfile3=`mktemp /tmp/$base.XXXXXX` || exit 1
10 keyfile4=`mktemp /tmp/$base.XXXXXX` || exit 1
11 mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
13 echo "1..14"
15 dd if=/dev/random of=${keyfile1} bs=512 count=16 >/dev/null 2>&1
16 dd if=/dev/random of=${keyfile2} bs=512 count=16 >/dev/null 2>&1
17 dd if=/dev/random of=${keyfile3} bs=512 count=16 >/dev/null 2>&1
18 dd if=/dev/random of=${keyfile4} bs=512 count=16 >/dev/null 2>&1
20 geli init -B none -P -K $keyfile1 md${no}
21 geli attach -p -k $keyfile1 md${no}
22 geli setkey -n 1 -P -K $keyfile2 md${no}
24 # Remove key 0 for attached provider.
25 geli delkey -n 0 md${no}
26 if [ $? -eq 0 ]; then
27 echo "ok 1"
28 else
29 echo "not ok 1"
31 geli detach md${no}
33 # We cannot use keyfile1 anymore.
34 geli attach -p -k $keyfile1 md${no} 2>/dev/null
35 if [ $? -ne 0 ]; then
36 echo "ok 2"
37 else
38 echo "not ok 2"
41 # Attach with key 1.
42 geli attach -p -k $keyfile2 md${no}
43 if [ $? -eq 0 ]; then
44 echo "ok 3"
45 else
46 echo "not ok 3"
49 # We cannot remove last key without -f option (for attached provider).
50 geli delkey -n 1 md${no} 2>/dev/null
51 if [ $? -ne 0 ]; then
52 echo "ok 4"
53 else
54 echo "not ok 4"
57 # Remove last key for attached provider.
58 geli delkey -f -n 1 md${no}
59 if [ $? -eq 0 ]; then
60 echo "ok 5"
61 else
62 echo "not ok 5"
65 # If there are no valid keys, but provider is attached, we can save situation.
66 geli setkey -n 0 -P -K $keyfile3 md${no}
67 if [ $? -eq 0 ]; then
68 echo "ok 6"
69 else
70 echo "not ok 6"
72 geli detach md${no}
74 # We cannot use keyfile2 anymore.
75 geli attach -p -k $keyfile2 md${no} 2>/dev/null
76 if [ $? -ne 0 ]; then
77 echo "ok 7"
78 else
79 echo "not ok 7"
82 # Attach with key 0.
83 geli attach -p -k $keyfile3 md${no}
84 if [ $? -eq 0 ]; then
85 echo "ok 8"
86 else
87 echo "not ok 8"
90 # Setup key 1.
91 geli setkey -n 1 -P -K $keyfile4 md${no}
92 if [ $? -eq 0 ]; then
93 echo "ok 9"
94 else
95 echo "not ok 9"
97 geli detach md${no}
99 # Remove key 1 for detached provider.
100 geli delkey -n 1 md${no}
101 if [ $? -eq 0 ]; then
102 echo "ok 10"
103 else
104 echo "not ok 10"
107 # We cannot use keyfile4 anymore.
108 geli attach -p -k $keyfile4 md${no} 2>/dev/null
109 if [ $? -ne 0 ]; then
110 echo "ok 11"
111 else
112 echo "not ok 11"
115 # We cannot remove last key without -f option (for detached provider).
116 geli delkey -n 0 md${no} 2>/dev/null
117 if [ $? -ne 0 ]; then
118 echo "ok 12"
119 else
120 echo "not ok 12"
123 # Remove last key for detached provider.
124 geli delkey -f -n 0 md${no}
125 if [ $? -eq 0 ]; then
126 echo "ok 13"
127 else
128 echo "not ok 13"
131 # We cannot use keyfile3 anymore.
132 geli attach -p -k $keyfile3 md${no} 2>/dev/null
133 if [ $? -ne 0 ]; then
134 echo "ok 14"
135 else
136 echo "not ok 14"
139 mdconfig -d -u $no
140 rm -f $keyfile1 $keyfile2 $keyfile3 $keyfile4