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# 29# Copyright (c) 2016 by Delphix. All rights reserved. 30# 31 32. $STF_SUITE/include/libtest.shlib 33 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 46verify_runnable "both" 47 48function cleanup 49{ 50 ismounted $tmpmnt && log_must umount $tmpmnt 51 [[ -d $tmpmnt ]] && log_must rm -rf $tmpmnt 52 [[ -n $oldmpt ]] && log_must zfs set mountpoint=$oldmpt $testfs 53 ! ismounted $oldmpt && log_must zfs mount $testfs 54} 55 56log_assert "With legacy mount, FSType-specific option works well." 57log_onexit cleanup 58 59# 60# /mnt on pool/fs read/write/setuid/devices/noexec/xattr/atime/dev=2d9009e 61# 62# FSType- FSType- 63# specific Keyword specific Keyword 64# option option 65# 66set -A args \ 67 "devices" "/devices/" "nodevices" "/nodevices/" \ 68 "exec" "/exec/" "noexec" "/noexec/" \ 69 "nbmand" "/nbmand/" "nonbmand" "/nonbmand/" \ 70 "ro" "read only" "rw" "read/write" \ 71 "setuid" "/setuid/" "nosetuid" "/nosetuid/" \ 72 "xattr" "/xattr/" "noxattr" "/noxattr/" \ 73 "atime" "/atime/" "noatime" "/noatime/" 74 75tmpmnt=/tmpmnt.$$ 76[[ -d $tmpmnt ]] && rm -rf $tmpmnt 77testfs=$TESTPOOL/$TESTFS 78log_must mkdir $tmpmnt 79oldmpt=$(get_prop mountpoint $testfs) 80log_must zfs set mountpoint=legacy $testfs 81 82typeset i=0 83while ((i < ${#args[@]})); do 84 log_must mount -F zfs -o ${args[$i]} $testfs $tmpmnt 85 msg=$(mount | grep "^$tmpmnt ") 86 87 # In LZ, a user with all zone privileges can never with "devices" 88 if ! is_global_zone && [[ ${args[$i]} == devices ]] ; then 89 args[((i+1))]="/nodevices/" 90 fi 91 92 echo $msg | grep "${args[((i+1))]}" > /dev/null 2>&1 93 if (($? != 0)) ; then 94 log_fail "Expected option: ${args[((i+1))]} \n" \ 95 "Real option: $msg" 96 fi 97 98 log_must umount $tmpmnt 99 ((i += 2)) 100done 101 102log_pass "With legacy mount, FSType-specific option works well passed." 103