xfs/007: fix regressions on V4 filesystems
[xfstests-dev.git] / tests / xfs / 195
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2008 Christoph Hellwig.
4 #
5 # FS QA Test No. 195
6 #
7 # Make sure the chattr dump flag gets picked up by xfsdump without a sync
8 #
9 # http://oss.sgi.com/bugzilla/show_bug.cgi?id=340
10 #
11 . ./common/preamble
12 _begin_fstest ioctl dump auto quick
13
14 # Override the default cleanup function.
15 _cleanup()
16 {
17         rm -rf $TEST_DIR/d
18         rm -f $TEST_DIR/dumpfile
19 }
20
21 #
22 # Perform a level 0 dump that respects the chattr dump exclude flag,
23 # and grep the output for the inode number we expect / do not expect
24 # to be skipped
25 #
26 # Only dump a subtree so we get away with a single partition for
27 # the subtree to be dumped and the dump file.
28 #
29 _do_dump()
30 {
31         $XFSDUMP_PROG -l 0 -s d -F  \
32                 -L prova -M prova \
33                 -f $TEST_DIR/dumpfile -v excluded_files=debug $TEST_DIR \
34                 | grep "ino $inum" \
35                 | sed -e 's/.*xfsdump: pruned ino [0-9]*, owner 0, estimated size 0: skip flag set/xfsdump: pruned ino NNN, owner 0, estimated size 0: skip flag set/'
36 }
37
38 # Import common functions.
39 . ./common/filter
40
41 # real QA test starts here
42 _supported_fs xfs
43
44 _require_test
45 _require_user
46 _require_command "$XFSDUMP_PROG" xfsdump
47
48 echo "Preparing subtree"
49 mkdir $TEST_DIR/d
50 touch $TEST_DIR/d/t
51 inum=`stat -c "%i" $TEST_DIR/d/t`
52
53 echo "No dump exclude flag set (should not be skipped)"
54 _do_dump
55
56 echo "Dump exclude flag set, but no sync yet (should be skipped)"
57 $CHATTR_PROG +d $TEST_DIR/d/t
58 _do_dump
59
60 echo "Dump exclude flag set, after sync (should be skipped)"
61 sync
62 _do_dump
63
64 # success, all done
65 echo "*** done"
66 status=0