xfs: test what happens when we reset the root dir and it has xattrs
[xfstests-dev.git] / tests / xfs / 162
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2021 Oracle.  All Rights Reserved.
4 #
5 # FS QA Test No. 162
6 #
7 # Make sure that attrs are handled properly when repair has to reset the root
8 # 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 7 15
18
19 _cleanup()
20 {
21         cd /
22         rm -rf $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/populate
29 . ./common/fuzzy
30
31 # real QA test starts here
32 _supported_fs xfs
33 _require_scratch_nocheck
34
35 rm -f $seqres.full
36
37 echo "Format and populate btree attr root dir"
38 _scratch_mkfs > "$seqres.full" 2>&1
39 _scratch_mount
40
41 blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
42 __populate_create_attr "${SCRATCH_MNT}" "$((64 * blksz / 40))" true
43 _scratch_unmount
44
45 echo "Break the root directory"
46 _scratch_xfs_fuzz_metadata_field core.mode zeroes 'sb 0' 'addr rootino' >> $seqres.full 2>&1
47
48 echo "Detect bad root directory"
49 _scratch_xfs_repair -n >> $seqres.full 2>&1 && \
50         echo "Should have detected bad root dir"
51
52 echo "Fix bad root directory"
53 _scratch_xfs_repair >> $seqres.full 2>&1
54
55 echo "Detect fixed root directory"
56 _scratch_xfs_repair -n >> $seqres.full 2>&1
57
58 echo "Mount test"
59 _scratch_mount
60
61 # success, all done
62 status=0
63 exit