generic/532: document the kernel commit
[xfstests-dev.git] / tests / generic / 532
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0+
3 # Copyright (c) 2019 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 532
6 #
7 # Regression test for a bug where XFS fails to set statx attributes_mask but
8 # sets attribute flags anyway, which is fixed by commit 1b9598c8fb99 ("xfs: fix
9 # reporting supported extra file attributes for statx()")
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         cd /
21         rm -f $tmp.* $testfile
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26
27 # real QA test starts here
28 _supported_fs generic
29 _supported_os Linux
30 _require_test
31
32 get_attributes() {
33         $XFS_IO_PROG -r -c "statx -r" $1 | grep 'stat.attributes =' | cut -d ' ' -f 3
34 }
35
36 get_attributes_mask() {
37         $XFS_IO_PROG -r -c "statx -r" $1 | grep 'stat.attributes_mask =' | cut -d ' ' -f 3
38 }
39
40 check_statx_attributes()
41 {
42         local attrs=$(get_attributes $testfile)
43         local mask=$(get_attributes_mask $testfile)
44
45         echo "MASK:$mask:ATTRS:$attrs:" >> $seqres.full
46
47         test -z "$mask" && _notrun "xfs_io statx command does not support attributes_mask"
48         test $(( attrs & ~(mask) )) -ne 0 && echo "attributes $attrs do not appear in mask $mask"
49 }
50
51 rm -f $seqres.full
52 echo "Silence is golden"
53
54 # Create file, check for incorrect mask
55 testfile=$TEST_DIR/$seq.$$.test
56 touch $testfile
57 check_statx_attributes
58
59 # Do it again, but this time try to turn on one of the attributes.
60 if $CHATTR_PROG +i $testfile > /dev/null 2>&1; then
61         check_statx_attributes
62         $CHATTR_PROG -i $testfile
63 fi
64 if $CHATTR_PROG +a $testfile > /dev/null 2>&1; then
65         check_statx_attributes
66         $CHATTR_PROG -a $testfile
67 fi
68
69 status=0
70 exit