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# $FreeBSD$ 24 25# 26# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)zfs_mount_008_pos.ksh 1.3 09/01/13 SMI" 30# 31 32. $STF_SUITE/tests/cli_root/zfs_mount/zfs_mount.kshlib 33 34################################################################################# 35# 36# __stc_assertion_start 37# 38# ID: zfs_mount_008_pos 39# 40# DESCRIPTION: 41# 'zfs mount -O' allow the file system to be mounted over an existing 42# mount point, making the underlying file system inaccessible. 43# 44# STRATEGY: 45# 1. Create two filesystem fs & fs1, and create two test files for them. 46# 2. Unmount fs1 and set mountpoint property is identical to fs. 47# 3. Verify 'zfs mount -O' will make the underlying filesystem fs 48# inaccessible. 49# 50# TESTABILITY: explicit 51# 52# TEST_AUTOMATION_LEVEL: automated 53# 54# CODING_STATUS: COMPLETED (2006-08-02) 55# 56# __stc_assertion_end 57# 58################################################################################ 59 60function cleanup 61{ 62 ! ismounted $fs && log_must $ZFS mount $fs 63 64 if datasetexists $fs1; then 65 log_must $ZFS destroy $fs1 66 fi 67 68 if [[ -f $testfile ]]; then 69 log_must $RM -f $testfile 70 fi 71} 72 73log_assert "Verify 'zfs mount -O' will override existing mount point." 74log_onexit cleanup 75 76fs=$TESTPOOL/$TESTFS; fs1=$TESTPOOL/$TESTFS1 77 78cleanup 79 80# Get the original mountpoint of $fs and $fs1 81mntpnt=$(get_prop mountpoint $fs) 82log_must $ZFS create $fs1 83mntpnt1=$(get_prop mountpoint $fs1) 84 85testfile=$mntpnt/$TESTFILE0; testfile1=$mntpnt1/$TESTFILE1 86log_must $MKFILE 1M $testfile $testfile1 87 88log_must $ZFS unmount $fs1 89log_must $ZFS set mountpoint=$mntpnt $fs1 90log_must $ZFS mount $fs1 91 92# Create new file in override mountpoint 93log_must $MKFILE 1M $mntpnt/$TESTFILE2 94 95# Verify the underlying file system inaccessible 96log_mustnot $LS $testfile 97log_must $LS $mntpnt/$TESTFILE1 $mntpnt/$TESTFILE2 98 99# Verify $TESTFILE2 was created in $fs1, rather then $fs 100log_must $ZFS unmount $fs1 101log_must $ZFS set mountpoint=$mntpnt1 $fs1 102log_must $ZFS mount $fs1 103log_must $LS $testfile1 $mntpnt1/$TESTFILE2 104 105# Verify $TESTFILE2 was not created in $fs, and $fs is accessible again. 106log_mustnot $LS $mntpnt/$TESTFILE2 107log_must $LS $testfile 108 109log_pass "Verify 'zfs mount -O' override mount point passed." 110