generic: test for file fsync after moving it to a new parent directory
[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 _supported_os Linux
34 _require_test
35 _require_scratch
36 _acl_setup_ids
37 _require_acls
38 _require_acl_get_max
39
40 rm -f $seqres.full
41
42 # get dir
43 cd $TEST_DIR
44 rm -rf $seq.dir1
45 mkdir $seq.dir1
46 cd $seq.dir1
47
48 # we return E2BIG if hit the max acl limits on new kernel, but EINVAL
49 # on old kernel. So we need to filter out the error message in order
50 # to make the updated golden output works for both old and new kernels.
51 _filter_largeacl()
52 {
53         sed -e "s/Invalid argument/Argument list too long/"
54 }
55
56 # filter all the non-ace stuff from the acl output so the count is
57 # correct. Note that this assumes that _create_n_aces always creates rwx acls.
58 _filter_acls()
59 {
60         _filter_aces | grep ':rwx'
61 }
62
63 # store the output in seqres.full, then run again an count and filter the
64 # output.
65 check_acls()
66 {
67         _acl=$1
68         _count=$2
69
70         chacl $_acl largeaclfile 2>&1 | _filter_largeacl
71         getfacl --numeric largeaclfile | _filter_aces \
72                 >> $seqres.full 2> /dev/null
73         nacls=`getfacl --numeric largeaclfile | _filter_acls | wc -l`
74         if [ $nacls -ne $_count ]; then
75                 echo Wrong ACL count - $nacls != $_count
76         fi
77 }
78
79
80 echo ""
81 echo "=== Test out large ACLs  ==="
82 touch largeaclfile
83
84 ACL_MAX_ENTRIES=$(_acl_get_max)
85 num_aces_pre=$((ACL_MAX_ENTRIES - 1))
86 num_aces_post=$((ACL_MAX_ENTRIES + 1))
87
88 acl1=`_create_n_aces $num_aces_pre`
89 acl2=`_create_n_aces $ACL_MAX_ENTRIES`
90 acl3=`_create_n_aces $num_aces_post`
91 acl4=`_create_n_aces 16` # Andreas G. libacl size for initial get
92 acl5=`_create_n_aces 17` # 1 over A.G. libacl initial size
93
94 echo "1 below acl max"
95 check_acls $acl1 $num_aces_pre
96
97 echo "acl max"
98 check_acls $acl2 $ACL_MAX_ENTRIES
99
100 # we expect the ACL change to fail, so the old ACLs should remain on the
101 # file. Hence the expected ACL count is XFS_ACL_MAX_ENTRIES, not num_aces_post.
102 echo "1 above acl max"
103 check_acls $acl3 $ACL_MAX_ENTRIES
104
105 echo "use 16 aces"
106 check_acls $acl4 16
107
108 echo "use 17 aces"
109 check_acls $acl5 17
110
111 # success, all done
112 status=0
113 exit