generic/553: fix test description
[xfstests-dev.git] / tests / generic / 553
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 553
6 #
7 # Check that we cannot copy_file_range() to an immutable file
8 #
9 # This is a regression test for kernel commit:
10 #   a31713517dac ("vfs: introduce generic_file_rw_checks()")
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 7 15
20
21 workdir="$TEST_DIR/test-$seq"
22 _cleanup()
23 {
24         $CHATTR_PROG -i $workdir/immutable > /dev/null 2>&1
25         cd /
26         rm -f $tmp.*
27 }
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32
33 # real QA test starts here
34 _supported_os Linux
35 _supported_fs generic
36
37 rm -f $seqres.full
38
39 _require_test
40 _require_chattr i
41 _require_xfs_io_command "copy_range"
42 _require_xfs_io_command "chattr"
43
44 rm -rf $workdir
45 mkdir $workdir
46
47 rm -f $seqres.full
48
49 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 128k" $workdir/file >> $seqres.full 2>&1
50
51 # we have to open the file to be immutable rw and hold it open over the
52 # chattr command to set it immutable, otherwise we won't be able to open it for
53 # writing after it's been made immutable. (i.e. would exercise file mode checks,
54 # not immutable inode flag checks).
55 echo immutable file returns EPERM
56 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 64k" -c fsync $workdir/immutable | _filter_xfs_io
57 $XFS_IO_PROG -f -c "chattr +i" -c "copy_range -l 32k $workdir/file" $workdir/immutable
58 $XFS_IO_PROG -f -r -c "chattr -i" $workdir/immutable
59
60 # success, all done
61 status=0
62 exit