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
33 $XFS_IO_PROG -r -c "statx -r" $1 | grep 'stat.attributes =' | cut -d ' ' -f 3
36 get_attributes_mask() {
37 $XFS_IO_PROG -r -c "statx -r" $1 | grep 'stat.attributes_mask =' | cut -d ' ' -f 3
40 check_statx_attributes()
42 local attrs=$(get_attributes $testfile)
43 local mask=$(get_attributes_mask $testfile)
45 echo "MASK:$mask:ATTRS:$attrs:" >> $seqres.full
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"
52 echo "Silence is golden"
54 # Create file, check for incorrect mask
55 testfile=$TEST_DIR/$seq.$$.test
57 check_statx_attributes
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
64 if $CHATTR_PROG +a $testfile > /dev/null 2>&1; then
65 check_statx_attributes
66 $CHATTR_PROG -a $testfile