generic/554: hide permision warning on exfat
[xfstests-dev.git] / tests / generic / 462
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat.  All Rights Reserved.
4 #
5 # FS QA Test 462
6 #
7 # This is a regression test for kernel commit
8 #  ef947b2 x86, mm: fix gup_pte_range() vs DAX mappings
9 # created by Jeffrey Moyer <jmoyer@redhat.com>
10 #
11 # This is reproducible only when testing on pmem device
12 # which is configured in "memory mode", not in "raw mode".
13 #
14 seq=`basename $0`
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
17
18 here=`pwd`
19 tmp=/tmp/$$
20 status=1        # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 _cleanup()
24 {
25         cd /
26         rm -rf $tmp.*
27 }
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32
33 # remove previous $seqres.full before test
34 rm -f $seqres.full
35
36 # Modify as appropriate.
37 _supported_fs generic
38 _require_test
39 _require_scratch_dax_mountopt "dax"
40 _require_test_program "t_mmap_write_ro"
41 # running by unpriviliged user is not necessary to reproduce
42 # this bug, just trying to test more.
43 _require_user
44
45 # real QA test starts here
46
47 _scratch_mkfs >>$seqres.full 2>&1
48 _scratch_mount "-o dax"
49
50 # remount TEST_DEV wo/ dax
51 export TEST_FS_MOUNT_OPTS=""
52 _test_cycle_mount
53
54 # prepare a 4k read-only DAX file, save its md5sum
55 $XFS_IO_PROG -f -c "pwrite -S 0xFF 0 4096" \
56         $SCRATCH_MNT/readonlyfile >> $seqres.full 2>&1
57 chmod 0644  $SCRATCH_MNT/readonlyfile
58 md5_1="$(_md5_checksum $SCRATCH_MNT/readonlyfile)"
59
60 # prepare another 4k non-DAX file
61 $XFS_IO_PROG -f -c "pwrite -S 0x00 0 4096" \
62         $TEST_DIR/${seq}.file >> $seqres.full 2>&1
63
64 # allow qa_user access
65 chown $qa_user $TEST_DIR/${seq}.file
66
67 # run test programme, read another file writing into
68 # the read-only file with mmap, which should fail.
69 #
70 # don't use $here/src/t_mmap_write_ro, as we're running it as a regular user,
71 # and $here may contain path component that a regular user doesn't have search
72 # permission
73 _user_do "src/t_mmap_write_ro $TEST_DIR/${seq}.file \
74         $SCRATCH_MNT/readonlyfile"
75
76 # read-only file should not get updated, md5sum again.
77 md5_2="$(_md5_checksum $SCRATCH_MNT/readonlyfile)"
78
79 [ "$md5_1" != "$md5_2" ] && echo "read only file changed"
80
81 # success, all done
82 status=0
83 exit