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
42 imgfile=$TEST_DIR/img-$seq
43 mntpt=$TEST_DIR/mount-$seq
44 testdir=$mntpt/testdir
45 testfile=$mntpt/testfile
46 nullstr="too_many_beans"
47 slashstr="are_bad_for_you"
48 test_names=("something" "$nullstr" "$slashstr" "another")
50 # Format image file w/o crcs so we can sed the image file
51 $XFS_IO_PROG -f -c 'truncate 40m' $imgfile
52 loopdev=$(_create_loop_device $imgfile)
53 MKFS_OPTIONS="-m crc=0" _mkfs_dev $loopdev >> $seqres.full
57 _mount $loopdev $mntpt
59 echo "creating entries" >> $seqres.full
61 # Create directory entries
63 for name in "${test_names[@]}"; do
64 touch "$testdir/f_$name"
69 for name in "${test_names[@]}"; do
70 $ATTR_PROG -s "a_$name" -V heh $testfile >> $seqres.full
73 # Now put in the first part of the garbage names to make sure we can't
74 # access those directly
75 test_names+=("too_many" "are_bad/for_you")
79 $ATTR_PROG -l $testfile
81 for name in "${test_names[@]}"; do
83 $ATTR_PROG -g "a_$name" $testfile
88 echo "++ ACCESSING GOOD METADATA" | tee -a $seqres.full
89 access_stuff > $tmp.log 2>&1
90 cat $tmp.log >> $seqres.full
91 cat $tmp.log | _filter_test_dir
95 _destroy_loop_device $loopdev
96 cp $imgfile $imgfile.old
98 -e "s/$nullstr/too_many\x00beans/g" \
99 -e "s/$slashstr/are_bad\/for_you/g" \
101 test "$(md5sum < $imgfile)" != "$(md5sum < $imgfile.old)" ||
102 _fail "sed failed to change the image file?"
104 loopdev=$(_create_loop_device $imgfile)
105 _mount $loopdev $mntpt
107 # Try to access the corrupt metadata
108 echo "++ ACCESSING BAD METADATA" | tee -a $seqres.full
109 access_stuff > $tmp.log 2>&1
110 cat $tmp.log >> $seqres.full
111 cat $tmp.log | _filter_test_dir | sed -e '/Could not list/d'
113 echo "does scrub complain?" >> $seqres.full
115 # Does scrub complain about this?
116 if _supports_xfs_scrub $mntpt $loopdev; then
117 $XFS_SCRUB_PROG -n $mntpt >> $seqres.full 2>&1
119 test $((res & 1)) -eq 0 && \
120 echo "scrub failed to report corruption ($res)"
123 echo "does repair complain?" >> $seqres.full
125 # Does repair complain about this?
127 $XFS_REPAIR_PROG -n $loopdev >> $seqres.full 2>&1
130 echo "repair failed to report corruption ($res)"
132 _destroy_loop_device $loopdev