overlay/029: fix test failure with nfs_export feature enabled
[xfstests-dev.git] / tests / overlay / 008
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 008
6 #
7 # Create file/dir over whiteout by another user, uid/gid of the file/dir should
8 # be current fsuid/fsgid, not the mounter's.
9 #
10 # This upstream kernel patch fixed the issue
11 # d0e13f5 ovl: fix uid/gid when creating over whiteout
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=1        # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24         cd /
25         rm -f $tmp.*
26 }
27
28 # get standard environment, filters and checks
29 . ./common/rc
30 . ./common/filter
31
32 rm -f $seqres.full
33
34 # real QA test starts here
35 _supported_fs overlay
36 _supported_os Linux
37 _require_scratch
38 _require_user
39
40 # Remove all files from previous tests
41 _scratch_mkfs
42
43 # Create test file on lower dir, and chown to fsgqa user
44 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
45 mkdir -p $lowerdir
46 touch $lowerdir/testfile
47 chown fsgqa:fsgqa $lowerdir/testfile
48
49 # chown upperdir to fsgqa user, so new file/dir can be created by the user
50 upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
51 mkdir -p $upperdir
52 chown fsgqa:fsgqa $upperdir
53
54 _scratch_mount
55
56 # Remove testfile, whiteout created in lowerdir
57 rm -f $SCRATCH_MNT/testfile
58
59 # Create new file over whiteout and check the file ownership
60 _user_do "touch $SCRATCH_MNT/testfile"
61 stat -c %U:%G-%F $SCRATCH_MNT/testfile
62
63 # Create new dir over whiteout and check ownership again
64 rm -f $SCRATCH_MNT/testfile
65 _user_do "mkdir $SCRATCH_MNT/testfile"
66 stat -c %U:%G-%F $SCRATCH_MNT/testfile
67
68 # success, all done
69 status=0
70 exit