4 # Test the statx stx_attribute flags that can be set with chattr
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2017 Red Hat, Inc. All Rights Reserved.
8 # Written by David Howells (dhowells@redhat.com)
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #-----------------------------------------------------------------------
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
32 trap "_cleanup; exit \$status" 0 1 2 3 15
38 $CHATTR_PROG -a -i $testfile
42 # get standard environment, filters and checks
46 # remove previous $seqres.full before test
49 # real QA test starts here
51 # Modify as appropriate.
53 _supported_os IRIX Linux
55 _require_test_program stat_test
57 _require_command "$CHATTR_PROG" chattr
59 function check_stat () {
60 $here/src/stat_test $* || echo stat_test failed
63 testfile=$TEST_DIR/$seq-file
66 # Work out what chattrs are supported on the fs under test
76 if $CHATTR_PROG +a $testfile >&/dev/null; then
81 if $CHATTR_PROG +c $testfile >&/dev/null; then
86 if $CHATTR_PROG +d $testfile >&/dev/null; then
91 if $CHATTR_PROG +i $testfile >&/dev/null; then
96 echo "a=$a_supported d=$d_supported c=$c_supported i=$i_supported" >>$seqres.full
98 if [ "$a_supported$c_supported$d_supported$i_supported" = "" ]; then
99 _notrun "file system doesn't support any of $CHATTR_PROG +a/+c/+d/+i"
102 $CHATTR_PROG -a -c -d -i $testfile
104 ###############################################################################
106 # Now do the actual test. We can turn on and off append (a), compressed (c),
107 # immutable (i) and no-dump (d) and theoretically see the output in the
108 # attribute flags. The following associations can be seen:
110 # chattr flag stx_attributes flag
111 # +a STATX_ATTR_APPEND
112 # +c STATX_ATTR_COMPRESSED
113 # +d STATX_ATTR_NODUMP
114 # +i STATX_ATTR_IMMUTABLE
116 # Note, however, that if the filesystem doesn't paste this information into
117 # stx_attributes, there's no way to tell the difference between cleared and
120 ###############################################################################
122 echo Trying "$*" >>$seqres.full
123 $CHATTR_PROG ${a_supported:+$1} \
128 check_stat $testfile \
129 ${a_supported:+attr=${1/a/append}} \
130 ${c_supported:+attr=${2/c/compressed}} \
131 ${d_supported:+attr=${3/d/nodump}} \
132 ${i_supported:+attr=${4/i/immutable}} \
150 # For tradition's sake
151 echo "Silence is golden"
153 # Done. We leave the success determination to the output comparator.