overlay/075: fix wrong invocation of t_immutable
[xfstests-dev.git] / tests / overlay / 002
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test 002
6 #
7 # Test that calling fsync against a file using the merged directory does not
8 # result in a crash nor fails unexpectedly.
9 #
10 # This is motivated by a change in overlayfs that resulted in a crash (invalid
11 # memory access) when the lower or upper directory belonged to a btrfs file
12 # system.
13 #
14 seq=`basename $0`
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
17
18 here=`pwd`
19 tmp=/tmp/$$
20 status=1        # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 _cleanup()
24 {
25         cd /
26         rm -f $tmp.*
27 }
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32
33 # remove previous $seqres.full before test
34 rm -f $seqres.full
35
36 # real QA test starts here
37 _supported_fs overlay
38 _require_scratch
39
40 # Remove all files from previous tests
41 _scratch_mkfs
42
43 # Create our test file.
44 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
45 mkdir -p $lowerdir
46 touch $lowerdir/foobar
47
48 _scratch_mount
49
50 # Write some data to our file and fsync it, using the merged directory path.
51 # This should work and not result in a crash.
52 $XFS_IO_PROG -c "pwrite 0 64k" -c "fsync" $SCRATCH_MNT/foobar | _filter_xfs_io
53
54 # success, all done
55 status=0
56 exit