generic/405: test mkfs against thin provision device
[xfstests-dev.git] / tests / generic / 396
1 #! /bin/bash
2 # FS QA Test generic/396
3 #
4 # Test that FS_IOC_SET_ENCRYPTION_POLICY correctly validates the fscrypt_policy
5 # structure that userspace passes to it.
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2016 Google, Inc.  All Rights Reserved.
9 #
10 # Author: Eric Biggers <ebiggers@google.com>
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #-----------------------------------------------------------------------
25 #
26
27 seq=`basename $0`
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
35
36 _cleanup()
37 {
38         cd /
39         rm -f $tmp.*
40 }
41
42 # get standard environment, filters and checks
43 . ./common/rc
44 . ./common/filter
45 . ./common/encrypt
46
47 # remove previous $seqres.full before test
48 rm -f $seqres.full
49
50 # real QA test starts here
51 _supported_fs generic
52 _supported_os Linux
53 _require_scratch_encryption
54 _require_xfs_io_command "set_encpolicy"
55
56 _scratch_mkfs_encrypted &>> $seqres.full
57 _scratch_mount
58 dir=$SCRATCH_MNT/dir
59 mkdir $dir
60
61 echo -e "\n*** Invalid contents encryption mode ***"
62 $XFS_IO_PROG -c "set_encpolicy -c 0xFF" $dir |& _filter_scratch
63
64 echo -e "\n*** Invalid filenames encryption mode ***"
65 $XFS_IO_PROG -c "set_encpolicy -n 0xFF" $dir |& _filter_scratch
66
67 echo -e "\n*** Invalid flags ***"
68 $XFS_IO_PROG -c "set_encpolicy -f 0xFF" $dir |& _filter_scratch
69
70 echo -e "\n*** Invalid policy version ***"
71 $XFS_IO_PROG -c "set_encpolicy -v 0xFF" $dir |& _filter_scratch
72
73 # Currently, the only supported combination of modes is AES-256-XTS for contents
74 # and AES-256-CTS for filenames.  Nothing else should be accepted.
75 echo -e "\n*** Invalid combinations of modes ***"
76 $XFS_IO_PROG -c "set_encpolicy -c AES-256-CTS -n AES-256-CTS" $dir |& _filter_scratch
77 $XFS_IO_PROG -c "set_encpolicy -c AES-256-CTS -n AES-256-XTS" $dir |& _filter_scratch
78 $XFS_IO_PROG -c "set_encpolicy -c AES-256-XTS -n AES-256-XTS" $dir |& _filter_scratch
79
80 # success, all done
81 status=0
82 exit