xref: /freebsd/tools/regression/tmpfs/t_mount (revision d73f7c1723048be5f8e7eca722cf7a285872d37a)
1f8c94cecSXin LI#!/bin/sh
2f8c94cecSXin LI#
3d73f7c17SXin LI# $NetBSD: t_mount,v 1.8 2007/07/24 11:29:16 jmmv Exp $
4f8c94cecSXin LI#
5d73f7c17SXin LI# Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
6f8c94cecSXin LI# All rights reserved.
7f8c94cecSXin LI#
8f8c94cecSXin LI# This code is derived from software contributed to The NetBSD Foundation
9f8c94cecSXin LI# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
10f8c94cecSXin LI# 2005 program.
11f8c94cecSXin LI#
12f8c94cecSXin LI# Redistribution and use in source and binary forms, with or without
13f8c94cecSXin LI# modification, are permitted provided that the following conditions
14f8c94cecSXin LI# are met:
15f8c94cecSXin LI# 1. Redistributions of source code must retain the above copyright
16f8c94cecSXin LI#    notice, this list of conditions and the following disclaimer.
17f8c94cecSXin LI# 2. Redistributions in binary form must reproduce the above copyright
18f8c94cecSXin LI#    notice, this list of conditions and the following disclaimer in the
19f8c94cecSXin LI#    documentation and/or other materials provided with the distribution.
20f8c94cecSXin LI# 3. All advertising materials mentioning features or use of this software
21f8c94cecSXin LI#    must display the following acknowledgement:
22f8c94cecSXin LI#        This product includes software developed by the NetBSD
23f8c94cecSXin LI#        Foundation, Inc. and its contributors.
24f8c94cecSXin LI# 4. Neither the name of The NetBSD Foundation nor the names of its
25f8c94cecSXin LI#    contributors may be used to endorse or promote products derived
26f8c94cecSXin LI#    from this software without specific prior written permission.
27f8c94cecSXin LI#
28f8c94cecSXin LI# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
29f8c94cecSXin LI# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
30f8c94cecSXin LI# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31f8c94cecSXin LI# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
32f8c94cecSXin LI# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33f8c94cecSXin LI# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34f8c94cecSXin LI# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35f8c94cecSXin LI# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36f8c94cecSXin LI# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37f8c94cecSXin LI# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38f8c94cecSXin LI# POSSIBILITY OF SUCH DAMAGE.
39f8c94cecSXin LI#
40f8c94cecSXin LI# $FreeBSD$
41f8c94cecSXin LI#
42f8c94cecSXin LI
43f8c94cecSXin LI#
44f8c94cecSXin LI# Verifies that an execution of mount and umount works correctly without
45f8c94cecSXin LI# causing errors and that the root node gets correct attributes.
46f8c94cecSXin LI# Also verifies command line parsing from mount_tmpfs.
47f8c94cecSXin LI#
48f8c94cecSXin LI
49f8c94cecSXin LItest_run() {
50f8c94cecSXin LI	test_name "File-system can be mounted"
51f8c94cecSXin LI	test_mount
52f8c94cecSXin LI	test_name "Root directory has two links"
53f8c94cecSXin LI	eval $(stat -s ${Work_Dir})
54f8c94cecSXin LI	[ ${st_nlink} = 2 ] || die
55f8c94cecSXin LI	test_name "File-system can be unmounted"
56f8c94cecSXin LI	test_unmount
57f8c94cecSXin LI
58f8c94cecSXin LI	test_name "File-system mount options work"
59f8c94cecSXin LI	test_mount -o ro
60f8c94cecSXin LI	mount | grep ${Work_Dir} | grep -q read-only || die
61f8c94cecSXin LI	test_unmount
62f8c94cecSXin LI
63f8c94cecSXin LI	test_name "Root directory attributes are set correctly"
64f8c94cecSXin LI	test_mount -o "uid=1000,gid=100,mode=755"
65f8c94cecSXin LI	eval $(stat -s ${Work_Dir})
66f8c94cecSXin LI	[ ${st_uid} = 1000 ] || die
67f8c94cecSXin LI	[ ${st_gid} = 100 ] || die
68f8c94cecSXin LI	[ ${st_mode} = 040755 ] || die
69f8c94cecSXin LI	test_unmount
70f8c94cecSXin LI
71f8c94cecSXin LI	test_name "Negative values are correctly handled"
72f8c94cecSXin LI	test_mount -o "size=-10"
73f8c94cecSXin LI	test_unmount
74f8c94cecSXin LI
75f8c94cecSXin LI	test_name "Extremely large values are correctly handled"
76f8c94cecSXin LI	test_mount -o size=9223372036854775807
77f8c94cecSXin LI	test_unmount
78f8c94cecSXin LI	mount -t tmpfs -o size=9223372036854775808 tmpfs ${Work_Dir} \
79f8c94cecSXin LI	    2>/dev/null && die
80f8c94cecSXin LI	mount -t tmpfs -o size=9223372036854775808g tmpfs ${Work_Dir} \
81f8c94cecSXin LI	    2>/dev/null && die
82f8c94cecSXin LI	rmdir ${Work_Dir}
83f8c94cecSXin LI}
84f8c94cecSXin LI
85f8c94cecSXin LI. ${SUBRDIR}/h_funcs.subr
86