ebf4b15ec9b51d0d97414de47c0f971980ed84da
[xfstests-dev.git] / tests / xfs / 005
1 #! /bin/bash
2 # FS QA Test No. 005
3 #
4 # Test that a bad crc on a primary V5 superblock will fail the mount
5 #
6 # 10e6e65 xfs: be more forgiving of a v4 secondary sb w/ junk in v5 fields
7 # inadvertently caused primary SB CRC failures to not error out, this
8 # is a regression test for that fix.
9 #
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2014 Red Hat, Inc.  All Rights Reserved.
12 #
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
16 #
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25 #-----------------------------------------------------------------------
26 #
27
28 seq=`basename $0`
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 trap "_cleanup; exit \$status" 0 1 2 3 15
36
37 _cleanup()
38 {
39     cd /
40     rm -f $tmp.*
41 }
42
43 # get standard environment, filters and checks
44 . ./common/rc
45 . ./common/filter
46
47 # Modify as appropriate.
48 _supported_fs xfs
49 _supported_os Linux
50
51 _require_scratch_nocheck
52 _require_xfs_mkfs_crc
53
54 rm -f $seqres.full
55
56 _scratch_mkfs_xfs -m crc=1 >> $seqres.full 2>&1 || _fail "mkfs failed"
57
58 # Zap the crc.  xfs_db updates the CRC post-write, so poke it directly
59 $XFS_IO_PROG -c "pwrite 224 4" -c fsync $SCRATCH_DEV | _filter_xfs_io
60
61 # should FAIL, the crc is bad; golden output contains mount failure
62 _scratch_mount 2>&1 | _filter_error_mount
63
64 # success, all done
65 status=0
66 exit