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.
38 _require_test_program stat_test
40 _require_command "$CHATTR_PROG" chattr
42 function check_stat () {
43 $here/src/stat_test $* || echo stat_test failed
46 testfile=$TEST_DIR/$seq-file
49 # Work out what chattrs are supported on the fs under test
59 if $CHATTR_PROG +a $testfile >&/dev/null; then
64 if $CHATTR_PROG +c $testfile >&/dev/null; then
69 if $CHATTR_PROG +d $testfile >&/dev/null; then
74 if $CHATTR_PROG +i $testfile >&/dev/null; then
79 echo "a=$a_supported d=$d_supported c=$c_supported i=$i_supported" >>$seqres.full
81 if [ "$a_supported$c_supported$d_supported$i_supported" = "" ]; then
82 _notrun "file system doesn't support any of $CHATTR_PROG +a/+c/+d/+i"
85 $CHATTR_PROG -a -c -d -i $testfile
87 ###############################################################################
89 # Now do the actual test. We can turn on and off append (a), compressed (c),
90 # immutable (i) and no-dump (d) and theoretically see the output in the
91 # attribute flags. The following associations can be seen:
93 # chattr flag stx_attributes flag
94 # +a STATX_ATTR_APPEND
95 # +c STATX_ATTR_COMPRESSED
96 # +d STATX_ATTR_NODUMP
97 # +i STATX_ATTR_IMMUTABLE
99 # Note, however, that if the filesystem doesn't paste this information into
100 # stx_attributes, there's no way to tell the difference between cleared and
103 ###############################################################################
105 echo Trying "$*" >>$seqres.full
106 $CHATTR_PROG ${a_supported:+$1} \
111 check_stat $testfile \
112 ${a_supported:+attr=${1/a/append}} \
113 ${c_supported:+attr=${2/c/compressed}} \
114 ${d_supported:+attr=${3/d/nodump}} \
115 ${i_supported:+attr=${4/i/immutable}} \
133 # For tradition's sake
134 echo "Silence is golden"
136 # Done. We leave the success determination to the output comparator.