4cc76d72e00e0313fbb061e0df546032f86ee59e
[xfstests-dev.git] / 187
1 #! /bin/sh
2 #
3 #-----------------------------------------------------------------------
4 # Copyright (c) 2008 Silicon Graphics, Inc.  All Rights Reserved.
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation.
9 #
10 # This program is distributed in the hope that it would be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write the Free Software Foundation,
17 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 #
19 #-----------------------------------------------------------------------
20 #
21 # FS QA Test No. 187
22 #
23 # To test out the noattr2 flag which is broken in pv#980021
24 # Given an existing attr2 filesystem, we should be able to mount
25 # as noattr2 and go back to an attr1 filesystem.
26 #
27 # Test the case where there are no more features2 bits on and
28 # so the morebitsbit should be off.
29 #
30 # creator
31 owner=tes@emu.melbourne.sgi.com
32
33 seq=`basename $0`
34 echo "QA output created by $seq"
35
36 here=`pwd`
37 tmp=/tmp/$$
38 status=1        # failure is the default!
39 trap "_cleanup; exit \$status" 0 1 2 3 15
40
41 _cleanup()
42 {
43     cd /
44     rm -f $tmp.*
45 }
46
47 _filter_version()
48 {
49         tee -a $seq.full | tr ',' '\n' | egrep 'ATTR|MORE|LAZY'
50 }
51
52 # get standard environment, filters and checks
53 . ./common.rc
54 . ./common.filter
55
56 # real QA test starts here
57 _require_scratch
58 _supported_fs xfs
59 _supported_os Linux
60 rm -f $seq.full
61
62 # lazysb and attr2 are in features2 and will require morebitsbit on
63 # So test with lazysb and without it to see if the morebitsbit is
64 # okay etc....
65 # Reset the options so that we can control what is going on here
66 export MKFS_OPTIONS=""
67 export MOUNT_OPTIONS=""
68
69 # Make sure that when we think we are testing with morebits off
70 # that we really are.
71 # Trying to future-proof in case mkfs defaults change.
72 _scratch_mkfs -i attr=1 >/dev/null 2>&1
73 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 >$tmp.db
74 if grep -i morebits $tmp.db
75 then
76         echo ""
77         echo "Need to update test $seq so that initial subtests do not use features2"
78         echo ""
79         exit
80 fi
81
82 echo ""
83 echo "*** 1. test attr2 mkfs and then noattr2 mount ***"
84 echo ""
85 echo "attr2 fs"
86 echo ""
87 _scratch_mkfs -i attr=2 -l lazy-count=0 >/dev/null 2>&1
88 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
89 echo ""
90 echo "noattr2 fs"
91 echo ""
92 _scratch_mount -o noattr2
93 $UMOUNT_PROG $SCRATCH_MNT
94 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
95
96 # adding an EA will ensure the ATTR1 flag is turned on
97 echo ""
98 echo "*** 2. test attr2 mkfs and then noattr2 mount with 1 EA ***"
99 echo ""
100 echo "attr2 fs"
101 echo ""
102 _scratch_mkfs -i attr=2 -l lazy-count=0 >/dev/null 2>&1
103 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
104 echo ""
105 echo "noattr2 fs"
106 echo ""
107 _scratch_mount -o noattr2
108 cd $SCRATCH_MNT
109 touch testfile
110 setfattr -n user.test -v 0xbabe testfile
111 getfattr testfile
112 cd $here
113 $UMOUNT_PROG $SCRATCH_MNT
114 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
115
116 echo ""
117 echo "*** 3. test noattr2 mount and lazy sb ***"
118 echo ""
119 echo ""
120 echo "attr2 fs"
121 echo ""
122 _scratch_mkfs -i attr=2 -l lazy-count=1 >/dev/null 2>&1
123 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
124 echo ""
125 echo "noattr2 fs"
126 echo ""
127 _scratch_mount -o noattr2
128 cd $SCRATCH_MNT
129 touch testfile
130 cd $here
131 $UMOUNT_PROG $SCRATCH_MNT
132 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
133
134 # success, all done
135 status=0
136 exit