xfs: test what happens when we reset the root dir and it has xattrs
[xfstests-dev.git] / tests / xfs / 451
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Red Hat Inc.  All Rights Reserved.
4 #
5 # FS QA Test 451
6 #
7 # Make sure xfs_repair can repair root inode parent's pointer
8 # when it contains a bogus ino when it's using shot form directory
9
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28
29 # remove previous $seqres.full before test
30 rm -f $seqres.full
31
32 echo "Silence is golden"
33
34 # real QA test starts here
35
36 # Modify as appropriate.
37 _supported_fs xfs
38 _require_scratch
39
40 _scratch_mkfs >> /dev/null 2>&1
41
42 rootino=$(_scratch_xfs_get_metadata_field 'rootino' 'sb 0')
43
44 prefix=$(_scratch_get_sfdir_prefix ${rootino} || \
45                         _fail "Cannot determine sfdir prefix")
46
47 # Corrupt root inode parent pointer
48 _scratch_xfs_set_metadata_field "${prefix}.hdr.parent.i4" 0 "inode ${rootino}"\
49                                                 >> $seqres.full 2>&1
50
51 _scratch_xfs_repair >> $seqres.full 2>&1
52
53 # Post-test integrity check will detect any remaining corruption
54
55 status=0
56 exit