add freeze and dangerous groups
[xfstests-dev.git] / 200
1 #! /bin/bash
2 # FS QA Test No. 200
3 #
4 # Check out various mount/remount/unmount scenarious on a read-only blockdev.
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2009 Christoph Hellwig.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #-----------------------------------------------------------------------
22 #
23 # creator
24 owner=hch@lst.de
25
26 seq=`basename $0`
27 echo "QA output created by $seq"
28
29 here=`pwd`
30 tmp=/tmp/$$
31 status=1        # failure is the default!
32
33 _cleanup()
34 {
35         cd /
36         blockdev --setrw $SCRATCH_DEV
37 }
38 trap "_cleanup; exit \$status" 0 1 2 3 15
39
40 # get standard environment, filters and checks
41 . ./common.rc
42 . ./common.filter
43
44 # real QA test starts here
45 _supported_fs xfs
46 _supported_os Linux
47
48 _require_scratch
49
50 _scratch_mkfs_xfs >/dev/null 2>&1
51
52 #
53 # Mark the device read-only
54 #
55 echo "setting device read-only"
56 blockdev --setro $SCRATCH_DEV
57
58 #
59 # Mount it, and make sure we can't write to it, and we can unmount it again
60 #
61 echo "mounting read-only block device:"
62 _scratch_mount 2>&1 | _filter_scratch
63
64 echo "touching file on read-only filesystem (should fail)"
65 touch $SCRATCH_MNT/foo 2>&1 | _filter_scratch
66
67 #
68 # Apparently this used to be broken at some point:
69 #       http://oss.sgi.com/bugzilla/show_bug.cgi?id=807
70 #
71 echo "unmounting read-only filesystem"
72 umount $SCRATCH_MNT 2>&1 | _filter_scratch
73
74 echo "setting device read-write"
75 blockdev --setrw $SCRATCH_DEV
76
77 echo "mounting read-write block device:"
78 _scratch_mount 2>&1 | _filter_scratch
79
80 echo "touch files"
81 touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
82
83 echo "going down:"
84 src/godown -f $SCRATCH_MNT
85
86 echo "unmounting shutdown filesystem:"
87 umount $SCRATCH_MNT 2>&1 | _filter_scratch
88
89 echo "setting device read-only"
90 blockdev --setro $SCRATCH_DEV
91
92 #
93 # Mounting a filesystem that requires log-recovery fails unless
94 # -o norecovery is used.
95 #
96 echo "mounting filesystem that needs recovery on a read-only device:"
97 _scratch_mount 2>&1 | _filter_scratch
98
99 echo "unmounting read-only filesystem"
100 umount $SCRATCH_MNT 2>&1 | _filter_scratch
101
102 #
103 # This is the way out if the underlying device really is read-only.
104 # Doesn't mean it's a good idea in practive, more a last resort
105 # data recovery hack.
106 #
107 echo "mounting filesystem with -o norecovery on a read-only device:"
108 _scratch_mount -o norecovery 2>&1 | _filter_scratch
109
110 echo "unmounting read-only filesystem"
111 umount $SCRATCH_MNT 2>&1 | _filter_scratch
112
113 echo "setting device read-write"
114 blockdev --setrw $SCRATCH_DEV
115
116 #
117 # But log recovery is performed when mount with -o ro as long as
118 # the underlying device is not write protected.
119 #
120 echo "mounting filesystem that needs recovery with -o ro:"
121 _scratch_mount -o ro 2>&1 | _filter_scratch
122
123
124 # success, all done
125 echo "*** done"
126 rm -f $seq.full
127 status=0