Added checks to ensure group quota is not used before attempting to mount with pquota...
[xfstests-dev.git] / 030
1 #! /bin/sh
2 # FS QA Test No. 030
3 #
4 # exercise xfs_repair repairing broken filesystems
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
8 #-----------------------------------------------------------------------
9 #
10 # creator
11 owner=nathans@sgi.com
12
13 seq=`basename $0`
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19
20 _cleanup()
21 {
22         cd /
23         umount $SCRATCH_DEV 2>/dev/null
24         rm -f $tmp.*
25 }
26
27 trap "_cleanup; exit \$status" 0 1 2 3 15
28
29 # get standard environment, filters and checks
30 . ./common.rc
31 . ./common.filter
32 . ./common.repair
33
34 # link correct .out file
35 _link_out_file $seq.out
36
37 # nuke the superblock, AGI, AGF, AGFL; then try repair the damage
38
39 _check_ag()
40 {
41         for structure in 'sb 0' 'agf 0' 'agi 0' 'agfl 0'
42         do
43                 echo "Corrupting $structure - setting bits to $1"
44                 _check_repair $1 "$structure"
45         done
46 }
47
48 # real QA test starts here
49 _supported_fs xfs
50 _supported_os IRIX Linux
51
52 _require_nobigloopfs
53 _require_scratch
54
55 DSIZE="-dsize=100m"
56
57 # first we need to ensure there are no bogus secondary
58 # superblocks between the primary and first secondary
59 # superblock (hanging around from earlier tests)...
60 #
61
62 _scratch_mkfs_xfs $DSIZE >/dev/null 2>&1
63 if [ $? -ne 0 ]         # probably don't have a big enough scratch
64 then
65         _notrun "SCRATCH_DEV too small, results would be non-deterministic"
66 else
67         _scratch_mount
68         src/feature -U $SCRATCH_DEV && \
69                 _notrun "UQuota are enabled, test needs controlled sb recovery"
70         src/feature -G $SCRATCH_DEV && \
71                 _notrun "GQuota are enabled, test needs controlled sb recovery"
72         src/feature -P $SCRATCH_DEV && \
73                 _notrun "PQuota are enabled, test needs controlled sb recovery"
74         umount $SCRATCH_DEV
75 fi
76 clear=""
77 eval `xfs_db -r -c "sb 1" -c stack $SCRATCH_DEV | perl -ne '
78         if (/byte offset (\d+), length (\d+)/) {
79                 print "clear=", $1 / 512, "\n"; exit
80         }'`
81 [ -z "$clear" ] && echo "Cannot calculate length to clear"
82 src/devzero -v -1 -n "$clear" $SCRATCH_DEV >/dev/null
83
84 # now kick off the real repair test...
85 #
86 _scratch_mkfs_xfs $DSIZE | _filter_mkfs 2>$tmp.mkfs
87 . $tmp.mkfs
88 _check_ag 0
89 _check_ag -1
90
91
92 # success, all done
93 status=0
94 exit