67fad9fd6e306fd11a51b33312c4e93ca5bb73ba
[xfstests-dev.git] / tests / overlay / 014
1 #! /bin/bash
2 # FS QA Test 014
3 #
4 # Test copy-up of lowerdir with opaque xattr set.
5 #
6 # When copying up a directory with opaque xattr set, the xattr was copied up as
7 # well, after a remount the opaque flag is honored so the copied-up directory
8 # is treated as opaque, which causes files created in the lowerdir to be hidden
9 # when using multiple lower directories.
10 #
11 # This is fixed by "ovl: don't copy up opaqueness".
12 #
13 #-----------------------------------------------------------------------
14 # Copyright (c) 2016 Red Hat Inc. All Rights Reserved.
15 #
16 # This program is free software; you can redistribute it and/or
17 # modify it under the terms of the GNU General Public License as
18 # published by the Free Software Foundation.
19 #
20 # This program is distributed in the hope that it would be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 # GNU General Public License for more details.
24 #
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write the Free Software Foundation,
27 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
28 #-----------------------------------------------------------------------
29 #
30
31 seq=`basename $0`
32 seqres=$RESULT_DIR/$seq
33 echo "QA output created by $seq"
34
35 here=`pwd`
36 tmp=/tmp/$$
37 status=1        # failure is the default!
38 trap "_cleanup; exit \$status" 0 1 2 3 15
39
40 _cleanup()
41 {
42         cd /
43         rm -f $tmp.*
44 }
45
46 # get standard environment, filters and checks
47 . ./common/rc
48 . ./common/filter
49
50 # remove previous $seqres.full before test
51 rm -f $seqres.full
52
53 # real QA test starts here
54 _supported_fs overlay
55 _supported_os Linux
56 # Use non-default scratch underlying overlay dirs, we need to check
57 # them explicity after test.
58 _require_scratch_nocheck
59
60 # Remove all files from previous tests
61 _scratch_mkfs
62
63 # Create multiple lowerdirs and upperdir, workdir, and testdir on lowerdir
64 lowerdir1=$OVL_BASE_SCRATCH_MNT/lower1
65 lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2
66 upperdir=$OVL_BASE_SCRATCH_MNT/upper
67 workdir=$OVL_BASE_SCRATCH_MNT/workdir
68 # When overlay inode index feature is enabled, a workdir cannot be reused
69 # with a different upperdir. workdir2 in this test is used as the workdir
70 # when lowerdir2 is used as the upperdir.
71 workdir2=$OVL_BASE_SCRATCH_MNT/workdir2
72 mkdir -p $lowerdir1 $lowerdir2 $upperdir $workdir $workdir2
73 mkdir -p $lowerdir1/testdir/d
74
75 # mount overlay with $lowerdir2 as upperdir, and remove & recreate testdir,
76 # make testdir on $lowerdir2 opaque
77 _overlay_scratch_mount_dirs $lowerdir1 $lowerdir2 $workdir2
78 rm -rf $SCRATCH_MNT/testdir
79 mkdir -p $SCRATCH_MNT/testdir/visibledir
80 # unmount overlayfs but not base fs
81 $UMOUNT_PROG $SCRATCH_MNT
82
83 # check overlayfs
84 _overlay_check_scratch_dirs $lowerdir1 $lowerdir2 $workdir2
85
86 # mount overlay again, with lowerdir1 and lowerdir2 as multiple lowerdirs,
87 # and create a new file in testdir, triggers copyup from lowerdir,
88 # copyup should not copy overlayfs private xattr
89 _overlay_scratch_mount_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir
90 touch $SCRATCH_MNT/testdir/visiblefile
91
92 # umount and mount overlay again, buggy kernel treats the copied-up dir as
93 # opaque, visibledir is not seen in merged dir.
94 $UMOUNT_PROG $SCRATCH_MNT
95 _overlay_scratch_mount_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir
96 ls $SCRATCH_MNT/testdir
97
98 # check overlayfs
99 _overlay_check_scratch_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir
100
101 # success, all done
102 status=0
103 exit