1#!/usr/local/bin/ksh93 -p
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23# $FreeBSD$
24
25#
26# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
27# Use is subject to license terms.
28#
29# ident	"@(#)mountpoint_003_pos.ksh	1.5	09/01/13 SMI"
30#
31
32. $STF_SUITE/include/libtest.kshlib
33
34#################################################################################
35#
36# __stc_assertion_start
37#
38# ID: mountpoint_003_pos
39#
40# DESCRIPTION:
41#	Verify FSType-specific option works well with legacy mount.
42#
43# STRATEGY:
44#	1. Set up FSType-specific options and expected keywords array.
45#	2. Create a test ZFS file system and set mountpoint=legacy.
46#	3. Mount ZFS test filesystem with specific options.
47#	4. Verify the filesystem was mounted with specific option.
48#	5. Loop check all the options.
49#
50# TESTABILITY: explicit
51#
52# TEST_AUTOMATION_LEVEL: automated
53#
54# CODING_STATUS: COMPLETED (2007-01-26)
55#
56# __stc_assertion_end
57#
58################################################################################
59
60verify_runnable "both"
61
62function cleanup
63{
64	ismounted $tmpmnt && log_must $UMOUNT $tmpmnt
65	[[ -d $tmpmnt ]] && log_must $RM -rf $tmpmnt
66	[[ -n $oldmpt ]] && log_must $ZFS set mountpoint=$oldmpt $testfs
67	! ismounted $oldmpt && log_must $ZFS mount $testfs
68}
69
70log_assert "With legacy mount, FSType-specific option works well."
71log_onexit cleanup
72
73#
74#  /mnt on pool/fs read/write/setuid/devices/noexec/xattr/atime/dev=2d9009e
75#
76#	FSType-				FSType-
77#	specific	Keyword		specific	Keyword
78#	option				option
79#
80set -A args \
81	"devices"	"/devices/"	"nodevices"	"/nodevices/"	\
82	"exec"		"/exec/"	"noexec"	"/noexec/"	\
83	"nbmand"	"/nbmand/"	"nonbmand"	"/nonbmand/"	\
84	"ro"		"read only"	"rw"		"read/write"	\
85	"setuid"	"/setuid/"	"nosetuid"	"/nosetuid/"	\
86	"xattr"		"/xattr/"	"noxattr"	"/noxattr/"	\
87	"atime"		"/atime/"	"noatime"	"/noatime/"
88
89tmpmnt=/tmpmnt.${TESTCASE_ID}
90[[ -d $tmpmnt ]] && $RM -rf $tmpmnt
91testfs=$TESTPOOL/$TESTFS
92log_must $MKDIR $tmpmnt
93oldmpt=$(get_prop mountpoint $testfs)
94log_must $ZFS set mountpoint=legacy $testfs
95
96typeset i=0
97while ((i < ${#args[@]})); do
98	log_must $MOUNT -t zfs -o ${args[$i]} $testfs $tmpmnt
99	msg=$($MOUNT | $GREP "^$tmpmnt ")
100
101	# In LZ, a user with all zone privileges can never with "devices"
102	if ! is_global_zone && [[ ${args[$i]} == devices ]] ; then
103		args[((i+1))]="/nodevices/"
104	fi
105
106	$ECHO $msg | $GREP "${args[((i+1))]}" > /dev/null 2>&1
107	if (($? != 0)) ; then
108		log_fail "Expected option: ${args[((i+1))]} \n" \
109			 "Real option: $msg"
110	fi
111
112	log_must $UMOUNT $tmpmnt
113	((i += 2))
114done
115
116log_pass "With legacy mount, FSType-specific option works well passed."
117