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 _begin_fstest auto quick fuzzers
13 # Override the default cleanup function.
17 $UMOUNT_PROG $mntpt > /dev/null 2>&1
18 test -n "$loopdev" && _destroy_loop_device $loopdev > /dev/null 2>&1
19 rm -r -f $imgfile $mntpt $tmp.*
22 # Import common functions.
26 # real QA test starts here
33 imgfile=$TEST_DIR/img-$seq
34 mntpt=$TEST_DIR/mount-$seq
35 testdir=$mntpt/testdir
36 testfile=$mntpt/testfile
37 nullstr="too_many_beans"
38 slashstr="are_bad_for_you"
39 test_names=("something" "$nullstr" "$slashstr" "another")
41 # Format image file w/o crcs so we can sed the image file
42 $XFS_IO_PROG -f -c 'truncate 40m' $imgfile
43 loopdev=$(_create_loop_device $imgfile)
44 MKFS_OPTIONS="-m crc=0" _mkfs_dev $loopdev >> $seqres.full
48 _mount $loopdev $mntpt
50 echo "creating entries" >> $seqres.full
52 # Create directory entries
54 for name in "${test_names[@]}"; do
55 touch "$testdir/f_$name"
60 for name in "${test_names[@]}"; do
61 $ATTR_PROG -s "a_$name" -V heh $testfile >> $seqres.full
64 # Now put in the first part of the garbage names to make sure we can't
65 # access those directly
66 test_names+=("too_many" "are_bad/for_you")
70 $ATTR_PROG -l $testfile | grep 'a_' | sort
72 for name in "${test_names[@]}"; do
74 $ATTR_PROG -g "a_$name" $testfile
79 echo "++ ACCESSING GOOD METADATA" | tee -a $seqres.full
80 access_stuff > $tmp.log 2>&1
81 cat $tmp.log >> $seqres.full
82 cat $tmp.log | _filter_test_dir
86 _destroy_loop_device $loopdev
87 cp $imgfile $imgfile.old
89 -e "s/$nullstr/too_many\x00beans/g" \
90 -e "s/$slashstr/are_bad\/for_you/g" \
92 test "$(md5sum < $imgfile)" != "$(md5sum < $imgfile.old)" ||
93 _fail "sed failed to change the image file?"
95 loopdev=$(_create_loop_device $imgfile)
96 _mount $loopdev $mntpt
98 # Try to access the corrupt metadata
99 echo "++ ACCESSING BAD METADATA" | tee -a $seqres.full
100 access_stuff > $tmp.log 2>&1
101 cat $tmp.log >> $seqres.full
102 cat $tmp.log | _filter_test_dir | sed -e '/Could not list/d'
104 echo "does scrub complain?" >> $seqres.full
106 # Does scrub complain about this?
107 if _supports_xfs_scrub $mntpt $loopdev; then
108 $XFS_SCRUB_PROG -n $mntpt >> $seqres.full 2>&1
110 test $((res & 1)) -eq 0 && \
111 echo "scrub failed to report corruption ($res)"
114 echo "does repair complain?" >> $seqres.full
116 # Does repair complain about this?
118 $XFS_REPAIR_PROG -n $loopdev >> $seqres.full 2>&1
121 echo "repair failed to report corruption ($res)"
123 _destroy_loop_device $loopdev