common/xfs: refactor commands to select a particular xfs backing device
[xfstests-dev.git] / tests / overlay / 015
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 015
6 #
7 # SGID bit inheritance over whiteout.
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 _require_scratch
34 _require_user
35 _require_group
36
37 # Remove all files from previous tests
38 _scratch_mkfs
39
40 # set umask to make output deterministic
41 umask 022
42
43 # Create test dir in lower dir and set sgid bit
44 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
45 mkdir -p $lowerdir/dir
46 chown $qa_user:$qa_group $lowerdir/dir
47 chmod 2775 $lowerdir/dir
48 touch $lowerdir/dir/testdir
49 touch $lowerdir/dir/testfile
50 touch $lowerdir/dir/hardlink
51
52 # mount overlayfs, create new file and dir in parent dir with sgid bit set, new
53 # files and dirs all should inherit the sgid bit and the group
54 _scratch_mount
55
56 # new dir
57 mkdir $SCRATCH_MNT/dir/newdir
58 stat -c "%A %G" $SCRATCH_MNT/dir/newdir
59
60 # new file
61 touch $SCRATCH_MNT/dir/newfile
62 stat -c "%A %G" $SCRATCH_MNT/dir/newfile
63
64 # new dir over whiteout
65 rm -f $SCRATCH_MNT/dir/testdir
66 mkdir $SCRATCH_MNT/dir/testdir
67 stat -c "%A %G" $SCRATCH_MNT/dir/testdir
68
69 # new file over whiteout
70 rm -f $SCRATCH_MNT/dir/testfile
71 touch $SCRATCH_MNT/dir/testfile
72 stat -c "%A %G" $SCRATCH_MNT/dir/testfile
73
74 # new hardlink over whiteout
75 rm -f $SCRATCH_MNT/dir/hardlink
76 ln $SCRATCH_MNT/dir/testfile $SCRATCH_MNT/dir/hardlink
77 stat -c "%A %G" $SCRATCH_MNT/dir/hardlink
78
79 # success, all done
80 status=0
81 exit