fstests: convert remaining tests to SPDX license tags
[xfstests-dev.git] / tests / overlay / 028
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 028
6 #
7 # When file in lower dir is locked and it's been copied up,
8 # make sure the lock is working in overlayfs.
9 #
10 # Kernel commit below fixed it.
11 # c568d68341be locks: fix file locking on overlayfs
12 #
13 # This reproducer was originally written by
14 #     Miklos Szeredi <mszeredi@redhat.com>
15 #
16 seq=`basename $0`
17 seqres=$RESULT_DIR/$seq
18 echo "QA output created by $seq"
19
20 here=`pwd`
21 tmp=/tmp/$$
22 status=1        # failure is the default!
23 trap "_cleanup; exit \$status" 0 1 2 3 15
24
25 _cleanup()
26 {
27         cd /
28         rm -f $tmp.*
29 }
30
31 # get standard environment, filters and checks
32 . ./common/rc
33 . ./common/filter
34
35 # remove previous $seqres.full before test
36 rm -f $seqres.full
37
38 # real QA test starts here
39
40 # Modify as appropriate.
41 _supported_fs overlay
42 _supported_os Linux
43 _require_scratch
44 _require_command "$FLOCK_PROG" flock
45
46 # Remove all files from previous tests
47 _scratch_mkfs
48
49 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
50 mkdir -p $lowerdir
51 touch $lowerdir/foo
52
53 # Mounting overlay
54 _scratch_mount
55
56 # Testing copyup and flock
57 flock $SCRATCH_MNT/foo sleep 3 &
58 # flock in subshell should fail with no output
59 (sleep 1; echo bar > $SCRATCH_MNT/foo; \
60   flock -n $SCRATCH_MNT/foo echo LOCKED)
61
62 wait
63 echo "Silence is golden"
64 # success, all done
65 status=0
66 exit