2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
7 # Check that various invalid reflink scenarios are rejected.
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 15
21 rm -rf $tmp.* $testdir1
24 # get standard environment, filters and checks
30 # real QA test starts here
32 _require_scratch_reflink
37 echo "Format and mount"
38 _scratch_mkfs > $seqres.full 2>&1
39 _scratch_mount >> $seqres.full 2>&1
41 testdir1="$TEST_DIR/test-$seq"
45 testdir2=$SCRATCH_MNT/test-$seq
48 echo "Create the original files"
49 blksz="$(_get_file_block_size $testdir1)"
53 free_blocks0=$(stat -f $testdir1 -c '%f')
55 filesize=$((blksz * nr))
56 _pwrite_byte 0x61 0 $sz $testdir1/file1 >> $seqres.full
57 _pwrite_byte 0x61 0 $sz $testdir1/file2 >> $seqres.full
58 _pwrite_byte 0x61 0 $sz $testdir2/file1 >> $seqres.full
59 _pwrite_byte 0x61 0 $sz $testdir2/file2 >> $seqres.full
61 seq 1 $((2 * blksz / 250)) | while read f; do
62 touch $testdir1/dir1/$f
64 mknod $testdir1/dev1 c 1 3
65 mkfifo $testdir1/fifo1
69 sed -e 's/Inappropriate ioctl for device/Invalid argument/g'
73 sed -e 's/Invalid argument/Bad file descriptor/g'
76 echo "Try cross-device reflink"
77 _reflink_range $testdir1/file1 0 $testdir2/file1 0 $blksz
79 echo "Try unaligned reflink"
80 _reflink_range $testdir1/file1 37 $testdir1/file1 59 23
82 echo "Try overlapping reflink"
83 _reflink_range $testdir1/file1 0 $testdir1/file1 1 $((blksz * 2))
85 echo "Try reflink past EOF"
86 _reflink_range $testdir1/file1 $(( (blks + 10) * blksz)) $testdir1/file1 0 $blksz
88 echo "Try to reflink a dir"
89 _reflink_range $testdir1/dir1 0 $testdir1/file2 0 $blksz
91 echo "Try to reflink a device"
92 _reflink_range $testdir1/dev1 0 $testdir1/file2 0 $blksz
94 echo "Try to reflink to a dir"
95 _reflink_range $testdir1/file1 0 $testdir1/dir1 0 $blksz 2>&1 | _filter_test_dir
97 echo "Try to reflink to a device"
98 _reflink_range $testdir1/file1 0 $testdir1/dev1 0 $blksz 2>&1 | _filter_enotty
100 echo "Try to reflink to a fifo"
101 _reflink_range $testdir1/file1 0 $testdir1/fifo1 0 $blksz -n 2>&1 | _filter_enotty
103 echo "Try to reflink an append-only file"
104 _reflink_range $testdir1/file1 0 $testdir1/file3 0 $blksz -a 2>&1 | _filter_einval
106 echo "Reflink two files"
107 _reflink_range $testdir1/file1 0 $testdir1/file2 0 $blksz >> $seqres.full
108 _reflink_range $testdir2/file1 0 $testdir2/file2 0 $blksz >> $seqres.full