4 # Test multiple redirects to the same lower dir.
6 # Multiple redirects to the same lower dir will falsely return the same
7 # st_ino/st_dev for two different upper dirs and will cause 'diff' to
8 # falsely report that content of directories is the same when it is not.
10 # This test checks that overlayfs detects and fails lookup of a multiply
13 # The check for multiply redirected dir was implemented by kernel titled
14 # "ovl: hash directory inodes for fsnotify"
16 #-----------------------------------------------------------------------
17 # Copyright (C) 2018 CTERA Networks. All Rights Reserved.
18 # Author: Amir Goldstein <amir73il@gmail.com>
20 # This program is free software; you can redistribute it and/or
21 # modify it under the terms of the GNU General Public License as
22 # published by the Free Software Foundation.
24 # This program is distributed in the hope that it would be useful,
25 # but WITHOUT ANY WARRANTY; without even the implied warranty of
26 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 # GNU General Public License for more details.
29 # You should have received a copy of the GNU General Public License
30 # along with this program; if not, write the Free Software Foundation,
31 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
32 #-----------------------------------------------------------------------
36 seqres=$RESULT_DIR/$seq
37 echo "QA output created by $seq"
41 status=1 # failure is the default!
42 trap "_cleanup; exit \$status" 0 1 2 3 15
50 # Rename lower dir to create a redirected upper dir and
51 # touch lower file to create copy up with origin xattr
56 mkdir -p $lowerdir/origin
57 touch $lowerdir/origin/file
59 _scratch_mount -o redirect_dir=on
60 touch $SCRATCH_MNT/origin/file
61 mv $SCRATCH_MNT/origin $SCRATCH_MNT/$redirect
63 $UMOUNT_PROG $SCRATCH_MNT
66 # get standard environment, filters and checks
72 # real QA test starts here
76 _require_scratch_feature redirect_dir
78 # remove all files from previous runs
81 upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
82 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
84 # Create redirected dir with copied up file
85 create_redirect redirect1
86 # Duplicate the redirected dir and copied up file
87 cp -a $upperdir/redirect1 $upperdir/redirect2
89 # Diverge the content of the two copies of file
90 # and the content of two copies of redirected dir
91 echo right >> $upperdir/redirect1/file
92 touch $upperdir/redirect1/right
93 echo wrong >> $upperdir/redirect2/file
94 touch $upperdir/redirect2/wrong
96 _scratch_mount -o redirect_dir=on
98 # If both copies of file/dir use the same st_dev/st_ino in overlay
99 # diff won't detect that their content differs
100 diff -q $SCRATCH_MNT/redirect1/file $SCRATCH_MNT/redirect2/file &>/dev/null && \
101 echo "diff on files inside duplicate redirect parent doesn't know right from wrong!"
103 diff -q $SCRATCH_MNT/redirect1 $SCRATCH_MNT/redirect2 &> /dev/null && \
104 echo "diff on duplicate redirect dirs doesn't know right from wrong!"
107 echo "Silence is golden"