xfs: fix old fuzz test invocations of xfs_repair
[xfstests-dev.git] / tests / ext4 / 026
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Google, Inc.  All Rights Reserved.
4 #
5 # FS QA Test 026
6 #
7 # Test for ea_inode feature in ext4. Without ea_inode feature, an extended
8 # attribute in ext4 cannot be larger than the fs block size. ea_inode feature
9 # allows storing xattr values in external inodes and so raises xattr value
10 # size limit to 64k.
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22         rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/attr
29
30 # remove previous $seqres.full before test
31 rm -f $seqres.full
32
33 # real QA test starts here
34 _supported_fs ext4
35 _require_scratch
36 _require_attrs
37 _require_scratch_ext4_feature "ea_inode"
38
39 _scratch_mkfs_ext4 -O ea_inode >/dev/null 2>&1
40 _scratch_mount
41
42 # Sets an extended attribute on a file.
43 attr_set()
44 {
45         local file=$1 name=$2 value=$3 tmp
46
47         if [[ "$value" != "" ]]; then
48                 $SETFATTR_PROG -n $name -v "$value" $file
49         else
50                 $SETFATTR_PROG -n $name $file
51         fi
52
53         tmp=$(_getfattr --absolute-names --only-values -n $name $file)
54         [[ "$tmp" == "$value" ]] || echo "unexpected value returned: $tmp"
55 }
56
57 # List attributes on a file.
58 attr_list()
59 {
60         _getfattr --absolute-names $1 | grep -v '^#'
61 }
62
63 # Removes an extended attribute from a file.
64 attr_remove()
65 {
66         local file=$1 name=$2
67
68         $SETFATTR_PROG -x $name $file
69 }
70
71 # Test files.
72 x=$SCRATCH_MNT/x
73 y=$SCRATCH_MNT/y
74 z=$SCRATCH_MNT/z
75
76 # Attribute with short name that goes into inode body.
77 name_in_ibody=user.i
78
79 # Attribute with long name that goes into xattr block.
80 name_in_block=user.$(perl -e 'print "b" x 100;')
81
82 # Set large xattr values on multiple files.
83 touch $x $y $z
84 for file in $x $y $z; do
85         for name in $name_in_ibody $name_in_block; do
86                 for size in 4096 8000 $((64*1024)); do
87                         attr_set $file $name-$size \
88                                 $(perl -e "print 'v' x $size;")
89                 done
90         done
91         attr_list $file
92 done
93 rm $x $y $z
94
95 # Set/remove.
96 touch $x
97 attr_set $x $name_in_ibody $(perl -e "print 'i' x 25000;")
98 attr_set $x $name_in_block $(perl -e "print 'b' x 25000;")
99 attr_list $x
100 attr_remove $x $name_in_ibody
101 attr_remove $x $name_in_block
102 rm $x
103
104 # Set with same value twice.
105 touch $x
106 attr_set $x $name_in_ibody $(perl -e "print 'i' x 60000;")
107 attr_set $x $name_in_ibody $(perl -e "print 'i' x 60000;")
108 attr_list $x
109 rm $x
110
111 # Repeatedly set an extended attribute with various value sizes.
112 touch $x
113 for size in 0 10 80 900 1900 3000 9000 60 10000 0 8000 3000 10 0 20 10000 5; do
114         attr_set $x user.1 $(perl -e "print 'v' x $size;")
115 done
116 attr_list $x
117 rm $x
118
119 # success, all done
120 status=0
121 exit