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