c19842859b9e0dfbe51c074384ad6eae0a2c039d
[xfstests-dev.git] / tests / generic / 554
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. 554
6 #
7 # Check that we cannot copy_file_range() to a swapfile
8 #
9 # This is a regression test for kernel commit:
10 #   96e6e8f4a68d ("vfs: add missing checks to copy_file_range")
11 #
12 . ./common/preamble
13 _begin_fstest auto quick copy_range swap
14
15 _register_cleanup "_cleanup" BUS
16
17 # Import common functions.
18 . ./common/filter
19
20 # real QA test starts here
21 _supported_fs generic
22
23 _require_scratch
24 _require_xfs_io_command "copy_range"
25 _require_scratch_swapfile
26
27 _scratch_mkfs >>$seqres.full 2>&1
28 _scratch_mount
29
30 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 128k" $SCRATCH_MNT/file >> $seqres.full 2>&1
31
32 echo swap files return ETXTBUSY
33 _format_swapfile $SCRATCH_MNT/swapfile 16m
34 _swapon_file $SCRATCH_MNT/swapfile
35
36 $XFS_IO_PROG -f -c "copy_range -l 32k $SCRATCH_MNT/file" $SCRATCH_MNT/swapfile
37 swapoff $SCRATCH_MNT/swapfile
38
39 # success, all done
40 status=0
41 exit