b81cff8e98253d68ac7368533fdcbaad1885e79b
[xfstests-dev.git] / tests / overlay / 008
1 #! /bin/bash
2 # FS QA Test 008
3 #
4 # Create file/dir over whiteout by another user, uid/gid of the file/dir should
5 # be current fsuid/fsgid, not the mounter's.
6 #
7 # This upstream kernel patch fixed the issue
8 # d0e13f5 ovl: fix uid/gid when creating over whiteout
9 #
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2016 Red Hat Inc.  All Rights Reserved.
12 #
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
16 #
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25 #-----------------------------------------------------------------------
26 #
27
28 seq=`basename $0`
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
31
32 here=`pwd`
33 tmp=/tmp/$$
34 status=1        # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
36
37 _cleanup()
38 {
39         cd /
40         rm -f $tmp.*
41 }
42
43 # get standard environment, filters and checks
44 . ./common/rc
45 . ./common/filter
46
47 rm -f $seqres.full
48
49 # real QA test starts here
50 _supported_fs overlay
51 _supported_os Linux
52 _require_scratch
53 _require_user
54
55 # Remove all files from previous tests
56 _scratch_mkfs
57
58 # Create test file on lower dir, and chown to fsgqa user
59 lowerdir=$SCRATCH_DEV/$OVL_LOWER
60 mkdir -p $lowerdir
61 touch $lowerdir/testfile
62 chown fsgqa:fsgqa $lowerdir/testfile
63
64 # chown upperdir to fsgqa user, so new file/dir can be created by the user
65 upperdir=$SCRATCH_DEV/$OVL_UPPER
66 mkdir -p $upperdir
67 chown fsgqa:fsgqa $upperdir
68
69 _scratch_mount
70
71 # Remove testfile, whiteout created in lowerdir
72 rm -f $SCRATCH_MNT/testfile
73
74 # Create new file over whiteout and check the file ownership
75 _user_do "touch $SCRATCH_MNT/testfile"
76 stat -c %U:%G-%F $SCRATCH_MNT/testfile
77
78 # Create new dir over whiteout and check ownership again
79 rm -f $SCRATCH_MNT/testfile
80 _user_do "mkdir $SCRATCH_MNT/testfile"
81 stat -c %U:%G-%F $SCRATCH_MNT/testfile
82
83 # success, all done
84 status=0
85 exit