xfs: fix $XFS_DB_PROG usage
[xfstests-dev.git] / tests / xfs / 002
1 #! /bin/bash
2 # FS QA Test No. 002
3 #
4 # Test that garbage in old v4 superblocks doesn't trip verifiers during growfs
5 #
6 # Older kernels sometimes left garbage in the unused portions
7 # of the superblock during growfs; with the new verifiers this initially
8 # caused failures during a subsequent growfs; see
9 # 10e6e65 xfs: be more forgiving of a v4 secondary sb w/ junk in v5 fields
10 # for further explanation.  (NB: while the commit log was good, the
11 # patch had a bug which was subsequently fixed)
12 #
13 #-----------------------------------------------------------------------
14 # Copyright (c) 2014 Red Hat, Inc.  All Rights Reserved.
15 #
16 # This program is free software; you can redistribute it and/or
17 # modify it under the terms of the GNU General Public License as
18 # published by the Free Software Foundation.
19 #
20 # This program is distributed in the hope that it would be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 # GNU General Public License for more details.
24 #
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write the Free Software Foundation,
27 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
28 #-----------------------------------------------------------------------
29 #
30
31 seq=`basename $0`
32 seqres=$RESULT_DIR/$seq
33 echo "QA output created by $seq"
34
35 here=`pwd`
36 tmp=/tmp/$$
37 status=1        # failure is the default!
38 trap "_cleanup; exit \$status" 0 1 2 3 15
39
40 _cleanup()
41 {
42     cd /
43     rm -f $tmp.*
44 }
45
46 # get standard environment, filters and checks
47 . ./common/rc
48 . ./common/filter
49
50 # Modify as appropriate.
51 _supported_fs xfs
52 _supported_os Linux
53 _require_scratch_nocheck
54
55 # So we can explicitly turn it _off_:
56 _require_xfs_mkfs_crc
57
58 rm -f $seqres.full
59
60 _scratch_mkfs_xfs -m crc=0 -d size=128m >> $seqres.full 2>&1 || _fail "mkfs failed"
61
62 # Scribble past a couple V4 secondary superblocks to populate sb_crc
63 # (We can't write to the structure member because it doesn't exist
64 # on a v4 superblock, so we use the data type & "write fill")
65 _scratch_xfs_db -x -c "sb 1" -c "type data" -c "write fill 0xff 224 4"
66 _scratch_xfs_db -x -c "sb 2" -c "type data" -c "write fill 0xff 224 4"
67
68 _scratch_mount
69
70 # This should pass
71 $XFS_GROWFS_PROG $SCRATCH_MNT >> $seqres.full 2>&1 || _fail "growfs failed"
72
73 # success, all done
74 status=0
75 exit