generic: Verify the inheritance behavior of FS_XFLAG_DAX flag in various combinations
[xfstests-dev.git] / tests / generic / 159
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 159
6 #
7 # Check that we can't reflink immutable files
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1    # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20     cd /
21     rm -rf $tmp.* $testdir1
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27 . ./common/attr
28 . ./common/reflink
29
30 # real QA test starts here
31 _supported_os Linux
32 _require_chattr i
33 _require_test_reflink
34
35 rm -f $seqres.full
36
37 echo "Format and mount"
38 testdir1="$TEST_DIR/test-$seq"
39 rm -rf $testdir1
40 mkdir $testdir1
41
42 echo "Create the original files"
43 blksz="$(_get_block_size $testdir1)"
44 blks=1000
45 margin='7%'
46 sz=$((blksz * blks))
47 free_blocks0=$(stat -f $testdir1 -c '%f')
48 nr=4
49 filesize=$((blksz * nr))
50 _pwrite_byte 0x61 0 $sz $testdir1/file1 >> $seqres.full
51 _pwrite_byte 0x61 0 $sz $testdir1/file2 >> $seqres.full
52 sync
53
54 do_filter_output()
55 {
56         _filter_test_dir | sed -e 's/Operation not permitted/Permission denied/g'
57 }
58
59 echo "Try reflink on immutable files"
60 $CHATTR_PROG +i $testdir1/file1 $testdir1/file2
61 _reflink_range $testdir1/file1 0 $testdir1/file2 0 $blksz 2>&1 | do_filter_output
62 $CHATTR_PROG -i $testdir1/file1 $testdir1/file2
63
64 # success, all done
65 status=0
66 exit