76f130ebdf66b99a09055b84030d8298e9e430ce
[xfstests-dev.git] / tests / xfs / 195
1 #! /bin/bash
2 # FS QA Test No. 195
3 #
4 # Make sure the chattr dump flag gets picked up by xfsdump without a sync
5 #
6 # http://oss.sgi.com/bugzilla/show_bug.cgi?id=340
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2008 Christoph Hellwig.
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=1        # failure is the default!
33
34 _cleanup()
35 {
36         rm -rf $TEST_DIR/d
37         rm -f $TEST_DIR/dumpfile
38 }
39 trap "_cleanup; exit \$status" 0 1 2 3 15
40
41 #
42 # Perform a level 0 dump that respects the chattr dump exclude flag,
43 # and grep the output for the inode number we expect / do not expect
44 # to be skipped
45 #
46 # Only dump a subtree so we get away with a single partition for
47 # the subtree to be dumped and the dump file.
48 #
49 _do_dump()
50 {
51         $XFSDUMP_PROG -l 0 -s d -F  \
52                 -L prova -M prova \
53                 -f $TEST_DIR/dumpfile -v excluded_files=debug $TEST_DIR \
54                 | grep "ino $inum" \
55                 | 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/'
56 }
57
58 # get standard environment, filters and checks
59 . ./common/rc
60 . ./common/filter
61
62 # real QA test starts here
63 _supported_fs xfs
64 _supported_os Linux
65
66 _require_test
67 _require_user
68 _require_command $XFSDUMP_PROG xfsdump
69
70 echo "Preparing subtree"
71 mkdir $TEST_DIR/d
72 touch $TEST_DIR/d/t
73 inum=`stat -c "%i" $TEST_DIR/d/t`
74
75 echo "No dump exclude flag set (should not be skipped)"
76 _do_dump
77
78 echo "Dump exclude flag set, but no sync yet (should be skipped)"
79 chattr +d $TEST_DIR/d/t
80 _do_dump
81
82 echo "Dump exclude flag set, after sync (should be skipped)"
83 sync
84 _do_dump
85
86 # success, all done
87 echo "*** done"
88 rm -f $seqres.full
89 status=0