generic/554: hide permision warning on exfat
[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 #   96e6e8f4a68d ("vfs: add missing checks to copy_file_range")
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         $XFS_IO_PROG -f -r -c "chattr -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_fs generic
35
36 rm -f $seqres.full
37
38 _require_test
39 _require_xfs_io_command "copy_range"
40 _require_xfs_io_command "chattr" "i"
41
42 rm -rf $workdir
43 mkdir $workdir
44
45 rm -f $seqres.full
46
47 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 128k" $workdir/file >> $seqres.full 2>&1
48
49 # we have to open the file to be immutable rw and hold it open over the
50 # chattr command to set it immutable, otherwise we won't be able to open it for
51 # writing after it's been made immutable. (i.e. would exercise file mode checks,
52 # not immutable inode flag checks).
53 echo immutable file returns EPERM
54 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 64k" -c fsync $workdir/immutable | _filter_xfs_io
55 $XFS_IO_PROG -f -c "chattr +i" -c "copy_range -l 32k $workdir/file" $workdir/immutable
56 $XFS_IO_PROG -f -r -c "chattr -i" $workdir/immutable
57
58 # success, all done
59 status=0
60 exit