overlay: rename OVERLAY_LOWER/UPPER/WORK_DIR
[xfstests-dev.git] / tests / overlay / 018
1 #! /bin/bash
2 # FSQA Test No. 018
3 #
4 # Test hardlink breakage
5 #
6 # This simple test demonstrates a known issue with overlayfs:
7 # - file A and B are hardlinked in lower
8 # - modify A to trigger copy up
9 # - file A is no longer a hardlink of file B
10 #
11 #-----------------------------------------------------------------------
12 #
13 # Copyright (C) 2016 CTERA Networks. All Rights Reserved.
14 # Author: Amir Goldstein <amir73il@gmail.com>
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 tmp=/tmp/$$
36 status=1        # failure is the default!
37 trap "_cleanup; exit \$status" 0 1 2 3 15
38
39 _cleanup()
40 {
41         rm -f $tmp.*
42 }
43
44 # get standard environment, filters and checks
45 . ./common/rc
46 . ./common/filter
47
48 # real QA test starts here
49 _supported_fs overlay
50 _supported_os Linux
51 _require_scratch
52
53 rm -f $seqres.full
54
55 _scratch_mkfs >>$seqres.full 2>&1
56
57 # Create 2 hardlinked files in lower
58 lowerdir=$SCRATCH_DEV/$OVL_LOWER
59 mkdir -p $lowerdir
60 echo "patient zero" >> $lowerdir/foo
61 ln $lowerdir/foo $lowerdir/bar
62
63
64 _scratch_mount
65
66
67 rm -f $tmp.before $tmp.after
68
69 foo=$SCRATCH_MNT/foo
70 bar=$SCRATCH_MNT/bar
71
72 # Record inode number and nlink before copy up
73 ls -li $foo $bar | awk '{ print $1, $3 }' > $tmp.before
74
75 # Modify content of one of the hardlinks
76 echo "mutated" >> $foo
77
78 # Record inode number and nlink after copy up
79 ls -li $foo $bar | awk '{ print $1, $3 }' > $tmp.after
80
81 # Compare ino/nlink before..after - expect silence
82 diff $tmp.before $tmp.after
83
84 # Compare content of files - expect silence
85 diff $foo $bar
86
87 echo "Silence is golden"
88 status=0
89 exit