Add GPL license plate to SGI's test files.
[xfstests-dev.git] / 033
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. 033
22 #
23 # exercise xfs_repair repairing broken filesystems (root inodes)
24 #
25 # creator
26 owner=nathans@sgi.com
27
28 seq=`basename $0`
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34
35 _cleanup()
36 {
37     cd /
38     umount $SCRATCH_DEV 2>/dev/null
39     rm -f $tmp.*
40 }
41
42 trap "_cleanup; exit \$status" 0 1 2 3 15
43
44 # get standard environment, filters and checks
45 . ./common.rc
46 . ./common.filter
47 . ./common.repair
48
49 # link correct .out file
50 _link_out_file $seq.out
51
52 # nuke the root, rt bitmap, and rt summary inodes
53
54 _check_root_inos()
55 {
56         echo "Corrupting root inode - setting bits to $1"
57         _check_repair $1 "inode $rootino"
58         echo "Corrupting rt bitmap inode - setting bits to $1"
59         _check_repair $1 "inode $rbmino"
60         echo "Corrupting rt summary inode - setting bits to $1"
61         _check_repair $1 "inode $rsumino"
62 }
63
64 #
65 # pv#909621
66 # IRIX checks for valid user and group ids as we have a 
67 # limit of MAXID
68 # As it is unsigned on Linux, this test is not done
69 # (i.e. -1 is a valid id on Linux but not on IRIX)
70 # So we make the output the same for both OS's.
71 #
72 _filter_bad_ids()
73 {
74         egrep -v 'bad user id 0xffffffff|bad group id 0xffffffff'
75 }
76
77 # real QA test starts here
78 _supported_fs xfs
79 _supported_os IRIX Linux
80  
81 _require_nobigloopfs
82 _require_scratch
83
84 # devzero blows away 512byte blocks, so make 512byte inodes (at least)
85 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
86 . $tmp.mkfs
87 [ $isize -lt 512 ] && \
88         _scratch_mkfs_xfs -isize=512 | _filter_mkfs >/dev/null 2>&1
89
90 `xfs_db -r -c sb -c p $SCRATCH_DEV | grep 'ino = ' | \
91         sed -e 's/ //g' -e 's/^/export /'`
92
93 # check we won't get any quota inodes setup on mount
94 _scratch_mount
95 src/feature -U $SCRATCH_DEV && \
96         _notrun "UQuota are enabled, test needs controlled sb recovery"
97 src/feature -G $SCRATCH_DEV && \
98         _notrun "GQuota are enabled, test needs controlled sb recovery"
99 src/feature -P $SCRATCH_DEV && \
100         _notrun "PQuota are enabled, test needs controlled sb recovery"
101 umount $SCRATCH_DEV
102
103 # rootino, rbmino, and rsumino are now set (lets blow em away!)
104 _check_root_inos 0
105 _check_root_inos -1 | _filter_bad_ids
106
107 # success, all done
108 status=0
109 exit