4 # Test constant inode numbers
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
11 # Also test if d_ino of readdir entries changes after copy up.
13 #-----------------------------------------------------------------------
15 # Copyright (C) 2016 CTERA Networks. All Rights Reserved.
16 # Author: Amir Goldstein <amir73il@gmail.com>
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.
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.
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 #-----------------------------------------------------------------------
34 seqres=$RESULT_DIR/$seq
35 echo "QA output created by $seq"
39 status=1 # failure is the default!
40 trap "_cleanup; exit \$status" 0 1 2 3 15
48 # get standard environment, filters and checks
52 # real QA test starts here
56 _require_test_program "af_unix"
60 _scratch_mkfs >>$seqres.full 2>&1
62 # Create our test files.
63 # Not dealing with hardlinks here, when hardlinks are broken they
64 # should not preserve the inode number.
65 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
69 ln -s $lowerdir/file $lowerdir/symlink
70 mknod $lowerdir/chrdev c 1 1
71 mknod $lowerdir/blkdev b 1 1
72 mknod $lowerdir/fifo p
73 $here/src/af_unix $lowerdir/socket
81 # Test stable stat(2) st_ino
83 # Record inode numbers before and after copy up
84 for f in dir file symlink chrdev blkdev fifo socket; do
85 ls -id $SCRATCH_MNT/$f >> $tmp.before
86 # chown -h modifies all those file types
87 chown -h 100 $SCRATCH_MNT/$f
88 ls -id $SCRATCH_MNT/$f >> $tmp.after
91 # Test stable readdir(3)/getdents(2) d_ino
93 # find by inode number - expect to find file by inode number
94 cat $tmp.before | while read ino f; do
95 find $SCRATCH_MNT/ -maxdepth 1 -inum $ino | grep -q $f || \
96 echo "$f not found by ino $ino"
99 # Compare before..after - expect silence
100 diff $tmp.before $tmp.after
102 echo "Silence is golden"