xfs: fix old fuzz test invocations of xfs_repair
[xfstests-dev.git] / tests / overlay / 059
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2018 CTERA Networks. All Rights Reserved.
4 #
5 # FS QA Test 059
6 #
7 # Test multiple origin references to the same lower file.
8 #
9 # Multiple origin references to the same lower file from upper files that
10 # are not hardlinks will falsely return the same st_ino/st_dev for two
11 # different overlay files and will cause 'diff' to falsely report that
12 # content of files is the same when it is not.
13 #
14 # This test checks that overlayfs detects and fails lookup of a multiply
15 # referenced origin.
16 #
17 # The check for multiply referenced origin was a by-product of kernel
18 # commit 31747eda41ef ("ovl: hash directory inodes for fsnotify")
19 #
20 seq=`basename $0`
21 seqres=$RESULT_DIR/$seq
22 echo "QA output created by $seq"
23
24 here=`pwd`
25 tmp=/tmp/$$
26 status=1        # failure is the default!
27 trap "_cleanup; exit \$status" 0 1 2 3 15
28
29 _cleanup()
30 {
31         cd /
32         rm -f $tmp.*
33 }
34
35 # Rename lower file to create copy up with origin xattr
36 create_origin_ref()
37 {
38         local ref=$1
39
40         touch $lowerdir/origin
41
42         # Enabling redirect_dir may seem irrelevant to rename of non-dir,
43         # but with upcoming 'metacopy' feature, redirects will be set also
44         # on non-dir and may also create multiple redirects.
45         _scratch_mount -o redirect_dir=on
46         mv $SCRATCH_MNT/origin $SCRATCH_MNT/$ref
47
48         $UMOUNT_PROG $SCRATCH_MNT
49 }
50
51 # get standard environment, filters and checks
52 . ./common/rc
53 . ./common/filter
54
55 rm -f $seqres.full
56
57 # real QA test starts here
58 _supported_fs overlay
59 _require_scratch_nocheck
60 _require_scratch_feature redirect_dir
61
62 # remove all files from previous runs
63 _scratch_mkfs
64
65 upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
66 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
67
68 # Create copied up file with origin xattr
69 create_origin_ref ref1
70 # Duplicate the copied up file
71 cp -a $upperdir/ref1 $upperdir/ref2
72
73 # Diverge the content of the two copies of file
74 # and the content of two copies of redirected dir
75 echo right >> $upperdir/ref1
76 echo wrong >> $upperdir/ref2
77
78 _scratch_mount -o redirect_dir=on
79
80 # If both copies of file use the same st_dev/st_ino in overlay
81 # diff won't detect that their content differs
82 diff -q $SCRATCH_MNT/ref1 $SCRATCH_MNT/ref2 &>/dev/null && \
83         echo "diff on duplicated upper files doesn't know right from wrong!"
84
85 # success, all done
86 echo "Silence is golden"
87 status=0
88 exit