2 # SPDX-License-Identifier: GPL-2.0-or-newer
3 # Copyright (c) 2019, Oracle and/or its affiliates. All Rights Reserved.
7 # See if we catch corrupt directory names or attr names with nulls or slashes
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
22 $UMOUNT_PROG $mntpt > /dev/null 2>&1
23 test -n "$loopdev" && _destroy_loop_device $loopdev > /dev/null 2>&1
24 rm -r -f $imgfile $mntpt $tmp.*
27 # get standard environment, filters and checks
32 # real QA test starts here
41 imgfile=$TEST_DIR/img-$seq
42 mntpt=$TEST_DIR/mount-$seq
43 testdir=$mntpt/testdir
44 testfile=$mntpt/testfile
45 nullstr="too_many_beans"
46 slashstr="are_bad_for_you"
47 test_names=("something" "$nullstr" "$slashstr" "another")
49 # Format image file w/o crcs so we can sed the image file
50 $XFS_IO_PROG -f -c 'truncate 40m' $imgfile
51 loopdev=$(_create_loop_device $imgfile)
52 MKFS_OPTIONS="-m crc=0" _mkfs_dev $loopdev >> $seqres.full
56 _mount $loopdev $mntpt
58 echo "creating entries" >> $seqres.full
60 # Create directory entries
62 for name in "${test_names[@]}"; do
63 touch "$testdir/f_$name"
68 for name in "${test_names[@]}"; do
69 $ATTR_PROG -s "a_$name" -V heh $testfile >> $seqres.full
72 # Now put in the first part of the garbage names to make sure we can't
73 # access those directly
74 test_names+=("too_many" "are_bad/for_you")
78 $ATTR_PROG -l $testfile | grep 'a_' | sort
80 for name in "${test_names[@]}"; do
82 $ATTR_PROG -g "a_$name" $testfile
87 echo "++ ACCESSING GOOD METADATA" | tee -a $seqres.full
88 access_stuff > $tmp.log 2>&1
89 cat $tmp.log >> $seqres.full
90 cat $tmp.log | _filter_test_dir
94 _destroy_loop_device $loopdev
95 cp $imgfile $imgfile.old
97 -e "s/$nullstr/too_many\x00beans/g" \
98 -e "s/$slashstr/are_bad\/for_you/g" \
100 test "$(md5sum < $imgfile)" != "$(md5sum < $imgfile.old)" ||
101 _fail "sed failed to change the image file?"
103 loopdev=$(_create_loop_device $imgfile)
104 _mount $loopdev $mntpt
106 # Try to access the corrupt metadata
107 echo "++ ACCESSING BAD METADATA" | tee -a $seqres.full
108 access_stuff > $tmp.log 2>&1
109 cat $tmp.log >> $seqres.full
110 cat $tmp.log | _filter_test_dir | sed -e '/Could not list/d'
112 echo "does scrub complain?" >> $seqres.full
114 # Does scrub complain about this?
115 if _supports_xfs_scrub $mntpt $loopdev; then
116 $XFS_SCRUB_PROG -n $mntpt >> $seqres.full 2>&1
118 test $((res & 1)) -eq 0 && \
119 echo "scrub failed to report corruption ($res)"
122 echo "does repair complain?" >> $seqres.full
124 # Does repair complain about this?
126 $XFS_REPAIR_PROG -n $loopdev >> $seqres.full 2>&1
129 echo "repair failed to report corruption ($res)"
131 _destroy_loop_device $loopdev