blob: 832bfeee5c925cc4d6116f94c198ee7353b1aa4e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#!/bin/sh
. $(atf_get_srcdir)/conf.sh
atf_test_case resize cleanup
resize_head()
{
atf_set "descr" "geli resize will resize a geli provider"
atf_set "require.user" "root"
}
resize_body()
{
geli_test_setup
BLK=512
BLKS_PER_MB=2048
attach_md md -t malloc -s40m
# Initialise
atf_check -s exit:0 -o ignore gpart create -s BSD ${md}
atf_check -s exit:0 -o ignore gpart add -t freebsd-ufs -s 10m ${md}
echo secret >tmp.key
atf_check geli init -Bnone -PKtmp.key ${md}a
atf_check geli attach -pk tmp.key ${md}a
atf_check -s exit:0 -o ignore newfs -U ${md}a.eli
atf_check -s exit:7 -o ignore fsck_ffs -Ffy ${md}a.eli
# Doing a backup, resize & restore must be forced (with -f) as geli
# verifies that the provider size in the metadata matches the consumer.
atf_check geli backup ${md}a tmp.meta
atf_check geli detach ${md}a.eli
atf_check -s exit:0 -o match:resized gpart resize -i1 -s 20m ${md}
atf_check -s not-exit:0 -e ignore geli attach -pktmp.key ${md}a
atf_check -s not-exit:0 -e ignore geli restore tmp.meta ${md}a
atf_check geli restore -f tmp.meta ${md}a
atf_check geli attach -pktmp.key ${md}a
atf_check -s exit:0 -o ignore growfs -y ${md}a.eli
atf_check -s exit:7 -o ignore fsck_ffs -Ffy ${md}a.eli
# Now do the resize properly
atf_check geli detach ${md}a.eli
atf_check -s exit:0 -o match:resized gpart resize -i1 -s 30m ${md}
atf_check geli resize -s20m ${md}a
atf_check -s not-exit:0 -e match:"Inconsistent provider.*metadata" \
geli resize -s20m ${md}a
atf_check geli attach -pktmp.key ${md}a
atf_check -s exit:0 -o ignore growfs -y ${md}a.eli
atf_check -s exit:7 -o ignore fsck_ffs -Ffy ${md}a.eli
atf_check geli detach ${md}a.eli
atf_check -s exit:0 -o ignore gpart destroy -F $md
# Verify that the man page example works, changing ada0 to $md,
# 1g to 20m, 2g to 30m and keyfile to tmp.key, and adding -B none
# to geli init.
atf_check -s exit:0 -o ignore gpart create -s GPT $md
atf_check -s exit:0 -o ignore gpart add -s 20m -t freebsd-ufs -i 1 $md
atf_check geli init -B none -K tmp.key -P ${md}p1
atf_check -s exit:0 -o match:resized gpart resize -s 30m -i 1 $md
atf_check geli resize -s 20m ${md}p1
atf_check geli attach -k tmp.key -p ${md}p1
}
resize_cleanup()
{
if [ -f "$TEST_MDS_FILE" ]; then
while read md; do
[ -c /dev/${md}a.eli ] && \
geli detach ${md}a.eli 2>/dev/null
[ -c /dev/${md}p1.eli ] && \
geli detach ${md}p1.eli
[ -c /dev/${md}.eli ] && \
geli detach ${md}.eli 2>/dev/null
mdconfig -d -u $md 2>/dev/null
done < $TEST_MDS_FILE
fi
}
atf_init_test_cases()
{
atf_add_test_case resize
}
|