xfs/007: fix regressions on V4 filesystems
[xfstests-dev.git] / tests / xfs / 278
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2011 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 278
6 #
7 # Test xfs_repair to ensure it fixes the lost+found link count
8 # at the first run. See also commit 198b747f255346bca64408875763b6ca0ed3d57d
9 # from xfsprogs tree.
10 #
11 . ./common/preamble
12 _begin_fstest repair auto
13
14 status=0        # failure is the default!
15
16 # Import common functions.
17 . ./common/filter
18
19 # real QA test starts here
20 _supported_fs xfs
21 _require_scratch
22
23 _scratch_mkfs >$seqres.full 2>&1
24 _scratch_mount
25
26 mkdir -p $SCRATCH_MNT/dir/subdir
27
28 #get inodes to be changed
29 DIR_INO=`ls -i $SCRATCH_MNT |awk '{print $1}'`
30 SUBDIR_INO=`ls -i $SCRATCH_MNT/dir |awk '{print $1}'`
31
32 _scratch_unmount
33
34 echo "Silence is goodness..."
35
36 set_ifield() {
37         _scratch_xfs_set_metadata_field "$1" 0 "inode $2" >> $seqres.full
38 }
39
40 sfdir_prefix="$(_scratch_get_sfdir_prefix "$DIR_INO" || \
41         _fail "Cannot determine sfdir prefix")"
42
43 # Corrupt DIR
44
45 set_ifield "${sfdir_prefix}.list[0].inumber.i4" "$DIR_INO"
46 set_ifield "${sfdir_prefix}.list[0].name" "$DIR_INO"
47 set_ifield "${sfdir_prefix}.list[0].offset" "$DIR_INO"
48 set_ifield "${sfdir_prefix}.list[0].namelen" "$DIR_INO"
49 set_ifield "${sfdir_prefix}.hdr.parent.i4" "$DIR_INO"
50 set_ifield "core.nlinkv2" "$DIR_INO"
51
52 # Corrupt SUBDIR
53 set_ifield "${sfdir_prefix}.hdr.parent.i4" "$SUBDIR_INO"
54 set_ifield "core.nlinkv2" "$SUBDIR_INO"
55
56 echo "===== BEGIN of xfs_repair =====" >> $seqres.full
57 echo "" >>$seqres.full
58
59 _scratch_xfs_repair >> $seqres.full 2>&1
60 echo "===== END of xfs_repair =====" >> $seqres.full
61
62 exit