generic: test for creating duplicate filenames in encrypted dir
[xfstests-dev.git] / tests / overlay / 039
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Huawei.  All Rights Reserved.
4 #
5 # FS QA Test 039
6 #
7 # Test access time update issue for directories in upper layer.
8 #
9 # Upstream Commit cd91304e7190 ("ovl: fix relatime for directories")
10 # fixed this issue.
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 # remove previous $seqres.full before test
32 rm -f $seqres.full
33
34 # real QA test starts here
35 _supported_fs overlay
36 _require_scratch
37 _require_relatime
38
39 # remove all files from previous runs
40 _scratch_mkfs
41
42 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
43 upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
44 mkdir -p $upperdir/test
45
46 _scratch_mount "-o relatime"
47
48 # access test dir, it's access time will be updated normally
49 ls $SCRATCH_MNT/test
50
51 pre_access_time=`stat -c "%X" $SCRATCH_MNT/test`
52
53 # In relatime mode, access time is only updated if the previous
54 # access time was earlier than the current modify or change time,
55 # so trigger modify and change time update.
56 touch $SCRATCH_MNT/test/foo
57 sleep 1
58
59 # access test dir again
60 ls $SCRATCH_MNT/test > /dev/null 2>&1
61
62 cur_access_time=`stat -c "%X" $SCRATCH_MNT/test`
63
64 # compare the results, current access time should later than the previous one
65 if [ $cur_access_time -le $pre_access_time ] ; then
66         echo "Access time is not updated correctly."
67 fi
68
69 # success, all done
70 echo "Silence is golden"
71 status=0
72 exit