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 (c) 2023 by iXsystems, Inc. All rights reserved. 25# 26 27. $STF_SUITE/include/libtest.shlib 28. $STF_SUITE/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib 29 30# 31# DESCRIPTION: 32# 'zfs set -u' should update the mountpoint, sharenfs and sharesmb 33# properties without mounting and sharing the dataset. Validate the 34# bevaior while dataset is mounted and unmounted. 35# 36# STRATEGY: 37# 1. Confirm dataset is currently mounted 38# 2. Update the mountpoint with -u flag 39# 3. Confirm mountpoint property is updated with new value 40# 4. Confirm dataset is still mounted at previous mountpoint 41# 5. Unmount the dataset 42# 6. Confirm dataset is unmounted 43# 7. Mount the dataset 44# 8. Confirm dataset is mounted at new mountpoint, that was set with -u flag. 45# 9. Update and mount the dataset at previous mountpoint. 46# 10. Unmount the dataset 47# 11. Update mountpoint property with zfs set -u 48# 12. Confirm dataset is not mounted 49# 13. Update sharenfs property with zfs set -u 50# 14. Confirm dataset is not mounted 51# 15. Update sharesmb property with zfs set -u 52# 16. Confirm dataset is not mounted 53# 17. Mount the dataset and confirm dataset is mounted at new mountpoint 54# 55 56verify_runnable "both" 57 58function cleanup 59{ 60 log_must zfs set sharenfs=off $TESTPOOL/$TESTFS 61 if is_linux; then 62 log_must zfs set sharesmb=off $TESTPOOL/$TESTFS 63 fi 64 rm -r $newmpt 65} 66 67log_assert "'zfs set -u' sets the mountpoint and share properties without " \ 68 "mounting the dataset" 69log_onexit cleanup 70 71oldmpt=$(get_prop mountpoint $TESTPOOL/$TESTFS) 72newmpt=$TEST_BASE_DIR/abc 73 74# Test while dataset is mounted 75log_must ismounted $TESTPOOL/$TESTFS 76log_must zfs set -u mountpoint=$newmpt $TESTPOOL/$TESTFS 77log_must check_user_prop $TESTPOOL/$TESTFS mountpoint $newmpt 78log_must eval "[[ "$(mount | grep $TESTPOOL/$TESTFS | awk '{print $3}')" == $oldmpt ]]" 79log_must zfs unmount $TESTPOOL/$TESTFS 80log_mustnot ismounted $TESTPOOL/$TESTFS 81log_must zfs mount $TESTPOOL/$TESTFS 82log_must eval "[[ "$(mount | grep $TESTPOOL/$TESTFS | awk '{print $3}')" == $newmpt ]]" 83 84# Test while dataset is unmounted 85log_must zfs set mountpoint=$oldmpt $TESTPOOL/$TESTFS 86log_must ismounted $TESTPOOL/$TESTFS 87log_must zfs unmount $TESTPOOL/$TESTFS 88log_must zfs set -u mountpoint=$newmpt $TESTPOOL/$TESTFS 89log_mustnot ismounted $TESTPOOL/$TESTFS 90log_must zfs set -u sharenfs=on $TESTPOOL/$TESTFS 91log_mustnot ismounted $TESTPOOL/$TESTFS 92if is_linux; then 93 log_must zfs set -u sharesmb=on $TESTPOOL/$TESTFS 94 log_mustnot ismounted $TESTPOOL/$TESTFS 95fi 96log_must zfs mount $TESTPOOL/$TESTFS 97log_must check_user_prop $TESTPOOL/$TESTFS mountpoint $newmpt 98log_must eval "[[ "$(mount | grep $TESTPOOL/$TESTFS | awk '{print $3}')" == $newmpt ]]" 99 100log_must zfs set mountpoint=$oldmpt $TESTPOOL/$TESTFS 101log_must ismounted $TESTPOOL/$TESTFS 102 103log_pass "'zfs set -u' functions correctly" 104