145805cdbcf8a7dc9760dd3253f08ee14a0336a1
[xfstests-dev.git] / tests / xfs / 033
1 #! /bin/bash
2 # FS QA Test No. 033
3 #
4 # exercise xfs_repair repairing broken filesystems (root inodes)
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #
22 #-----------------------------------------------------------------------
23 #
24
25 seqfull=$0
26 seq=`basename $0`
27 seqres=$RESULT_DIR/$seq
28 seqres=$RESULT_DIR/$seq
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
31
32 here=`pwd`
33 tmp=/tmp/$$
34 status=1        # failure is the default!
35
36 _cleanup()
37 {
38     cd /
39     umount $SCRATCH_DEV 2>/dev/null
40     rm -f $tmp.*
41 }
42
43 trap "_cleanup; exit \$status" 0 1 2 3 15
44
45 # get standard environment, filters and checks
46 . ./common/rc
47 . ./common/filter
48 . ./common/repair
49
50 # link correct .out file
51 _link_out_file $seq.out $seqfull.out
52
53 # nuke the root, rt bitmap, and rt summary inodes
54
55 _check_root_inos()
56 {
57         echo "Corrupting root inode - setting bits to $1"
58         _check_repair $1 "inode $rootino"
59         echo "Corrupting rt bitmap inode - setting bits to $1"
60         _check_repair $1 "inode $rbmino"
61         echo "Corrupting rt summary inode - setting bits to $1"
62         _check_repair $1 "inode $rsumino"
63 }
64
65 #
66 # pv#909621
67 # IRIX checks for valid user and group ids as we have a 
68 # limit of MAXID
69 # As it is unsigned on Linux, this test is not done
70 # (i.e. -1 is a valid id on Linux but not on IRIX)
71 # So we make the output the same for both OS's.
72 #
73 _filter_bad_ids()
74 {
75         egrep -v 'bad user id 0xffffffff|bad group id 0xffffffff'
76 }
77
78 # real QA test starts here
79 _supported_fs xfs
80 _supported_os IRIX Linux
81
82 _require_scratch
83 _require_no_large_scratch_dev
84
85 # devzero blows away 512byte blocks, so make 512byte inodes (at least)
86 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
87 . $tmp.mkfs
88 [ $isize -lt 512 ] && \
89         _scratch_mkfs_xfs -isize=512 | _filter_mkfs >/dev/null 2>&1
90
91 `xfs_db -r -c sb -c p $SCRATCH_DEV | grep 'ino = ' | \
92         sed -e 's/ //g' -e 's/^/export /'`
93
94 # check we won't get any quota inodes setup on mount
95 _scratch_mount
96 src/feature -U $SCRATCH_DEV && \
97         _notrun "UQuota are enabled, test needs controlled sb recovery"
98 src/feature -G $SCRATCH_DEV && \
99         _notrun "GQuota are enabled, test needs controlled sb recovery"
100 src/feature -P $SCRATCH_DEV && \
101         _notrun "PQuota are enabled, test needs controlled sb recovery"
102 umount $SCRATCH_DEV
103
104 # rootino, rbmino, and rsumino are now set (lets blow em away!)
105 _check_root_inos 0
106 _check_root_inos -1 | _filter_bad_ids
107
108 # success, all done
109 status=0
110 exit