fsx: Replace use of bzero() with memset()
[xfstests-dev.git] / 187
1 #! /bin/sh
2 # FS QA Test No. 187
3 #
4 # To test out the noattr2 flag which is broken in pv#980021
5 # Given an existing attr2 filesystem, we should be able to mount
6 # as noattr2 and go back to an attr1 filesystem.
7 #
8 # Test the case where there are no more features2 bits on and
9 # so the morebitsbit should be off.
10 #
11 #-----------------------------------------------------------------------
12 # Copyright (c) 2008 Silicon Graphics, Inc.  All Rights Reserved.
13 #-----------------------------------------------------------------------
14 #
15 # creator
16 owner=tes@emu.melbourne.sgi.com
17
18 seq=`basename $0`
19 echo "QA output created by $seq"
20
21 here=`pwd`
22 tmp=/tmp/$$
23 status=1        # failure is the default!
24 trap "_cleanup; exit \$status" 0 1 2 3 15
25
26 _cleanup()
27 {
28     cd /
29     rm -f $tmp.*
30 }
31
32 _filter_version()
33 {
34         tee -a $seq.full | tr ',' '\n' | egrep 'ATTR|MORE|LAZY'
35 }
36
37 # get standard environment, filters and checks
38 . ./common.rc
39 . ./common.filter
40
41 # real QA test starts here
42 _require_scratch
43 _supported_fs xfs
44 _supported_os Linux
45 rm -f $seq.full
46
47 # lazysb and attr2 are in features2 and will require morebitsbit on
48 # So test with lazysb and without it to see if the morebitsbit is
49 # okay etc....
50 # Reset the options so that we can control what is going on here
51 export MKFS_OPTIONS=""
52 export MOUNT_OPTIONS=""
53
54 # Make sure that when we think we are testing with morebits off
55 # that we really are.
56 # Trying to future-proof in case mkfs defaults change.
57 _scratch_mkfs -i attr=1 >/dev/null 2>&1
58 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 >$tmp.db
59 if grep -i morebits $tmp.db
60 then
61         echo ""
62         echo "Need to update test $seq so that initial subtests do not use features2"
63         echo ""
64         exit
65 fi
66
67 echo ""
68 echo "*** 1. test attr2 mkfs and then noattr2 mount ***"
69 echo ""
70 echo "attr2 fs"
71 echo ""
72 _scratch_mkfs -i attr=2 -l lazy-count=0 >/dev/null 2>&1
73 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
74 echo ""
75 echo "noattr2 fs"
76 echo ""
77 _scratch_mount -o noattr2
78 $UMOUNT_PROG $SCRATCH_MNT
79 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
80
81 # adding an EA will ensure the ATTR1 flag is turned on
82 echo ""
83 echo "*** 2. test attr2 mkfs and then noattr2 mount with 1 EA ***"
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 cd $SCRATCH_MNT
94 touch testfile
95 setfattr -n user.test -v 0xbabe testfile
96 getfattr testfile
97 cd $here
98 $UMOUNT_PROG $SCRATCH_MNT
99 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
100
101 echo ""
102 echo "*** 3. test noattr2 mount and lazy sb ***"
103 echo ""
104 echo ""
105 echo "attr2 fs"
106 echo ""
107 _scratch_mkfs -i attr=2 -l lazy-count=1 >/dev/null 2>&1
108 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
109 echo ""
110 echo "noattr2 fs"
111 echo ""
112 _scratch_mount -o noattr2
113 cd $SCRATCH_MNT
114 touch testfile
115 cd $here
116 $UMOUNT_PROG $SCRATCH_MNT
117 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
118
119 # success, all done
120 status=0
121 exit