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