overlay: use OVL_BASE_SCRATCH_MNT instead of SCRATCH_DEV
[xfstests-dev.git] / tests / overlay / 015
1 #! /bin/bash
2 # FS QA Test 015
3 #
4 # SGID bit inheritance over whiteout.
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2016 Red Hat Inc.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #-----------------------------------------------------------------------
22 #
23
24 seq=`basename $0`
25 seqres=$RESULT_DIR/$seq
26 echo "QA output created by $seq"
27
28 here=`pwd`
29 tmp=/tmp/$$
30 status=1        # failure is the default!
31 trap "_cleanup; exit \$status" 0 1 2 3 15
32
33 _cleanup()
34 {
35         cd /
36         rm -f $tmp.*
37 }
38
39 # get standard environment, filters and checks
40 . ./common/rc
41 . ./common/filter
42
43 # remove previous $seqres.full before test
44 rm -f $seqres.full
45
46 # real QA test starts here
47 _supported_fs overlay
48 _supported_os Linux
49 _require_scratch
50 _require_user
51 _require_group
52
53 # Remove all files from previous tests
54 _scratch_mkfs
55
56 # set umask to make output deterministic
57 umask 022
58
59 # Create test dir in lower dir and set sgid bit
60 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
61 mkdir -p $lowerdir/dir
62 chown $qa_user:$qa_group $lowerdir/dir
63 chmod 2775 $lowerdir/dir
64 touch $lowerdir/dir/testdir
65 touch $lowerdir/dir/testfile
66 touch $lowerdir/dir/hardlink
67
68 # mount overlayfs, create new file and dir in parent dir with sgid bit set, new
69 # files and dirs all should inherit the sgid bit and the group
70 _scratch_mount
71
72 # new dir
73 mkdir $SCRATCH_MNT/dir/newdir
74 stat -c "%A %G" $SCRATCH_MNT/dir/newdir
75
76 # new file
77 touch $SCRATCH_MNT/dir/newfile
78 stat -c "%A %G" $SCRATCH_MNT/dir/newfile
79
80 # new dir over whiteout
81 rm -f $SCRATCH_MNT/dir/testdir
82 mkdir $SCRATCH_MNT/dir/testdir
83 stat -c "%A %G" $SCRATCH_MNT/dir/testdir
84
85 # new file over whiteout
86 rm -f $SCRATCH_MNT/dir/testfile
87 touch $SCRATCH_MNT/dir/testfile
88 stat -c "%A %G" $SCRATCH_MNT/dir/testfile
89
90 # new hardlink over whiteout
91 rm -f $SCRATCH_MNT/dir/hardlink
92 ln $SCRATCH_MNT/dir/testfile $SCRATCH_MNT/dir/hardlink
93 stat -c "%A %G" $SCRATCH_MNT/dir/hardlink
94
95 # success, all done
96 status=0
97 exit