generic: test for creating duplicate filenames in encrypted dir
[xfstests-dev.git] / tests / generic / 279
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 279
6 #
7 # Test mmap CoW behavior when the write temporarily fails.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1    # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20     cd /
21     rm -rf $tmp.* $TEST_DIR/mwrite.out
22     _dmerror_cleanup
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/reflink
29 . ./common/dmerror
30
31 # real QA test starts here
32 _require_scratch_reflink
33 _require_cp_reflink
34 _require_dm_target error
35
36 rm -f $seqres.full
37
38
39 echo "Format and mount"
40 _scratch_mkfs > $seqres.full 2>&1
41 _dmerror_init
42 _dmerror_mount >> $seqres.full 2>&1
43
44 testdir=$SCRATCH_MNT/test-$seq
45 mkdir $testdir
46
47 blksz=65536
48 nr=640
49 bufnr=128
50 filesize=$((blksz * nr))
51 bufsize=$((blksz * bufnr))
52
53 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
54
55 echo "Create the original files"
56 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $filesize" $testdir/file1 >> $seqres.full
57 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
58 _dmerror_unmount
59 _dmerror_mount
60
61 echo "Compare files"
62 md5sum $testdir/file1 | _filter_scratch
63 md5sum $testdir/file2 | _filter_scratch
64
65 echo "CoW and unmount"
66 sync
67 _dmerror_load_error_table
68 # Insulate ourselves against bash reporting the SIGBUS when we try to modify
69 # the metadata.
70 cat > $tmp.run << ENDL
71 ulimit -c 0
72 $XFS_IO_PROG -f -c "mmap -rw 0 $filesize" -c "mwrite -S 0x63 0 $filesize" \
73         -c "msync -s 0 $filesize" $testdir/file2 >> $seqres.full 2>&1
74 ENDL
75 bash $tmp.run 2> /dev/null
76 _dmerror_load_working_table
77 _dmerror_unmount
78 _dmerror_mount
79
80 echo "Compare files"
81 md5sum $testdir/file1 | _filter_scratch
82
83 echo "Check for damage"
84 _dmerror_unmount
85 _dmerror_cleanup
86 _repair_scratch_fs >> $seqres.full
87
88 # success, all done
89 status=0
90 exit