generic: test for creating duplicate filenames in encrypted dir
[xfstests-dev.git] / tests / generic / 084
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Red Hat Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 084
6 #
7 # Test hardlink to unlinked file.
8 #
9 # Regression test for commit:
10 # aae8a97 fs: Don't allow to create hardlink for deleted file
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23         cd /
24         rm -f $tmp.*
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30
31 # real QA test starts here
32 _supported_fs generic
33 _require_scratch
34
35 link_unlink_storm()
36 {
37         local src=$1
38         local target=$2
39         local i=0
40
41         while true; do
42                 ln -f $src $target.$i >/dev/null 2>&1
43                 rm -f $target.$i >/dev/null 2>&1
44                 let i=i+1
45         done
46 }
47
48 rm -f $seqres.full
49 nr_cpu=`$here/src/feature -o`
50 echo "Silence is golden"
51
52 _scratch_mkfs >>$seqres.full 2>&1
53 _scratch_mount
54
55 # create, open & unlinked files so unlinked inode list is not empty
56 $here/src/multi_open_unlink -f $SCRATCH_MNT/$seq.unlinked -n $nr_cpu &
57 open_pid=$!
58
59 # start link/unlink storm
60 src=$SCRATCH_MNT/$seq.target
61 touch $src
62 for i in `seq 1 $nr_cpu`; do
63         target=$SCRATCH_MNT/$seq.target.link.$i
64         link_unlink_storm $src $target &
65         link_pids="$link_pids $!"
66 done
67
68 # remove & re-create target to race with link/unlink
69 while true; do
70         rm -f $src
71         touch $src
72 done &
73 sleep 5
74 kill $! >/dev/null 2>&1
75
76 kill $open_pid $link_pids >/dev/null 2>&1
77 wait $open_pid $link_pids
78
79 # all done, no oops/hang expected, _check_filesystems checks SCRATCH_DEV after test
80 status=0
81 exit