overlay/075: fix wrong invocation of t_immutable
[xfstests-dev.git] / tests / overlay / 037
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2017 CTERA Networks. All Rights Reserved.
4 #
5 # FS QA Test 037
6 #
7 # Test mount error cases with option index=on
8 #
9 # - Upper/lower mismatch
10 # - Index/upper mismatch
11 #
12 # With index=on, lowerdir and upperdir are verified using a file handle
13 # stored in trusted.overlay.origin xattr in upperdir and indexdir.
14 #
15 # Failure to verify lowerdir/upperdir on mount results in ESTALE.
16 #
17 seq=`basename $0`
18 seqres=$RESULT_DIR/$seq
19 echo "QA output created by $seq"
20
21 here=`pwd`
22 tmp=/tmp/$$
23 status=1        # failure is the default!
24 trap "_cleanup; exit \$status" 0 1 2 3 15
25
26 _cleanup()
27 {
28         cd /
29         rm -f $tmp.*
30 }
31
32 # get standard environment, filters and checks
33 . ./common/rc
34 . ./common/filter
35
36 # remove previous $seqres.full before test
37 rm -f $seqres.full
38
39 # real QA test starts here
40 _supported_fs overlay
41 # Use non-default scratch underlying overlay dirs, we need to check
42 # them explicity after test.
43 _require_scratch_nocheck
44 _require_scratch_feature index
45
46 # Remove all files from previous tests
47 _scratch_mkfs
48
49 # Create multiple lowerdirs, upperdirs and workdir
50 lowerdir=$OVL_BASE_SCRATCH_MNT/lower
51 lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2
52 upperdir=$OVL_BASE_SCRATCH_MNT/upper
53 upperdir2=$OVL_BASE_SCRATCH_MNT/upper2
54 workdir=$OVL_BASE_SCRATCH_MNT/workdir
55 mkdir -p $lowerdir $lowerdir2 $upperdir $upperdir2 $workdir
56
57 # Mount overlay with lowerdir, upperdir, workdir and index=on
58 # to store the file handles of lowerdir and upperdir in overlay.origin xattr
59 _overlay_scratch_mount_dirs $lowerdir $upperdir $workdir -oindex=on
60 $UMOUNT_PROG $SCRATCH_MNT
61
62 # Try to mount an overlay with the same upperdir and different lowerdir - expect ESTALE
63 _overlay_scratch_mount_dirs $lowerdir2 $upperdir $workdir -oindex=on \
64         2>&1 | _filter_error_mount
65 $UMOUNT_PROG $SCRATCH_MNT 2>/dev/null
66
67 # Try to mount an overlay with the same workdir and different upperdir - expect ESTALE
68 _overlay_scratch_mount_dirs $lowerdir $upperdir2 $workdir -oindex=on \
69         2>&1 | _filter_error_mount
70 $UMOUNT_PROG $SCRATCH_MNT 2>/dev/null
71
72 # Mount overlay with original lowerdir, upperdir, workdir and index=on - expect success
73 _overlay_scratch_mount_dirs $lowerdir $upperdir $workdir -oindex=on
74
75 # check overlayfs
76 _overlay_check_scratch_dirs $lowerdir $upperdir $workdir -oindex=on
77
78 # success, all done
79 status=0
80 exit