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