overlay: rename OVERLAY_LOWER/UPPER/WORK_DIR
[xfstests-dev.git] / tests / overlay / 028
1 #! /bin/bash
2 # FS QA Test 028
3 #
4 # When file in lower dir is locked and it's been copied up,
5 # make sure the lock is working in overlayfs.
6 #
7 # Kernel commit below fixed it.
8 # c568d68341be locks: fix file locking on overlayfs
9 #
10 # This reproducer was originally written by
11 #     Miklos Szeredi <mszeredi@redhat.com>
12 #
13 #-----------------------------------------------------------------------
14 # Copyright (c) 2017 Red Hat Inc.  All Rights Reserved.
15 #
16 # This program is free software; you can redistribute it and/or
17 # modify it under the terms of the GNU General Public License as
18 # published by the Free Software Foundation.
19 #
20 # This program is distributed in the hope that it would be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 # GNU General Public License for more details.
24 #
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write the Free Software Foundation,
27 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
28 #-----------------------------------------------------------------------
29 #
30
31 seq=`basename $0`
32 seqres=$RESULT_DIR/$seq
33 echo "QA output created by $seq"
34
35 here=`pwd`
36 tmp=/tmp/$$
37 status=1        # failure is the default!
38 trap "_cleanup; exit \$status" 0 1 2 3 15
39
40 _cleanup()
41 {
42         cd /
43         rm -f $tmp.*
44 }
45
46 # get standard environment, filters and checks
47 . ./common/rc
48 . ./common/filter
49
50 # remove previous $seqres.full before test
51 rm -f $seqres.full
52
53 # real QA test starts here
54
55 # Modify as appropriate.
56 _supported_fs overlay
57 _supported_os Linux
58 _require_scratch
59 _require_command "$FLOCK_PROG" flock
60
61 # Remove all files from previous tests
62 _scratch_mkfs
63
64 lowerdir=$SCRATCH_DEV/$OVL_LOWER
65 mkdir -p $lowerdir
66 touch $lowerdir/foo
67
68 # Mounting overlay
69 _scratch_mount
70
71 # Testing copyup and flock
72 flock $SCRATCH_MNT/foo sleep 3 &
73 # flock in subshell should fail with no output
74 (sleep 1; echo bar > $SCRATCH_MNT/foo; \
75   flock -n $SCRATCH_MNT/foo echo LOCKED)
76
77 wait
78 echo "Silence is golden"
79 # success, all done
80 status=0
81 exit