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/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib 33 34# 35# DESCRIPTION: 36# 'zfs mount -O' allow the file system to be mounted over an existing 37# mount point, making the underlying file system inaccessible. 38# 39# STRATEGY: 40# 1. Create two filesystem fs & fs1, and create two test files for them. 41# 2. Unmount fs1 and set mountpoint property is identical to fs. 42# 3. Verify 'zfs mount -O' will make the underlying filesystem fs 43# inaccessible. 44# 45 46function cleanup 47{ 48 ! ismounted $fs && log_must zfs mount $fs 49 50 datasetexists $fs1 && destroy_dataset $fs1 51 52 if [[ -f $testfile ]]; then 53 log_must rm -f $testfile 54 fi 55} 56 57log_assert "Verify 'zfs mount -O' will override existing mount point." 58log_onexit cleanup 59 60fs=$TESTPOOL/$TESTFS; fs1=$TESTPOOL/$TESTFS1 61 62cleanup 63 64# Get the original mountpoint of $fs and $fs1 65mntpnt=$(get_prop mountpoint $fs) 66log_must zfs create $fs1 67mntpnt1=$(get_prop mountpoint $fs1) 68 69testfile=$mntpnt/$TESTFILE0; testfile1=$mntpnt1/$TESTFILE1 70log_must mkfile 1M $testfile $testfile1 71 72log_must zfs unmount $fs1 73log_must zfs set mountpoint=$mntpnt $fs1 74log_must zfs mount $fs1 75log_must zfs unmount $fs1 76log_must zfs mount -O $fs1 77 78# Create new file in override mountpoint 79log_must mkfile 1M $mntpnt/$TESTFILE2 80 81# Verify the underlying file system inaccessible 82log_mustnot ls $testfile 83log_must ls $mntpnt/$TESTFILE1 $mntpnt/$TESTFILE2 84 85# Verify $TESTFILE2 was created in $fs1, rather than $fs 86log_must zfs unmount $fs1 87log_must zfs set mountpoint=$mntpnt1 $fs1 88log_must zfs mount $fs1 89log_must ls $testfile1 $mntpnt1/$TESTFILE2 90 91# Verify $TESTFILE2 was not created in $fs, and $fs is accessible again. 92log_mustnot ls $mntpnt/$TESTFILE2 93log_must ls $testfile 94 95log_pass "Verify 'zfs mount -O' override mount point passed." 96