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 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27 28. $STF_SUITE/include/libtest.shlib 29. $STF_SUITE/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib 30 31# 32# DESCRIPTION: 33# Invoke "zfs mount <filesystem>" with a filesystem 34# which mountpoint be the identical or the top of an existing one, 35# it will fail with a return code of 1 36# 37# STRATEGY: 38# 1. Prepare an existing mounted filesystem. 39# 2. Setup a new filesystem and make sure that it is unmounted. 40# 3. Mount the new filesystem using the various combinations 41# - zfs set mountpoint=<identical path> <filesystem> 42# - zfs set mountpoint=<top path> <filesystem> 43# 4. Verify that mount failed with return code of 1. 44# 45 46verify_runnable "both" 47 48function cleanup 49{ 50 log_must force_unmount $TESTPOOL/$TESTFS 51 52 datasetexists $TESTPOOL/$TESTFS1 && \ 53 cleanup_filesystem $TESTPOOL $TESTFS1 54 55 [[ -d $TESTDIR ]] && \ 56 log_must $RM -rf $TESTDIR 57 log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS 58 log_must force_unmount $TESTPOOL/$TESTFS 59 60 return 0 61} 62 63typeset -i ret=0 64 65log_assert "Verify that '$ZFS $mountcmd <filesystem>' " \ 66 "which mountpoint be the identical or the top of an existing one " \ 67 "will fail with return code 1." 68 69log_onexit cleanup 70 71unmounted $TESTPOOL/$TESTFS || \ 72 log_must force_unmount $TESTPOOL/$TESTFS 73 74[[ -d $TESTDIR ]] && \ 75 log_must $RM -rf $TESTDIR 76 77typeset -i MAXDEPTH=3 78typeset -i depth=0 79typeset mtpt=$TESTDIR 80 81while (( depth < MAXDEPTH )); do 82 mtpt=$mtpt/$depth 83 (( depth = depth + 1)) 84done 85 86log_must $ZFS set mountpoint=$mtpt $TESTPOOL/$TESTFS 87log_must $ZFS $mountcmd $TESTPOOL/$TESTFS 88 89mounted $TESTPOOL/$TESTFS || \ 90 log_unresolved "Filesystem $TESTPOOL/$TESTFS is unmounted" 91 92log_must $ZFS create $TESTPOOL/$TESTFS1 93 94unmounted $TESTPOOL/$TESTFS1 || \ 95 log_must force_unmount $TESTPOOL/$TESTFS1 96 97while [[ -n $mtpt ]] ; do 98 (( depth == MAXDEPTH )) && \ 99 log_note "Verify that '$ZFS $mountcmd <filesystem>' " \ 100 "which mountpoint be the identical of an existing one " \ 101 "will fail with return code 1." 102 103 log_must $ZFS set mountpoint=$mtpt $TESTPOOL/$TESTFS1 104 log_mustnot $ZFS $mountcmd $TESTPOOL/$TESTFS1 105 106 unmounted $TESTPOOL/$TESTFS1 || \ 107 log_fail "Filesystem $TESTPOOL/$TESTFS1 is mounted." 108 109 mtpt=${mtpt%/*} 110 111 (( depth == MAXDEPTH )) && \ 112 log_note "Verify that '$ZFS $mountcmd <filesystem>' " \ 113 "which mountpoint be the top of an existing one " \ 114 "will fail with return code 1." 115 (( depth = depth - 1 )) 116done 117 118log_pass "'$ZFS $mountcmd <filesystem>' " \ 119 "which mountpoint be the identical or the top of an existing one " \ 120 "will fail with return code 1." 121