2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat, Inc. All Rights Reserved.
7 # Test the statx stx_attribute flags that can be set with chattr
10 _begin_fstest auto quick
12 # Override the default cleanup function.
17 $CHATTR_PROG -a -i $testfile
21 # Import common functions.
24 # real QA test starts here
26 # Modify as appropriate.
29 _require_test_program stat_test
31 _require_command "$CHATTR_PROG" chattr
33 function check_stat () {
34 $here/src/stat_test $* || echo stat_test failed
37 testfile=$TEST_DIR/$seq-file
40 # Work out what chattrs are supported on the fs under test
50 if $CHATTR_PROG +a $testfile >&/dev/null; then
55 if $CHATTR_PROG +c $testfile >&/dev/null; then
60 if $CHATTR_PROG +d $testfile >&/dev/null; then
65 if $CHATTR_PROG +i $testfile >&/dev/null; then
70 echo "a=$a_supported d=$d_supported c=$c_supported i=$i_supported" >>$seqres.full
72 if [ "$a_supported$c_supported$d_supported$i_supported" = "" ]; then
73 _notrun "file system doesn't support any of $CHATTR_PROG +a/+c/+d/+i"
76 $CHATTR_PROG -a -c -d -i $testfile
78 ###############################################################################
80 # Now do the actual test. We can turn on and off append (a), compressed (c),
81 # immutable (i) and no-dump (d) and theoretically see the output in the
82 # attribute flags. The following associations can be seen:
84 # chattr flag stx_attributes flag
85 # +a STATX_ATTR_APPEND
86 # +c STATX_ATTR_COMPRESSED
87 # +d STATX_ATTR_NODUMP
88 # +i STATX_ATTR_IMMUTABLE
90 # Note, however, that if the filesystem doesn't paste this information into
91 # stx_attributes, there's no way to tell the difference between cleared and
94 ###############################################################################
96 echo Trying "$*" >>$seqres.full
97 $CHATTR_PROG ${a_supported:+$1} \
102 check_stat $testfile \
103 ${a_supported:+attr=${1/a/append}} \
104 ${c_supported:+attr=${2/c/compressed}} \
105 ${d_supported:+attr=${3/d/nodump}} \
106 ${i_supported:+attr=${4/i/immutable}} \
124 # For tradition's sake
125 echo "Silence is golden"
127 # Done. We leave the success determination to the output comparator.