overlay: run unionmount testsuite test cases
[xfstests-dev.git] / tests / overlay / 064
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2019 Red Hat Inc.  All Rights Reserved.
4 #
5 # FS QA Test 064
6 #
7 # Make sure CAP_SETUID is not cleared over file copy up.
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 -f $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27
28 # remove previous $seqres.full before test
29 rm -f $seqres.full
30
31 # real QA test starts here
32 _supported_fs overlay
33 _supported_os Linux
34 _require_scratch
35 _require_command "$SETCAP_PROG" setcap
36 _require_command "$GETCAP_PROG" getcap
37 _require_scratch_overlay_features metacopy
38
39 # Remove all files from previous tests
40 _scratch_mkfs
41
42 # Create test file
43 lowerdir=${OVL_BASE_SCRATCH_MNT}/${OVL_LOWER}
44 echo "This is lower1" >> ${lowerdir}/file1
45 echo "This is lower2" >> ${lowerdir}/file2
46
47 # set setuid bit
48 $SETCAP_PROG cap_setuid+ep ${lowerdir}/file1
49 $SETCAP_PROG cap_setuid+ep ${lowerdir}/file2
50
51 _scratch_mount "-o metacopy=on"
52
53 # Trigger file copy up without actually writing anything to file. This
54 # requires opening file with WRITE and xfs_io opens file with
55 # O_RDWR by default.
56 $XFS_IO_PROG -c "stat" ${SCRATCH_MNT}/file1 >>$seqres.full
57
58 # Make sure cap_setuid is still there
59 $GETCAP_PROG ${SCRATCH_MNT}/file1 | _filter_scratch
60
61 # Trigger metadata only copy-up
62 chmod 000 ${SCRATCH_MNT}/file2
63
64 # Trigger data copy-up
65 $XFS_IO_PROG -c "stat" ${SCRATCH_MNT}/file2 >>$seqres.full
66
67 # Make sure cap_setuid is still there
68 $GETCAP_PROG ${SCRATCH_MNT}/file2 | _filter_scratch
69
70 # success, all done
71 status=0
72 exit