xfstests: cleanup duplicates in all tests
[xfstests-dev.git] / tests / xfs / 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 # Copyright (c) 2011 Red Hat, Inc.  All Rights Reserved.
10 #
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
14 #
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23 #-----------------------------------------------------------------------
24 #
25
26 seq=`basename $0`
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=0        # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
34
35 _cleanup()
36 {
37     cd /
38     rm -f $tmp.*
39 }
40
41 # get standard environment, filters and checks
42 . ./common/rc
43 . ./common/filter
44
45 # real QA test starts here
46 _supported_fs xfs
47 _supported_os Linux
48 _require_scratch
49 _scratch_mkfs >/dev/null 2>&1
50 _scratch_mount
51
52 mkdir -p $SCRATCH_MNT/dir/subdir
53
54 #get inodes to be changed
55 DIR_INO=`ls -i $SCRATCH_MNT |awk '{print $1}'`
56 SUBDIR_INO=`ls -i $SCRATCH_MNT/dir |awk '{print $1}'`
57
58 _scratch_unmount
59
60 echo "Silence is goodness..."
61
62 # Corrupt DIR
63 xfs_db -x -c "inode $DIR_INO" -c "write u.sfdir2.list[0].inumber.i4 0" $SCRATCH_DEV >> $seqres.full
64 xfs_db -x -c "inode $DIR_INO" -c "write u.sfdir2.list[0].name 0" $SCRATCH_DEV >> $seqres.full
65 xfs_db -x -c "inode $DIR_INO" -c "write u.sfdir2.list[0].offset 0" $SCRATCH_DEV >> $seqres.full
66 xfs_db -x -c "inode $DIR_INO" -c "write u.sfdir2.list[0].namelen 0" $SCRATCH_DEV >> $seqres.full
67 xfs_db -x -c "inode $DIR_INO" -c "write u.sfdir2.hdr.parent.i4 0" $SCRATCH_DEV >> $seqres.full
68 xfs_db -x -c "inode $DIR_INO" -c "write core.nlinkv2 0" $SCRATCH_DEV >> $seqres.full
69
70 # Corrupt SUBDIR
71 xfs_db -x -c "inode $SUBDIR_INO" -c "write u.sfdir2.hdr.parent.i4 0" $SCRATCH_DEV >> $seqres.full
72 xfs_db -x -c "inode $SUBDIR_INO" -c "write core.nlinkv2 0" $SCRATCH_DEV >> $seqres.full
73
74 echo "===== BEGIN of xfs_repair =====" >> $seqres.full
75 echo "" >>$seqres.full
76
77 xfs_repair  $SCRATCH_DEV >> $seqres.full 2>&1
78 echo "===== END of xfs_repair =====" >> $seqres.full
79
80 #if _check_scratch_fs; then
81 #       status=0
82 #else
83 #       status=1
84 #fi
85 exit