overlay/075: fix wrong invocation of t_immutable
[xfstests-dev.git] / tests / overlay / 057
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2018 Red Hat, Inc. All Rights Reserved.
4 #
5 # FS QA Test No. 057
6 #
7 # Test absolute redirect is followed even if ancestor is opaque
8 #
9 # Typically, when following absolute redirect, if an opauqe dentry is
10 # found, lookup in further lower directories is stopped. But if a
11 # child dentry has another absolute redirect, then lookup in further
12 # lower layers should continue.
13 #
14 # Say, following is example setup.
15 # upper:  /redirect (redirect=/a/b/c)
16 # lower1: /a/[b]/c       ([b] is opaque) (c has absolute redirect=/a/b/d/)
17 # lower0: /a/b/d/foo
18 #
19 # "redirect" directory in upper should merge with lower1:/a/b/c/ and
20 # lower0:/a/b/d/, despite lower1:/a/b/ being opaque.
21 #
22 seq=`basename $0`
23 seqres=$RESULT_DIR/$seq
24 echo "QA output created by $seq"
25
26 here=`pwd`
27 tmp=/tmp/$$
28 status=1        # failure is the default!
29 trap "_cleanup; exit \$status" 0 1 2 3 15
30
31 _cleanup()
32 {
33         cd /
34         rm -f $tmp.*
35 }
36
37 # get standard environment, filters and checks
38 . ./common/rc
39 . ./common/filter
40
41 # remove previous $seqres.full before test
42 rm -f $seqres.full
43
44 # real QA test starts here
45 _supported_fs overlay
46 # We use non-default scratch underlying overlay dirs, we need to check
47 # them explicity after test.
48 _require_scratch_nocheck
49 _require_scratch_overlay_features redirect_dir
50
51 # remove all files from previous tests
52 _scratch_mkfs
53
54 # Create test directories
55 lowerdir=$OVL_BASE_SCRATCH_MNT/lower
56 lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2
57 upperdir=$OVL_BASE_SCRATCH_MNT/upper
58 workdir=$OVL_BASE_SCRATCH_MNT/workdir
59 workdir2=$OVL_BASE_SCRATCH_MNT/workdir2
60
61 mkdir -p $lowerdir $lowerdir2 $upperdir $workdir $workdir2
62 mkdir -p $lowerdir/origin
63 touch $lowerdir/origin/foo
64 _overlay_scratch_mount_dirs $lowerdir $lowerdir2 $workdir2 -o redirect_dir=on
65
66 # Create opaque parent with absolute redirect child in middle layer
67 mkdir $SCRATCH_MNT/pure
68 mv $SCRATCH_MNT/origin $SCRATCH_MNT/pure/redirect
69 $UMOUNT_PROG $SCRATCH_MNT
70 _overlay_scratch_mount_dirs $lowerdir2:$lowerdir $upperdir $workdir -o redirect_dir=on
71 mv $SCRATCH_MNT/pure/redirect $SCRATCH_MNT/redirect
72 # List content of renamed merge dir before mount cycle
73 ls $SCRATCH_MNT/redirect/
74
75 # Verify that redirects are followed by listing content of renamed merge dir
76 # after mount cycle
77 $UMOUNT_PROG $SCRATCH_MNT
78 _overlay_scratch_mount_dirs $lowerdir2:$lowerdir $upperdir $workdir -o redirect_dir=on
79 ls $SCRATCH_MNT/redirect/
80
81 # check overlayfs
82 _overlay_check_scratch_dirs "$lowerdir2:$lowerdir" $upperdir $workdir -o redirect_dir=on
83
84 # success, all done
85 status=0
86 exit