overlay/017: silence test output
[xfstests-dev.git] / tests / overlay / 017
1 #! /bin/bash
2 # FSQA Test No. 017
3 #
4 # Test unstable inode number
5 #
6 # This simple test demonstrates a known issue with overlayfs:
7 # - stat file A shows inode number X
8 # - modify A to trigger copy up
9 # - stat file A shows inode number Y != X
10 #
11 # Also test if d_ino of readdir entries changes after copy up.
12 #
13 #-----------------------------------------------------------------------
14 #
15 # Copyright (C) 2016 CTERA Networks. All Rights Reserved.
16 # Author: Amir Goldstein <amir73il@gmail.com>
17 #
18 # This program is free software; you can redistribute it and/or
19 # modify it under the terms of the GNU General Public License as
20 # published by the Free Software Foundation.
21 #
22 # This program is distributed in the hope that it would be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25 # GNU General Public License for more details.
26 #
27 # You should have received a copy of the GNU General Public License
28 # along with this program; if not, write the Free Software Foundation,
29 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
30 #-----------------------------------------------------------------------
31 #
32
33 seq=`basename $0`
34 seqres=$RESULT_DIR/$seq
35 echo "QA output created by $seq"
36
37 tmp=/tmp/$$
38 status=1        # failure is the default!
39 trap "_cleanup; exit \$status" 0 1 2 3 15
40
41 _cleanup()
42 {
43         cd /
44         rm -f $tmp.*
45 }
46
47 # get standard environment, filters and checks
48 . ./common/rc
49 . ./common/filter
50
51 # real QA test starts here
52 _supported_fs overlay
53 _supported_os Linux
54 _require_scratch
55
56 rm -f $seqres.full
57
58 _scratch_mkfs >>$seqres.full 2>&1
59
60 # Create our test files.
61 # Not dealing with hardlinks here, because there is more to test
62 # then stable inode number.
63 # Hardlinks will get a test of their own.
64 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
65 mkdir -p $lowerdir
66 mkdir $lowerdir/dir
67 touch $lowerdir/file
68 ln -s $lowerdir/file $lowerdir/symlink
69 mknod $lowerdir/chrdev c 1 1
70 mknod $lowerdir/blkdev b 1 1
71 mknod $lowerdir/fifo p
72
73
74 _scratch_mount
75
76
77 rm -f $tmp.*
78
79 # Test stable stat(2) st_ino
80
81 # Record inode numbers before and after copy up
82 for f in dir file symlink chrdev blkdev fifo; do
83         ls -id $SCRATCH_MNT/$f >> $tmp.before
84         # chown -h modifies all those file types
85         chown -h 100 $SCRATCH_MNT/$f
86         ls -id $SCRATCH_MNT/$f >> $tmp.after
87 done
88
89 # Test stable readdir(3)/getdents(2) d_ino
90
91 # find by inode number - expect to find file by inode number
92 cat $tmp.before | while read ino f; do
93         find $SCRATCH_MNT/ -maxdepth 1 -inum $ino | grep -q $f || \
94                 echo "$f not found by ino $ino"
95 done
96
97 # Compare before..after - expect silence
98 diff $tmp.before $tmp.after
99
100 echo "Silence is golden"
101 status=0
102 exit