4 # Test RW open of a device on a RO fs
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2013 Red Hat, Inc. All Rights Reserved.
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.
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.
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 #-----------------------------------------------------------------------
25 seqres=$RESULT_DIR/$seq
26 echo "QA output created by $seq"
30 status=1 # failure is the default!
31 trap "_cleanup; exit \$status" 0 1 2 3 15
40 # get standard environment, filters and checks
44 # real QA test starts here
46 # Modify as appropriate.
52 DEVNULL=$SCRATCH_MNT/devnull
53 DEVZERO=$SCRATCH_MNT/devzero
54 SYMLINK=$SCRATCH_MNT/symlink
55 BINDFILE=$SCRATCH_MNT/bindfile
56 TARGET=$TEST_DIR/target
59 _scratch_mkfs > $seqres.full 2>&1
62 rm -f $DEVNULL $DEVZERO
64 mknod $DEVNULL c 1 3 || _fail "Could not create devnull device"
65 mknod $DEVZERO c 1 5 || _fail "Could not create devzero device"
66 touch $BINDFILE || _fail "Could not create bind mount file"
67 touch $TARGET || _fail "Could not create symlink target"
68 ln -s $TARGET $SYMLINK
70 _scratch_remount ro || _fail "Could not remount scratch readonly"
72 # We should be able to read & write to/from these devices even on an RO fs
73 echo "== try to create new file"
74 touch $SCRATCH_MNT/this_should_fail 2>&1 | _filter_scratch
75 echo "== pwrite to null device"
76 $XFS_IO_PROG -c "pwrite 0 512" $DEVNULL | _filter_xfs_io
77 echo "== pread from zero device"
78 $XFS_IO_PROG -c "pread 0 512" $DEVZERO | _filter_xfs_io
80 echo "== truncating write to null device"
81 echo foo > $DEVNULL 2>&1 | _filter_scratch
82 echo "== appending write to null device"
83 echo foo >> $DEVNULL 2>&1 | _filter_scratch
85 echo "== writing to symlink from ro fs to rw fs"
86 # Various combinations of O_CREAT & O_TRUNC
87 $XFS_IO_PROG -c "pwrite 0 512" $SYMLINK | _filter_xfs_io
88 $XFS_IO_PROG -f -c "pwrite 0 512" $SYMLINK | _filter_xfs_io
89 $XFS_IO_PROG -t -c "pwrite 0 512" $SYMLINK | _filter_xfs_io
91 echo "== write to bind-mounted rw file on ro fs"
92 mount --bind $TARGET $BINDFILE
93 # with and without -f (adds O_CREAT)
94 $XFS_IO_PROG -c "pwrite 0 512" $BINDFILE | _filter_xfs_io
95 $XFS_IO_PROG -f -c "pwrite 0 512" $BINDFILE | _filter_xfs_io
96 $XFS_IO_PROG -t -c "pwrite 0 512" $BINDFILE | _filter_xfs_io