a302d749ebccf103d47b5dbb88592391083a5a76
[xfstests-dev.git] / tests / overlay / 010
1 #! /bin/bash
2 # FS QA Test 010
3 #
4 # Remove dir which contains whiteout from lower dir.
5 #
6 # The following kernel commit fixed the kernel crash on the removal
7 # 84889d4 ovl: check dentry positiveness in ovl_cleanup_whiteouts()
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2016 Red Hat Inc.  All Rights Reserved.
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #-----------------------------------------------------------------------
25 #
26
27 seq=`basename $0`
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
35
36 _cleanup()
37 {
38         cd /
39         rm -f $tmp.*
40 }
41
42 # get standard environment, filters and checks
43 . ./common/rc
44 . ./common/filter
45
46 rm -f $seqres.full
47
48 # real QA test starts here
49 _supported_fs overlay
50 _supported_os Linux
51 _require_scratch
52
53 # Remove all files from previous tests
54 _scratch_mkfs
55
56 # Need two lower dirs in this test, and we mount overlay ourselves,
57 # create upper and workdir as well
58 lowerdir1=$SCRATCH_DEV/$OVERLAY_LOWER_DIR.1
59 lowerdir2=$SCRATCH_DEV/$OVERLAY_LOWER_DIR.2
60 upperdir=$SCRATCH_DEV/$OVERLAY_UPPER_DIR
61 workdir=$SCRATCH_DEV/$OVERLAY_WORK_DIR
62 mkdir -p $lowerdir1 $lowerdir2 $upperdir $workdir
63
64 # One lowerdir contains test dir and test files, the other contains whiteout
65 mkdir -p $lowerdir1/testdir $lowerdir2/testdir
66 touch $lowerdir1/testdir/a $lowerdir1/testdir/b
67 mknod $lowerdir2/testdir/a c 0 0
68
69 # Mount overlayfs and remove testdir, which led to kernel crash
70 _overlay_mount_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir \
71                     $SCRATCH_DEV $SCRATCH_MNT
72 rm -rf $SCRATCH_MNT/testdir
73
74 # success, all done
75 echo "Silence is golden"
76 status=0
77 exit