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#
24# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26
27. $STF_SUITE/include/libtest.kshlib
28
29#################################################################################
30#
31# __stc_assertion_start
32#
33# ID: mountpoint_003_pos
34#
35# DESCRIPTION:
36#	Verify FSType-specific option works well with legacy mount.
37#
38# STRATEGY:
39#	1. Set up FSType-specific options and expected keywords array.
40#	2. Create a test ZFS file system and set mountpoint=legacy.
41#	3. Mount ZFS test filesystem with specific options.
42#	4. Verify the filesystem was mounted with specific option.
43#	5. Loop check all the options.
44#
45# TESTABILITY: explicit
46#
47# TEST_AUTOMATION_LEVEL: automated
48#
49# CODING_STATUS: COMPLETED (2007-01-26)
50#
51# __stc_assertion_end
52#
53################################################################################
54
55verify_runnable "both"
56
57function cleanup
58{
59	ismounted $tmpmnt && log_must $UMOUNT $tmpmnt
60	[[ -d $tmpmnt ]] && log_must $RM -rf $tmpmnt
61	[[ -n $oldmpt ]] && log_must $ZFS set mountpoint=$oldmpt $testfs
62	! ismounted $oldmpt && log_must $ZFS mount $testfs
63}
64
65log_assert "With legacy mount, FSType-specific option works well."
66log_onexit cleanup
67
68#
69#  /mnt on pool/fs read/write/setuid/devices/noexec/xattr/atime/dev=2d9009e
70#
71#	FSType-				FSType-
72#	specific	Keyword		specific	Keyword
73#	option				option
74#
75set -A args \
76	"devices"	"/devices/"	"nodevices"	"/nodevices/"	\
77	"exec"		"/exec/"	"noexec"	"/noexec/"	\
78	"nbmand"	"/nbmand/"	"nonbmand"	"/nonbmand/"	\
79	"ro"		"read only"	"rw"		"read/write"	\
80	"setuid"	"/setuid/"	"nosetuid"	"/nosetuid/"	\
81	"xattr"		"/xattr/"	"noxattr"	"/noxattr/"	\
82	"atime"		"/atime/"	"noatime"	"/noatime/"
83
84tmpmnt=/tmpmnt.${TESTCASE_ID}
85[[ -d $tmpmnt ]] && $RM -rf $tmpmnt
86testfs=$TESTPOOL/$TESTFS
87log_must $MKDIR $tmpmnt
88oldmpt=$(get_prop mountpoint $testfs)
89log_must $ZFS set mountpoint=legacy $testfs
90
91typeset i=0
92while ((i < ${#args[@]})); do
93	log_must $MOUNT -t zfs -o ${args[$i]} $testfs $tmpmnt
94	msg=$($MOUNT | $GREP "^$tmpmnt ")
95
96	# In LZ, a user with all zone privileges can never with "devices"
97	if ! is_global_zone && [[ ${args[$i]} == devices ]] ; then
98		args[((i+1))]="/nodevices/"
99	fi
100
101	$ECHO $msg | $GREP "${args[((i+1))]}" > /dev/null 2>&1
102	if (($? != 0)) ; then
103		log_fail "Expected option: ${args[((i+1))]} \n" \
104			 "Real option: $msg"
105	fi
106
107	log_must $UMOUNT $tmpmnt
108	((i += 2))
109done
110
111log_pass "With legacy mount, FSType-specific option works well passed."
112