fstests: check for filesystem FS_IOC_FSSETXATTR support
[xfstests-dev.git] / tests / xfs / 149
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 149
6 #
7 # Exercise xfs_prepair - ensure repeated use doesn't corrupt
8 # This is a clone of test 031 using xfs_prepair instead of xfs_repair
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
18 rm -f $seqres.full
19
20 # get standard environment, filters and checks
21 . ./common/rc
22 . ./common/repair
23 . ./common/filter
24
25 [ -z "$XFS_PARALLEL_REPAIR_PROG" ] && _notrun "parallel repair binary xfs_prepair is not installed"
26
27 # force use of parallel repair
28 export XFS_REPAIR_PROG=$XFS_PARALLEL_REPAIR_PROG
29
30 _check_repair()
31 {
32         echo "Repairing, round 0" >> $seqres.full
33         _scratch_xfs_repair 2>&1 | _filter_repair | tee -a $seqres.full >$tmp.0
34         for i in 1 2 3 4
35         do
36                 echo "Repairing, iteration $i" | tee -a $seqres.full
37                 _scratch_xfs_repair 2>&1 | _filter_repair >$tmp.$i
38                 diff $tmp.0 $tmp.$i >> $seqres.full
39                 if [ $? -ne 0 ]; then
40                         echo "ERROR: repair round $i differs to round 0 (see $seqres.full)" | tee -a $seqres.full
41                         break
42                 fi
43                 # echo all interesting stuff...
44                 perl -ne '
45                         s/(rebuilding directory inode) (\d+)/\1 INO/g;
46                         s/internal log/<TYPEOF> log/g;
47                         s/external log on \S+/<TYPEOF> log/g;
48                         /^\S+/ && print;
49                 ' $tmp.$i
50         done
51         echo
52 }
53
54 # prototype file to create various directory forms
55 _create_proto()
56 {
57         total=$1
58         count=0
59
60         # take inode size into account for non-shortform directories...
61         [ $total -gt 0 ] && total=`expr $total \* $isize / 512`
62
63         cat >$tmp.proto <<EOF
64 DUMMY1
65 0 0
66 : root directory
67 d--777 3 1
68 lost+found d--755 3 1
69 $
70 EOF
71
72         while [ $count -lt $total ]
73         do
74                 let count=$count+1
75                 cat >>$tmp.proto <<EOF
76 ${count}_of_${total}_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ---755 3 1 /bin/true
77 EOF
78         done
79         echo '$' >>$tmp.proto
80 }
81
82 # real QA test starts here
83 _supported_fs xfs
84 _supported_os Linux
85
86 _require_scratch
87 _require_no_large_scratch_dev
88
89 # sanity test - default + one root directory entry
90 # Note: must do this proto/mkfs now for later inode size calcs
91 _create_proto 0
92 echo "=== one entry (shortform)"
93 _scratch_mkfs_xfs -p $tmp.proto >$tmp.mkfs0 2>&1
94 _filter_mkfs <$tmp.mkfs0 >/dev/null 2>$tmp.mkfs
95 . $tmp.mkfs
96 _check_repair
97
98 # block-form root directory & repeat
99 _create_proto 20
100 echo "=== twenty entries (block form)"
101 _scratch_mkfs_xfs -p $tmp.proto | _filter_mkfs >/dev/null 2>&1
102 _check_repair
103
104 # leaf-form root directory & repeat
105 _create_proto 1000
106 echo "=== thousand entries (leaf form)"
107 _scratch_mkfs_xfs -p $tmp.proto | _filter_mkfs >/dev/null 2>&1
108 _check_repair
109
110 # success, all done
111 status=0
112 exit