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