mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
f036a4da85
commit 96e6e8f4a68d ("vfs: add missing checks to copy_file_range")
adds checks for immutablefile and swapfile instead of commit a31713517d
("vfs: introduce generic_file_rw_checks()").
Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
62 lines
1.5 KiB
Bash
Executable File
62 lines
1.5 KiB
Bash
Executable File
#! /bin/bash
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
# Copyright (c) 2018 Red Hat, Inc. All Rights Reserved.
|
|
#
|
|
# FS QA Test No. 553
|
|
#
|
|
# Check that we cannot copy_file_range() to an immutable file
|
|
#
|
|
# This is a regression test for kernel commit:
|
|
# 96e6e8f4a68d ("vfs: add missing checks to copy_file_range")
|
|
#
|
|
seq=`basename $0`
|
|
seqres=$RESULT_DIR/$seq
|
|
echo "QA output created by $seq"
|
|
|
|
here=`pwd`
|
|
tmp=/tmp/$$
|
|
status=1 # failure is the default!
|
|
trap "_cleanup; exit \$status" 0 1 2 3 7 15
|
|
|
|
workdir="$TEST_DIR/test-$seq"
|
|
_cleanup()
|
|
{
|
|
$XFS_IO_PROG -f -r -c "chattr -i" $workdir/immutable >/dev/null 2>&1
|
|
cd /
|
|
rm -f $tmp.*
|
|
}
|
|
|
|
# get standard environment, filters and checks
|
|
. ./common/rc
|
|
. ./common/filter
|
|
|
|
# real QA test starts here
|
|
_supported_os Linux
|
|
_supported_fs generic
|
|
|
|
rm -f $seqres.full
|
|
|
|
_require_test
|
|
_require_xfs_io_command "copy_range"
|
|
_require_xfs_io_command "chattr" "i"
|
|
|
|
rm -rf $workdir
|
|
mkdir $workdir
|
|
|
|
rm -f $seqres.full
|
|
|
|
$XFS_IO_PROG -f -c "pwrite -S 0x61 0 128k" $workdir/file >> $seqres.full 2>&1
|
|
|
|
# we have to open the file to be immutable rw and hold it open over the
|
|
# chattr command to set it immutable, otherwise we won't be able to open it for
|
|
# writing after it's been made immutable. (i.e. would exercise file mode checks,
|
|
# not immutable inode flag checks).
|
|
echo immutable file returns EPERM
|
|
$XFS_IO_PROG -f -c "pwrite -S 0x61 0 64k" -c fsync $workdir/immutable | _filter_xfs_io
|
|
$XFS_IO_PROG -f -c "chattr +i" -c "copy_range -l 32k $workdir/file" $workdir/immutable
|
|
$XFS_IO_PROG -f -r -c "chattr -i" $workdir/immutable
|
|
|
|
# success, all done
|
|
status=0
|
|
exit
|