xfstests: kill useless test owner fields
[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
24 seq=`basename $0`
25 echo "QA output created by $seq"
26
27 here=`pwd`
28 tmp=/tmp/$$
29 status=1        # failure is the default!
30
31 _cleanup()
32 {
33         cd /
34         blockdev --setrw $SCRATCH_DEV
35 }
36 trap "_cleanup; exit \$status" 0 1 2 3 15
37
38 # get standard environment, filters and checks
39 . ./common.rc
40 . ./common.filter
41
42 # real QA test starts here
43 _supported_fs xfs
44 _supported_os Linux
45
46 _require_scratch
47
48 _scratch_mkfs_xfs >/dev/null 2>&1
49
50 #
51 # Mark the device read-only
52 #
53 echo "setting device read-only"
54 blockdev --setro $SCRATCH_DEV
55
56 #
57 # Mount it, and make sure we can't write to it, and we can unmount it again
58 #
59 echo "mounting read-only block device:"
60 _scratch_mount 2>&1 | _filter_scratch
61
62 echo "touching file on read-only filesystem (should fail)"
63 touch $SCRATCH_MNT/foo 2>&1 | _filter_scratch
64
65 #
66 # Apparently this used to be broken at some point:
67 #       http://oss.sgi.com/bugzilla/show_bug.cgi?id=807
68 #
69 echo "unmounting read-only filesystem"
70 umount $SCRATCH_MNT 2>&1 | _filter_scratch
71
72 echo "setting device read-write"
73 blockdev --setrw $SCRATCH_DEV
74
75 echo "mounting read-write block device:"
76 _scratch_mount 2>&1 | _filter_scratch
77
78 echo "touch files"
79 touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
80
81 echo "going down:"
82 src/godown -f $SCRATCH_MNT
83
84 echo "unmounting shutdown filesystem:"
85 umount $SCRATCH_MNT 2>&1 | _filter_scratch
86
87 echo "setting device read-only"
88 blockdev --setro $SCRATCH_DEV
89
90 #
91 # Mounting a filesystem that requires log-recovery fails unless
92 # -o norecovery is used.
93 #
94 echo "mounting filesystem that needs recovery on a read-only device:"
95 _scratch_mount 2>&1 | _filter_scratch
96
97 echo "unmounting read-only filesystem"
98 umount $SCRATCH_MNT 2>&1 | _filter_scratch
99
100 #
101 # This is the way out if the underlying device really is read-only.
102 # Doesn't mean it's a good idea in practive, more a last resort
103 # data recovery hack.
104 #
105 echo "mounting filesystem with -o norecovery on a read-only device:"
106 _scratch_mount -o norecovery 2>&1 | _filter_scratch
107
108 echo "unmounting read-only filesystem"
109 umount $SCRATCH_MNT 2>&1 | _filter_scratch
110
111 echo "setting device read-write"
112 blockdev --setrw $SCRATCH_DEV
113
114 #
115 # But log recovery is performed when mount with -o ro as long as
116 # the underlying device is not write protected.
117 #
118 echo "mounting filesystem that needs recovery with -o ro:"
119 _scratch_mount -o ro 2>&1 | _filter_scratch
120
121
122 # success, all done
123 echo "*** done"
124 rm -f $seq.full
125 status=0