2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Red Hat, Inc. All Rights Reserved.
7 # Check that we cannot copy_file_range() to/from an immutable file
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 7 15
18 workdir="$TEST_DIR/test-$seq"
21 $CHATTR_PROG -i $workdir/immutable > /dev/null 2>&1
26 # get standard environment, filters and checks
30 # real QA test starts here
38 _require_xfs_io_command "copy_range"
39 _require_xfs_io_command "chattr"
46 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 128k" $workdir/file >> $seqres.full 2>&1
48 # we have to open the file to be immutable rw and hold it open over the
49 # chattr command to set it immutable, otherwise we won't be able to open it for
50 # writing after it's been made immutable. (i.e. would exercise file mode checks,
51 # not immutable inode flag checks).
52 echo immutable file returns EPERM
53 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 64k" -c fsync $workdir/immutable | _filter_xfs_io
54 $XFS_IO_PROG -f -c "chattr +i" -c "copy_range -l 32k $workdir/file" $workdir/immutable
55 $XFS_IO_PROG -f -r -c "chattr -i" $workdir/immutable