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 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
16 trap "_cleanup; exit \$status" 0 1 2 3 15
22 $CHATTR_PROG -a -i $testfile
26 # get standard environment, filters and checks
30 # remove previous $seqres.full before test
33 # real QA test starts here
35 # Modify as appropriate.
39 _require_test_program stat_test
41 _require_command "$CHATTR_PROG" chattr
43 function check_stat () {
44 $here/src/stat_test $* || echo stat_test failed
47 testfile=$TEST_DIR/$seq-file
50 # Work out what chattrs are supported on the fs under test
60 if $CHATTR_PROG +a $testfile >&/dev/null; then
65 if $CHATTR_PROG +c $testfile >&/dev/null; then
70 if $CHATTR_PROG +d $testfile >&/dev/null; then
75 if $CHATTR_PROG +i $testfile >&/dev/null; then
80 echo "a=$a_supported d=$d_supported c=$c_supported i=$i_supported" >>$seqres.full
82 if [ "$a_supported$c_supported$d_supported$i_supported" = "" ]; then
83 _notrun "file system doesn't support any of $CHATTR_PROG +a/+c/+d/+i"
86 $CHATTR_PROG -a -c -d -i $testfile
88 ###############################################################################
90 # Now do the actual test. We can turn on and off append (a), compressed (c),
91 # immutable (i) and no-dump (d) and theoretically see the output in the
92 # attribute flags. The following associations can be seen:
94 # chattr flag stx_attributes flag
95 # +a STATX_ATTR_APPEND
96 # +c STATX_ATTR_COMPRESSED
97 # +d STATX_ATTR_NODUMP
98 # +i STATX_ATTR_IMMUTABLE
100 # Note, however, that if the filesystem doesn't paste this information into
101 # stx_attributes, there's no way to tell the difference between cleared and
104 ###############################################################################
106 echo Trying "$*" >>$seqres.full
107 $CHATTR_PROG ${a_supported:+$1} \
112 check_stat $testfile \
113 ${a_supported:+attr=${1/a/append}} \
114 ${c_supported:+attr=${2/c/compressed}} \
115 ${d_supported:+attr=${3/d/nodump}} \
116 ${i_supported:+attr=${4/i/immutable}} \
134 # For tradition's sake
135 echo "Silence is golden"
137 # Done. We leave the success determination to the output comparator.