817ee639cd8782066f3e9072e0ccf3f077ffdea6
[xfstests-dev.git] / tests / overlay / 022
1 #! /bin/bash
2 # FS QA Test 022
3 #
4 # Regression test for kernel commit:
5 #     76bc8e2 ovl: disallow overlayfs as upperdir
6 #
7 # This reproducer was originally written by
8 #     Miklos Szeredi <mszeredi@redhat.com>
9 #
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2017 Red Hat Inc. All Rights Reserved.
12 #
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
16 #
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25 #-----------------------------------------------------------------------
26 #
27
28 seq=`basename $0`
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
31
32 here=`pwd`
33 tmp=/tmp/$$
34 status=1        # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
36
37 _cleanup()
38 {
39         cd /
40         $UMOUNT_PROG $tmp/mnt > /dev/null 2>&1
41         rm -rf $tmp
42         rm -f $tmp.*
43 }
44
45 # get standard environment, filters and checks
46 . ./common/rc
47 . ./common/filter
48
49 # remove previous $seqres.full before test
50 rm -f $seqres.full
51
52 # real QA test starts here
53
54 # Modify as appropriate.
55 _supported_fs overlay
56 _supported_os Linux
57 _require_scratch
58
59 # Remove all files from previous tests
60 _scratch_mkfs
61
62 upperdir=$SCRATCH_DEV/$OVERLAY_UPPER_DIR
63 mkdir -p $upperdir/upper
64 mkdir -p $upperdir/work
65 # mount overlay with dirs in upper
66 _scratch_mount
67
68 mkdir -p $tmp/{lower,mnt}
69 # mount overlay using upper from another overlay upper
70 # should fail
71 _overlay_mount_dirs $tmp/lower $SCRATCH_MNT/upper \
72   $SCRATCH_MNT/work overlay $tmp/mnt > /dev/null 2>&1
73 if [ $? -ne 0 ] ; then
74         echo "Silence is golden"
75 else
76         echo "Test Fail"
77         echo "Overlay upperdir can't be another overlay upperdir"
78 fi
79
80 # success, all done
81 status=0
82 exit