overlay: rename OVERLAY_LOWER/UPPER/WORK_DIR
[xfstests-dev.git] / tests / overlay / 012
1 #! /bin/bash
2 # FS QA Test 012
3 #
4 # The upper dentry may become stale before we remove it from
5 # overlay, e.g. file was removed from upperdir directly, which
6 # triggered warning/oops in ovl_remove_and_whiteout().
7 #
8 # Commit cfc9fde0b07c ("ovl: verify upper dentry in
9 # ovl_remove_and_whiteout()") fixed this issue.
10 #
11 #-----------------------------------------------------------------------
12 # Copyright (c) 2016 Red Hat Inc.  All Rights Reserved.
13 #
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License as
16 # published by the Free Software Foundation.
17 #
18 # This program is distributed in the hope that it would be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write the Free Software Foundation,
25 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
26 #-----------------------------------------------------------------------
27 #
28
29 seq=`basename $0`
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
32
33 here=`pwd`
34 tmp=/tmp/$$
35 status=1        # failure is the default!
36 trap "_cleanup; exit \$status" 0 1 2 3 15
37
38 _cleanup()
39 {
40         cd /
41         rm -f $tmp.*
42 }
43
44 # get standard environment, filters and checks
45 . ./common/rc
46 . ./common/filter
47
48 rm -f $seqres.full
49
50 # real QA test starts here
51 _supported_fs overlay
52 _supported_os Linux
53 _require_scratch
54
55 # remove all files from previous runs
56 _scratch_mkfs
57
58 lowerdir=$SCRATCH_DEV/$OVL_LOWER
59 upperdir=$SCRATCH_DEV/$OVL_UPPER
60 mkdir -p $lowerdir/test
61
62 _scratch_mount
63
64 # remove test file to create a whiteout
65 rmdir $SCRATCH_MNT/test
66
67 # create the test file again and remove it from upperdir directly, make the
68 # upper dentry become stale
69 touch $SCRATCH_MNT/test
70 rm $upperdir/test
71 # try to remove test file from overlay dir, trigger ovl_remove_and_whiteout, it
72 # should see stale file handle error, and no warnings/oops are expected.
73 rm $SCRATCH_MNT/test 2>&1 | _filter_scratch
74
75 # success, all done
76 status=0
77 exit