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 https://opensource.org/licenses/CDDL-1.0. 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# 66if is_linux; then 67 set -A args \ 68 "nodev" "dev" \ 69 "noexec" "exec" \ 70 "ro" "rw" \ 71 "nosuid" "suid" \ 72 "xattr" "noxattr" \ 73 "atime" "noatime" 74 75 # Only older kernels support non-blocking mandatory locks 76 if [[ $(linux_version) -lt $(linux_version "4.4") ]]; then 77 args+=("mand" "nomand") 78 fi 79elif is_freebsd; then 80 # 'xattr' and 'devices' are not supported on FreeBSD 81 # Perhaps more options need to be added. 82 set -A args \ 83 "noexec" "exec" \ 84 "ro" "rw" \ 85 "nosuid" "suid" \ 86 "atime" "noatime" 87else 88 set -A args \ 89 "devices" "/devices/" "nodevices" "/nodevices/" \ 90 "exec" "/exec/" "noexec" "/noexec/" \ 91 "nbmand" "/nbmand/" "nonbmand" "/nonbmand/" \ 92 "ro" "read only" "rw" "read/write" \ 93 "setuid" "/setuid/" "nosetuid" "/nosetuid/" \ 94 "xattr" "/xattr/" "noxattr" "/noxattr/" \ 95 "atime" "/atime/" "noatime" "/noatime/" 96fi 97 98tmpmnt=/tmpmnt.$$ 99[[ -d $tmpmnt ]] && rm -rf $tmpmnt 100testfs=$TESTPOOL/$TESTFS 101log_must mkdir $tmpmnt 102oldmpt=$(get_prop mountpoint $testfs) 103log_must zfs set mountpoint=legacy $testfs 104 105typeset i=0 106while ((i < ${#args[@]})); do 107 if is_linux || is_freebsd; then 108 log_must mount -t zfs -o ${args[$i]} $testfs $tmpmnt 109 110 msg=$(mount | grep "$tmpmnt ") 111 112 if ! echo $msg | grep -q "${args[((i))]}"; then 113 if echo $msg | grep -q "${args[((i-1))]}"; then 114 log_fail "Expected option: ${args[((i))]} \n" \ 115 "Real option: $msg" 116 fi 117 fi 118 119 log_must umount $tmpmnt 120 ((i += 1)) 121 else 122 log_must mount -F zfs -o ${args[$i]} $testfs $tmpmnt 123 124 msg=$(mount | grep "^$tmpmnt ") 125 126 # In LZ, a user with all zone privileges can never "devices" 127 if ! is_global_zone && [[ ${args[$i]} == devices ]] ; then 128 args[((i+1))]="/nodevices/" 129 fi 130 131 if ! echo $msg | grep -q "${args[((i+1))]}"; then 132 log_fail "Expected option: ${args[((i+1))]} \n" \ 133 "Real option: $msg" 134 fi 135 136 137 log_must umount $tmpmnt 138 ((i += 2)) 139 fi 140done 141 142log_pass "With legacy mount, FSType-specific option works well passed." 143