1*6f818c1fSAlan Somers 2*6f818c1fSAlan Somers# Test various operations for geli-on-geli providers, to ensure that geli is 3*6f818c1fSAlan Somers# reentrant. 4*6f818c1fSAlan Somers 5*6f818c1fSAlan Somers. $(atf_get_srcdir)/conf.sh 6*6f818c1fSAlan Somers 7*6f818c1fSAlan Somersinit_test() 8*6f818c1fSAlan Somers{ 9*6f818c1fSAlan Somers cipher=$1 10*6f818c1fSAlan Somers aalgo=$2 11*6f818c1fSAlan Somers secsize=$3 12*6f818c1fSAlan Somers ealgo=${cipher%%:*} 13*6f818c1fSAlan Somers keylen=${cipher##*:} 14*6f818c1fSAlan Somers 15*6f818c1fSAlan Somers atf_check dd if=/dev/random of=testdata bs=$secsize count=1 status=none 16*6f818c1fSAlan Somers atf_check dd if=/dev/random of=keyfile bs=$secsize count=16 status=none 17*6f818c1fSAlan Somers 18*6f818c1fSAlan Somers # Create the lower geli device 19*6f818c1fSAlan Somers atf_check -s exit:0 -e ignore \ 20*6f818c1fSAlan Somers geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K keyfile \ 21*6f818c1fSAlan Somers -s $secsize ${md} 22*6f818c1fSAlan Somers atf_check geli attach -p -k keyfile ${md} 23*6f818c1fSAlan Somers # Create the upper geli device 24*6f818c1fSAlan Somers atf_check -s exit:0 -e ignore \ 25*6f818c1fSAlan Somers geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K keyfile \ 26*6f818c1fSAlan Somers -s $secsize ${md}.eli 27*6f818c1fSAlan Somers atf_check geli attach -p -k keyfile ${md}.eli 28*6f818c1fSAlan Somers echo ${md} > layered_md_device 29*6f818c1fSAlan Somers 30*6f818c1fSAlan Somers # Ensure we can read and write. 31*6f818c1fSAlan Somers atf_check dd if=testdata of=/dev/${md}.eli.eli bs=$secsize count=1 \ 32*6f818c1fSAlan Somers status=none 33*6f818c1fSAlan Somers atf_check dd if=/dev/${md}.eli.eli of=cmpdata bs=$secsize count=1 \ 34*6f818c1fSAlan Somers status=none 35*6f818c1fSAlan Somers atf_check cmp -s testdata cmpdata 36*6f818c1fSAlan Somers 37*6f818c1fSAlan Somers geli detach ${md}.eli 2>/dev/null 38*6f818c1fSAlan Somers} 39*6f818c1fSAlan Somers 40*6f818c1fSAlan Somersatf_test_case init cleanup 41*6f818c1fSAlan Somersinit_head() 42*6f818c1fSAlan Somers{ 43*6f818c1fSAlan Somers atf_set "descr" "Initialize a geli provider on top of another" 44*6f818c1fSAlan Somers atf_set "require.user" "root" 45*6f818c1fSAlan Somers atf_set "timeout" 600 46*6f818c1fSAlan Somers} 47*6f818c1fSAlan Somersinit_body() 48*6f818c1fSAlan Somers{ 49*6f818c1fSAlan Somers sectors=2 50*6f818c1fSAlan Somers geli_test_setup 51*6f818c1fSAlan Somers 52*6f818c1fSAlan Somers for_each_geli_config init_test 53*6f818c1fSAlan Somers} 54*6f818c1fSAlan Somersinit_cleanup() 55*6f818c1fSAlan Somers{ 56*6f818c1fSAlan Somers if [ -f layered_md_device ]; then 57*6f818c1fSAlan Somers while read provider; do 58*6f818c1fSAlan Somers [ -c /dev/${md}.eli.eli ] && \ 59*6f818c1fSAlan Somers geli detach $md.eli.eli 2>/dev/null 60*6f818c1fSAlan Somers done < layered_md_device 61*6f818c1fSAlan Somers fi 62*6f818c1fSAlan Somers geli_test_cleanup 63*6f818c1fSAlan Somers} 64*6f818c1fSAlan Somers 65*6f818c1fSAlan Somersatf_init_test_cases() 66*6f818c1fSAlan Somers{ 67*6f818c1fSAlan Somers atf_add_test_case init 68*6f818c1fSAlan Somers} 69