xfs: fix old fuzz test invocations of xfs_repair
[xfstests-dev.git] / tests / xfs / 491
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Oracle.  All Rights Reserved.
4 #
5 # FS QA Test No. 491
6 #
7 # Test detection & fixing of bad summary block counts at mount time.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap '_cleanup; exit $status' 0 1 2 3 15
17
18 _cleanup()
19 {
20         cd /
21         rm -f $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27
28 # remove previous $seqres.full before test
29 rm -f $seqres.full
30
31 # real QA test starts here
32
33 # Modify as appropriate.
34 _supported_fs xfs
35 _require_scratch
36
37 echo "Format and mount"
38 _scratch_mkfs > $seqres.full 2>&1
39
40 # pre-lazysbcount filesystems blindly trust the primary sb fdblocks
41 _require_scratch_xfs_features LAZYSBCOUNT
42
43 _scratch_mount >> $seqres.full 2>&1
44 echo "test file" > $SCRATCH_MNT/testfile
45
46 echo "Fuzz fdblocks"
47 _scratch_unmount
48 dblocks=$(_scratch_xfs_get_metadata_field dblocks 'sb 0')
49 _scratch_xfs_set_metadata_field fdblocks $((dblocks * 2)) 'sb 0' > $seqres.full 2>&1
50
51 echo "Detection and Correction"
52 _scratch_mount >> $seqres.full 2>&1
53 avail=$(stat -c '%a' -f $SCRATCH_MNT)
54 total=$(stat -c '%b' -f $SCRATCH_MNT)
55 echo "avail: $avail" >> $seqres.full
56 echo "total: $total" >> $seqres.full
57 test "$avail" -gt "$total" && echo "free space bad: $avail > $total"
58
59 # success, all done
60 status=0
61 exit