xref: /freebsd/tools/test/stress2/misc/mountro4.sh (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1#!/bin/sh
2
3#
4# SPDX-License-Identifier: BSD-2-Clause
5#
6# Copyright (c) 2019 Dell EMC Isilon
7#
8# Redistribution and use in source and binary forms, with or without
9# modification, are permitted provided that the following conditions
10# are met:
11# 1. Redistributions of source code must retain the above copyright
12#    notice, this list of conditions and the following disclaimer.
13# 2. Redistributions in binary form must reproduce the above copyright
14#    notice, this list of conditions and the following disclaimer in the
15#    documentation and/or other materials provided with the distribution.
16#
17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27# SUCH DAMAGE.
28#
29
30# Check that the time stamps are not updated for a RO mount.
31
32. ../default.cfg
33
34f1=$mntpoint/f1
35f2=$mntpoint/f2
36s=0
37
38# ufs
39mount | grep -q "on $mntpoint " && umount $mntpoint
40[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart
41mdconfig -a -t swap -s 1g -u $mdstart
42newfs $newfs_flags /dev/md$mdstart > /dev/null
43mount /dev/md$mdstart $mntpoint || exit 1
44touch $f1
45mount -u -o ro $mntpoint
46touch $f2 2>/dev/null && { echo "ufs: ro failed"; s=1; }
47d1=`stat -f '%a %m %c' $f1`
48sleep 1
49cat $f1 > /dev/null
50d2=`stat -f '%a %m %c' $f1`
51if [ "$d1" != "$d2" ]; then
52	echo "ufs: Access time was updated. $d1 != $d2"
53	s=1
54fi
55mount -u -o rw $mntpoint
56touch $f2 2>/dev/null || { echo "ufs: rw failed"; s=1; }
57umount $mntpoint
58mdconfig -d -u $mdstart
59
60# tmpfs
61mount -o size=100m -t tmpfs null $mntpoint || exit 1
62touch $f1
63mount -u -o ro $mntpoint
64touch $f2 2>/dev/null && { echo "tmpfs: ro failed"; s=1; }
65d1=`stat -f '%a %m %c' $f1`
66sleep 1
67cat $f1 > /dev/null
68d2=`stat -f '%a %m %c' $f1`
69if [ "$d1" != "$d2" ]; then
70	echo "tmpfs: Access time was updated. $d1 != $d2"
71	s=1
72fi
73mount -u -o rw $mntpoint
74touch $f2 2>/dev/null || { echo "tmpfs: rw failed"; s=1; }
75umount $mntpoint
76
77# msdosfs
78[ -c /dev/md$mdstart ] &&  mdconfig -d -u $mdstart
79mdconfig -a -t swap -s 1g -u $mdstart
80gpart create -s bsd md$mdstart > /dev/null
81gpart add -t freebsd-ufs md$mdstart > /dev/null
82part=a
83newfs_msdos /dev/md${mdstart}$part > /dev/null
84mount -t msdosfs /dev/md${mdstart}$part $mntpoint || exit 1
85
86touch $f1
87mount -u -o ro $mntpoint
88touch $f2 2>/dev/null && { echo "msdosfs: ro failed"; s=1; }
89d1=`stat -f '%a %m %c' $f1`
90sleep 1
91cat $f1 > /dev/null
92d2=`stat -f '%a %m %c' $f1`
93if [ "$d1" != "$d2" ]; then
94	echo "msdosfs: Access time was updated. $d1 != $d2"
95	s=1
96fi
97mount -u -o rw $mntpoint
98touch $f2 2>/dev/null || { echo "msdosfs: rw failed"; s=1; }
99umount $mntpoint
100mdconfig -d -u $mdstart
101
102exit $s
103