generic/554: hide permision warning on exfat
[xfstests-dev.git] / tests / generic / 026
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
4 # Copyright (c) 2014 Red hat, Inc.  All Rights Reserved.
5 #
6 # FS QA Test No. generic/026
7 #
8 # Test out ACL count limits
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # FAILure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 # get standard environment, filters and checks
20 . ./common/rc
21 . ./common/filter
22 . ./common/attr
23
24 _cleanup()
25 {
26     cd /
27     rm -f $tmp.*
28     [ -n "$TEST_DIR" ] && rm -rf $TEST_DIR/$seq.dir1
29 }
30
31 # real QA test starts here
32 _supported_fs generic
33 _require_test
34 _acl_setup_ids
35 _require_acls
36 _require_acl_get_max
37
38 rm -f $seqres.full
39
40 # get dir
41 cd $TEST_DIR
42 rm -rf $seq.dir1
43 mkdir $seq.dir1
44 cd $seq.dir1
45
46 # we return E2BIG if hit the max acl limits on new kernel, but EINVAL
47 # on old kernel. So we need to filter out the error message in order
48 # to make the updated golden output works for both old and new kernels.
49 _filter_largeacl()
50 {
51         sed -e "s/Invalid argument/Argument list too long/"
52 }
53
54 # filter all the non-ace stuff from the acl output so the count is
55 # correct. Note that this assumes that _create_n_aces always creates rwx acls.
56 _filter_acls()
57 {
58         _filter_aces | grep ':rwx'
59 }
60
61 # store the output in seqres.full, then run again an count and filter the
62 # output.
63 check_acls()
64 {
65         _acl=$1
66         _count=$2
67
68         chacl $_acl largeaclfile 2>&1 | _filter_largeacl
69         getfacl --numeric largeaclfile | _filter_aces \
70                 >> $seqres.full 2> /dev/null
71         nacls=`getfacl --numeric largeaclfile | _filter_acls | wc -l`
72         if [ $nacls -ne $_count ]; then
73                 echo Wrong ACL count - $nacls != $_count
74         fi
75 }
76
77
78 echo ""
79 echo "=== Test out large ACLs  ==="
80 touch largeaclfile
81
82 ACL_MAX_ENTRIES=$(_acl_get_max)
83 num_aces_pre=$((ACL_MAX_ENTRIES - 1))
84 num_aces_post=$((ACL_MAX_ENTRIES + 1))
85
86 acl1=`_create_n_aces $num_aces_pre`
87 acl2=`_create_n_aces $ACL_MAX_ENTRIES`
88 acl3=`_create_n_aces $num_aces_post`
89 acl4=`_create_n_aces 16` # Andreas G. libacl size for initial get
90 acl5=`_create_n_aces 17` # 1 over A.G. libacl initial size
91
92 echo "1 below acl max"
93 check_acls $acl1 $num_aces_pre
94
95 echo "acl max"
96 check_acls $acl2 $ACL_MAX_ENTRIES
97
98 # we expect the ACL change to fail, so the old ACLs should remain on the
99 # file. Hence the expected ACL count is XFS_ACL_MAX_ENTRIES, not num_aces_post.
100 echo "1 above acl max"
101 check_acls $acl3 $ACL_MAX_ENTRIES
102
103 echo "use 16 aces"
104 check_acls $acl4 16
105
106 echo "use 17 aces"
107 check_acls $acl5 17
108
109 # success, all done
110 status=0
111 exit