common: kill _supported_os
[xfstests-dev.git] / tests / overlay / 004
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat Inc. All Rights Reserved.
4 #
5 # FS QA Test 004
6 #
7 # Test file copy up on overlayfs by changing mode bits.
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 # Modify as appropriate.
32 _supported_fs overlay
33 _require_scratch
34 _require_user
35
36 # Remove all files from previous tests
37 _scratch_mkfs
38
39 # Create test file in lower dir
40 lowerdir=${OVL_BASE_SCRATCH_MNT}/${OVL_LOWER}
41 upperdir=${OVL_BASE_SCRATCH_MNT}/${OVL_UPPER}
42 mkdir -p $lowerdir
43 touch ${lowerdir}/attr_file1
44 chmod 000 ${lowerdir}/attr_file1
45 touch ${lowerdir}/attr_file2
46 chmod 000 ${lowerdir}/attr_file2
47
48 _scratch_mount
49
50 # copy up by change mode bits and check.
51 chmod a+x ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
52 chmod o-w ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
53 chmod g+w ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
54 chmod u-r ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
55 chmod a+X ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
56 chmod o-s ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
57 chmod g+t ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
58 chmod u-X ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
59 stat -c %a ${SCRATCH_MNT}/attr_file1
60
61 # unprivileged user can't do this.
62 _user_do "chmod a+x ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
63 _user_do "chmod o-w ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
64 _user_do "chmod g+w ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
65 _user_do "chmod u-r ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
66 _user_do "chmod a+X ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
67 _user_do "chmod o-s ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
68 _user_do "chmod g+t ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
69 _user_do "chmod u-X ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
70 stat -c %a ${SCRATCH_MNT}/attr_file2
71
72 # unmount overlayfs but not base fs
73 $UMOUNT_PROG $SCRATCH_MNT
74
75 # check mode bits of the file that has been copied up, and
76 # the file that should not have been copied up.
77 stat -c %a ${upperdir}/attr_file1
78 ls ${upperdir}/
79
80 # success, all done
81 status=0
82 exit