overlay/029: fix test failure with nfs_export feature enabled
[xfstests-dev.git] / tests / overlay / 022
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat Inc. All Rights Reserved.
4 #
5 # FS QA Test 022
6 #
7 # Regression test for kernel commit:
8 #     76bc8e2 ovl: disallow overlayfs as upperdir
9 #
10 # This reproducer was originally written by
11 #     Miklos Szeredi <mszeredi@redhat.com>
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         $UMOUNT_PROG $tmp/mnt > /dev/null 2>&1
26         rm -rf $tmp
27         rm -f $tmp.*
28 }
29
30 # get standard environment, filters and checks
31 . ./common/rc
32 . ./common/filter
33
34 # remove previous $seqres.full before test
35 rm -f $seqres.full
36
37 # real QA test starts here
38
39 # Modify as appropriate.
40 _supported_fs overlay
41 _supported_os Linux
42 _require_scratch
43
44 # Remove all files from previous tests
45 _scratch_mkfs
46
47 upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
48 mkdir -p $upperdir/upper
49 mkdir -p $upperdir/work
50 # mount overlay with dirs in upper
51 _scratch_mount
52
53 mkdir -p $tmp/{lower,mnt}
54 # mount overlay using upper from another overlay upper
55 # should fail
56 _overlay_mount_dirs $tmp/lower $SCRATCH_MNT/upper \
57   $SCRATCH_MNT/work overlay $tmp/mnt > /dev/null 2>&1
58 if [ $? -ne 0 ] ; then
59         echo "Silence is golden"
60 else
61         echo "Test Fail"
62         echo "Overlay upperdir can't be another overlay upperdir"
63 fi
64
65 # success, all done
66 status=0
67 exit