Add GPL license plate to SGI's test files.
[xfstests-dev.git] / 030
1 #! /bin/sh
2 #
3 #-----------------------------------------------------------------------
4 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation.
9 #
10 # This program is distributed in the hope that it would be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write the Free Software Foundation,
17 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 #
19 #-----------------------------------------------------------------------
20 #
21 # FS QA Test No. 030
22 #
23 # exercise xfs_repair repairing broken filesystems
24 #
25 #-----------------------------------------------------------------------
26 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
27 #-----------------------------------------------------------------------
28 #
29 # creator
30 owner=nathans@sgi.com
31
32 seq=`basename $0`
33 echo "QA output created by $seq"
34
35 here=`pwd`
36 tmp=/tmp/$$
37 status=1        # failure is the default!
38
39 _cleanup()
40 {
41         cd /
42         umount $SCRATCH_DEV 2>/dev/null
43         rm -f $tmp.*
44 }
45
46 trap "_cleanup; exit \$status" 0 1 2 3 15
47
48 # get standard environment, filters and checks
49 . ./common.rc
50 . ./common.filter
51 . ./common.repair
52
53 # link correct .out file
54 _link_out_file $seq.out
55
56 # nuke the superblock, AGI, AGF, AGFL; then try repair the damage
57 #
58 _check_ag()
59 {
60         for structure in 'sb 0' 'agf 0' 'agi 0' 'agfl 0'
61         do
62                 echo "Corrupting $structure - setting bits to $1"
63                 _check_repair $1 "$structure"
64         done
65 }
66
67 # real QA test starts here
68 _supported_fs xfs
69 _supported_os IRIX Linux
70
71 _require_nobigloopfs
72 _require_scratch
73
74 DSIZE="-dsize=100m,agcount=6"
75
76 # first we need to ensure there are no bogus secondary
77 # superblocks between the primary and first secondary
78 # superblock (hanging around from earlier tests)...
79 #
80
81 _scratch_mkfs_xfs $DSIZE >/dev/null 2>&1
82 if [ $? -ne 0 ]         # probably don't have a big enough scratch
83 then
84         _notrun "SCRATCH_DEV too small, results would be non-deterministic"
85 else
86         _scratch_mount
87         src/feature -U $SCRATCH_DEV && \
88                 _notrun "UQuota are enabled, test needs controlled sb recovery"
89         src/feature -G $SCRATCH_DEV && \
90                 _notrun "GQuota are enabled, test needs controlled sb recovery"
91         src/feature -P $SCRATCH_DEV && \
92                 _notrun "PQuota are enabled, test needs controlled sb recovery"
93         umount $SCRATCH_DEV
94 fi
95 clear=""
96 eval `xfs_db -r -c "sb 1" -c stack $SCRATCH_DEV | perl -ne '
97         if (/byte offset (\d+), length (\d+)/) {
98                 print "clear=", $1 / 512, "\n"; exit
99         }'`
100 [ -z "$clear" ] && echo "Cannot calculate length to clear"
101 src/devzero -v -1 -n "$clear" $SCRATCH_DEV >/dev/null
102
103 # now kick off the real repair test...
104 #
105 _scratch_mkfs_xfs $DSIZE | _filter_mkfs 2>$tmp.mkfs
106 . $tmp.mkfs
107 _check_ag 0
108 _check_ag -1
109
110
111 # success, all done
112 status=0
113 exit