15b4aded616a6afe65636428ede3a1e5299e1154
[xfstests-dev.git] / tests / generic / 513
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 513
6 #
7 # Ensure that ctime is updated and capabilities are cleared when reflinking.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12 tmp=/tmp/$$
13 status=1        # failure is the default!
14 trap "_cleanup; exit \$status" 0 1 2 3 15
15
16 _cleanup()
17 {
18         cd /
19         rm -f $tmp.*
20 }
21
22 # get standard environment, filters and checks
23 . ./common/rc
24 . ./common/filter
25 . ./common/reflink
26
27 # real QA test starts here
28 _supported_fs generic
29 _require_scratch_reflink
30 _require_command "$GETCAP_PROG" getcap
31 _require_command "$SETCAP_PROG" setcap
32
33 rm -f $seqres.full
34
35 _scratch_mkfs >>$seqres.full 2>&1
36 _scratch_mount
37
38 $XFS_IO_PROG -f -c "pwrite -S 0x18 0 1m" $SCRATCH_MNT/foo >>$seqres.full
39 $XFS_IO_PROG -f -c "pwrite -S 0x20 0 1m" $SCRATCH_MNT/bar >>$seqres.full
40
41 $SETCAP_PROG cap_setgid,cap_setuid+ep $SCRATCH_MNT/bar
42
43 before_cap="$($GETCAP_PROG -v $SCRATCH_MNT/bar)"
44 before_ctime="$(stat -c '%z' $SCRATCH_MNT/bar)"
45
46 sleep 1
47
48 $XFS_IO_PROG -c "reflink $SCRATCH_MNT/foo" $SCRATCH_MNT/bar >> $seqres.full 2>&1
49
50 after_cap="$($GETCAP_PROG -v $SCRATCH_MNT/bar)"
51 after_ctime="$(stat -c '%z' $SCRATCH_MNT/bar)"
52
53 echo "$before_cap $before_ctime" >> $seqres.full
54 echo "$after_cap $after_ctime" >> $seqres.full
55
56 test "$before_cap" != "$after_cap" || echo "Expected capabilities to drop."
57 test "$before_ctime" != "$after_ctime" || echo "Expected ctime to change."
58
59 echo Silence is golden.
60 status=0
61 exit