xfstests: introduce 285 for SEEK_DATA/SEEK_HOLE sanity test
[xfstests-dev.git] / 278
1 #! /bin/bash
2 # FS QA Test No. 278
3 #
4 # Test xfs_repair to ensure it fixes the lost+found link count
5 # at the first run. See also commit 198b747f255346bca64408875763b6ca0ed3d57d
6 # from xfsprogs tree.
7 #
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2011 Red Hat, Inc.  All Rights Reserved.
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #-----------------------------------------------------------------------
25 #
26 # creator
27 owner=cmaiolino@redhat.com
28
29 seq=`basename $0`
30 echo "QA output created by $seq"
31
32 here=`pwd`
33 tmp=/tmp/$$
34 status=0        # 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 # real QA test starts here
48 _supported_fs xfs
49 _supported_os Linux
50 _require_scratch
51 _scratch_mkfs >/dev/null 2>&1
52 _scratch_mount
53
54 mkdir -p $SCRATCH_MNT/dir/subdir
55
56 #get inodes to be changed
57 DIR_INO=`ls -i $SCRATCH_MNT |awk '{print $1}'`
58 SUBDIR_INO=`ls -i $SCRATCH_MNT/dir |awk '{print $1}'`
59
60 _scratch_unmount
61
62 echo "Silence is goodness..."
63
64 # Corrupt DIR
65 xfs_db -x -c "inode $DIR_INO" -c "write u.sfdir2.list[0].inumber.i4 0" $SCRATCH_DEV >> $seq.full
66 xfs_db -x -c "inode $DIR_INO" -c "write u.sfdir2.list[0].name 0" $SCRATCH_DEV >> $seq.full
67 xfs_db -x -c "inode $DIR_INO" -c "write u.sfdir2.list[0].offset 0" $SCRATCH_DEV >> $seq.full
68 xfs_db -x -c "inode $DIR_INO" -c "write u.sfdir2.list[0].namelen 0" $SCRATCH_DEV >> $seq.full
69 xfs_db -x -c "inode $DIR_INO" -c "write u.sfdir2.hdr.parent.i4 0" $SCRATCH_DEV >> $seq.full
70 xfs_db -x -c "inode $DIR_INO" -c "write core.nlinkv2 0" $SCRATCH_DEV >> $seq.full
71
72 # Corrupt SUBDIR
73 xfs_db -x -c "inode $SUBDIR_INO" -c "write u.sfdir2.hdr.parent.i4 0" $SCRATCH_DEV >> $seq.full
74 xfs_db -x -c "inode $SUBDIR_INO" -c "write core.nlinkv2 0" $SCRATCH_DEV >> $seq.full
75
76 echo "===== BEGIN of xfs_repair =====" >> $seq.full
77 echo "" >>$seq.full
78
79 xfs_repair  $SCRATCH_DEV >> $seq.full 2>&1
80 echo "===== END of xfs_repair =====" >> $seq.full
81
82 #if _check_scratch_fs; then
83 #       status=0
84 #else
85 #       status=1
86 #fi
87 exit