generic/611: Use _getfattr instead of GETFATTR_PROG
[xfstests-dev.git] / tests / generic / 115
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 115
6 #
7 # Moving and deleting cloned ("reflinked") files on btrfs:
8 #   - Create a file and a reflink
9 #   - Move both to a directory
10 #   - Delete the original (moved) file, check that the copy still exists.
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 15
20
21 _cleanup()
22 {
23     cd /
24     rm -f $tmp.* $testdir
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30 . ./common/reflink
31
32 # real QA test starts here
33 _require_test_reflink
34
35 _require_xfs_io_command "fiemap"
36 _require_cp_reflink
37 _require_test
38
39 rm -f $seqres.full
40
41 testdir1=$TEST_DIR/test-$seq
42 rm -rf $testdir1
43 mkdir $testdir1
44
45 echo "Create the original files and reflink dirs"
46 $XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $testdir1/original \
47     >> $seqres.full
48 cp --reflink $testdir1/original $testdir1/copy
49
50 _verify_reflink $testdir1/original $testdir1/copy
51
52 echo "Move orig & reflink copy to subdir and md5sum:"
53 mkdir $testdir1/subdir
54 mv $testdir1/original $testdir1/subdir/original_moved
55 mv $testdir1/copy $testdir1/subdir/copy_moved
56 _verify_reflink $testdir1/subdir/original_moved \
57     $testdir1/subdir/copy_moved
58
59 md5sum $testdir1/subdir/original_moved | _filter_test_dir
60 md5sum $testdir1/subdir/copy_moved | _filter_test_dir
61
62 echo "remove orig from subdir and md5sum reflink copy:"
63 rm $testdir1/subdir/original_moved
64 md5sum $testdir1/subdir/copy_moved | _filter_test_dir
65 rm -rf $testdir1/subdir
66
67 # success, all done
68 status=0
69 exit