c168fec8de4a3e0f6641c9a3da201c6a875e6baa
[xfstests-dev.git] / tests / xfs / 199
1 #! /bin/bash
2 # FS QA Test No. 199
3 #
4 # Check that the features2 location fixups work correctly.  We check both
5 # a regular read-write mount of a filesystem and the case where the
6 # filesystem is first mounted read-only and then later remounted read-write,
7 # which is the usual case for the root filesystem.
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2008 Christoph Hellwig.
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #-----------------------------------------------------------------------
25 #
26
27 seq=`basename $0`
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34
35 _cleanup()
36 {
37         cd /
38         umount $SCRATCH_MNT >/dev/null 2>&1
39 }
40 trap "_cleanup; exit \$status" 0 1 2 3 15
41
42 # get standard environment, filters and checks
43 . ./common/rc
44 . ./common/filter
45
46 # real QA test starts here
47 _supported_fs xfs
48 _supported_os Linux
49
50 _require_scratch
51
52 get_features()
53 {
54         xfs_db -x $SCRATCH_DEV -c "sb" -c "print $1" | awk '// {print $3}'
55 }
56
57 # clear any mkfs options so that we can directly specify the options we need to
58 # be able to test the features bitmask behaviour correctly.
59 MKFS_OPTIONS=
60 _scratch_mkfs_xfs -m crc=0 -l lazy-count=1 >/dev/null 2>&1
61
62 # Grab the initial configuration. This checks mkfs sets the fields properly, and
63 # gives us the values the resultant tests should be the same as for testing at
64 # the end of the test. We don't hard code feature values, because that makes the
65 # test break every time we change mkfs feature defaults.
66 f2=`get_features features2`
67 bf2=`get_features bad_features2`
68
69 #
70 # Now clear the normal flags
71 #
72 echo "Clearing features2:"
73 xfs_db -x $SCRATCH_DEV -c 'sb' -c 'write features2 0'
74
75 _scratch_mount
76 umount $SCRATCH_MNT
77 rwf2=`get_features features2`
78
79 #
80 # Clear the normal flags again for the second rount.
81 #
82 echo "Clearing features2:"
83 xfs_db -x $SCRATCH_DEV -c 'sb' -c 'write features2 0'
84
85 #
86 # And print the flags after a mount ro and remount rw
87 #
88 _scratch_mount -o ro
89 _scratch_mount -o remount,rw
90 umount $SCRATCH_MNT
91 rof2=`get_features features2`
92
93 [ "$f2" != "$bf2" ] && echo "mkfs: features2 $f2 != bad_features2 $bf2"
94 [ "$f2" != "$rwf2" ] && echo "mount rw: old features2 $f2 != new features2 $rwf2"
95 [ "$f2" != "$rof2" ] && echo "ro->rw: old features2 $f2 != new features2 $rof2"
96
97 # success, all done
98 echo "*** done"
99 rm -f $seqres.full
100 status=0