2 # SPDX-License-Identifier: GPL-2.0+
3 # Copyright (c) 2019 Oracle, Inc. All Rights Reserved.
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()")
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
21 rm -f $tmp.* $testfile
24 # get standard environment, filters and checks
27 # real QA test starts here
32 $XFS_IO_PROG -r -c "statx -r" $1 | grep 'stat.attributes =' | cut -d ' ' -f 3
35 get_attributes_mask() {
36 $XFS_IO_PROG -r -c "statx -r" $1 | grep 'stat.attributes_mask =' | cut -d ' ' -f 3
39 check_statx_attributes()
41 local attrs=$(get_attributes $testfile)
42 local mask=$(get_attributes_mask $testfile)
44 echo "MASK:$mask:ATTRS:$attrs:" >> $seqres.full
46 test -z "$mask" && _notrun "xfs_io statx command does not support attributes_mask"
47 test $(( attrs & ~(mask) )) -ne 0 && echo "attributes $attrs do not appear in mask $mask"
51 echo "Silence is golden"
53 # Create file, check for incorrect mask
54 testfile=$TEST_DIR/$seq.$$.test
56 check_statx_attributes
58 # Do it again, but this time try to turn on one of the attributes.
59 if $CHATTR_PROG +i $testfile > /dev/null 2>&1; then
60 check_statx_attributes
61 $CHATTR_PROG -i $testfile
63 if $CHATTR_PROG +a $testfile > /dev/null 2>&1; then
64 check_statx_attributes
65 $CHATTR_PROG -a $testfile