1#!/bin/ksh -p 2# 3# CDDL HEADER START 4# 5# This file and its contents are supplied under the terms of the 6# Common Development and Distribution License ("CDDL"), version 1.0. 7# You may only use this file in accordance with the terms of version 8# 1.0 of the CDDL. 9# 10# A full copy of the text of the CDDL should have accompanied this 11# source. A copy of the CDDL is also available via the Internet at 12# http://www.illumos.org/license/CDDL. 13# 14# CDDL HEADER END 15# 16 17. $STF_SUITE/include/libtest.shlib 18. $STF_SUITE/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib 19 20# 21# DESCRIPTION: 22# Verify zfs mount helper functions for both devices and pools. 23# 24 25verify_runnable "both" 26 27set -A vdevs $(get_disklist_fullpath $TESTPOOL) 28typeset -r mntpoint=$(get_prop mountpoint $TESTPOOL) 29typeset -r helper="mount.zfs -o zfsutil" 30typeset -r fs=$TESTPOOL/$TESTFS 31 32function cleanup 33{ 34 cd $STF_SUITE 35 if [[ -d $TESTDIR/$$ ]]; then 36 log_must rm -rf $TESTDIR/$$ 37 fi 38 mounted && zfs $mountcmd $TESTPOOL 39 return 0 40} 41log_onexit cleanup 42 43log_note "Verify zfs mount helper functions for both devices and pools" 44 45# Ensure that the ZFS filesystem is unmounted 46force_unmount $TESTPOOL 47 48log_note "Verify '<dataset> <path>'" 49log_must $helper $fs $mntpoint 50log_must ismounted $fs 51force_unmount $fs 52 53log_note "Verify mount(8) does not canonicalize before calling helper" 54# Canonicalization is confused by files in PWD matching [device|mountpoint] 55log_must mkdir -p $TESTDIR/$$/$TESTPOOL 56log_must cd $TESTDIR/$$ 57# The env flag directs zfs to exec /bin/mount, which then calls helper 58log_must eval ZFS_MOUNT_HELPER=1 zfs $mountcmd -v $TESTPOOL 59# mount (2.35.2) still suffers from a cosmetic PWD prefix bug 60log_must mounted $TESTPOOL 61force_unmount $TESTPOOL 62 63log_note "Verify CWD prefix filter <dataset> <path>" 64log_must cd / 65log_must zfs set mountpoint=legacy $TESTPOOL 66log_must mkdir -p $mntpoint 67log_must mount -t zfs $TESTPOOL $mntpoint 68log_must ismounted $TESTPOOL 69log_must umount $mntpoint 70log_must zfs set mountpoint=$mntpoint $TESTPOOL 71log_must cd - 72force_unmount $TESTPOOL 73 74log_note "Verify '-f <dataset> <path>' fakemount" 75log_must $helper -f $fs $mntpoint 76log_mustnot ismounted $fs 77 78log_note "Verify '-o ro -v <dataset> <path>' verbose RO" 79log_must ${helper},ro -v $fs $mntpoint 80log_must ismounted $fs 81force_unmount $fs 82 83log_note "Verify '-o abc -s <device> <path>' sloppy option" 84log_must ${helper},abc -s ${vdevs[0]} $mntpoint 85log_must mounted $mntpoint 86force_unmount $TESTPOOL 87 88log_note "Verify '<device> <path>'" 89log_must $helper ${vdevs[0]} $mntpoint 90log_must mounted $mntpoint 91 92log_pass "zfs mount helper correctly handles both device and pool strings" 93