overlay: rename OVERLAY_LOWER/UPPER/WORK_DIR
[xfstests-dev.git] / tests / overlay / 001
1 #! /bin/bash
2 # FS QA Test 001
3 #
4 # Test copy up files from lower dir that are <, =, > 4G in size.
5 #
6 # Kernel commit 0480334fa604 ("ovl: use O_LARGEFILE in ovl_copy_up()")
7 # fixed bug when copying up large file from lower dir.
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 # remove previous $seqres.full before test
47 rm -f $seqres.full
48
49 # real QA test starts here
50 _supported_fs overlay
51 _supported_os Linux
52 _require_scratch
53
54 # Remove all files from previous tests
55 _scratch_mkfs
56
57 # overlay copy_up doesn't deal with sparse file well, holes will be filled by
58 # zeros, so at least (4G + 4G + 8k) free space is needed on $SCRATCH_DEV,
59 # where $SCRATCH_DEV is actually a test dir used in overlay testing
60 _require_fs_space $SCRATCH_DEV $((4*1024*1024*2 + 8))
61
62 # Create test files with different sizes in lower dir
63 lowerdir=$SCRATCH_DEV/$OVL_LOWER
64 mkdir -p $lowerdir
65 touch $lowerdir/zero_size
66 $XFS_IO_PROG -fc "pwrite 0 4k" $lowerdir/less_than_4g >>$seqres.full
67 $XFS_IO_PROG -fc "pwrite 4294963200 4k" $lowerdir/4gfile >>$seqres.full
68 $XFS_IO_PROG -fc "pwrite 4g 4k" $lowerdir/larger_than_4g >>$seqres.full
69
70 _scratch_mount
71
72 echo "Silence is golden"
73
74 # Open the files should succeed, no errors are expected (e.g. EFBIG)
75 for f in $SCRATCH_MNT/*; do
76         $XFS_IO_PROG -c "open" $f >>$seqres.full
77 done
78
79 # success, all done
80 status=0
81 exit