1#!/bin/ksh -p
2#
3# This file and its contents are supplied under the terms of the
4# Common Development and Distribution License ("CDDL"), version 1.0.
5# You may only use this file in accordance with the terms of version
6# 1.0 of the CDDL.
7#
8# A full copy of the text of the CDDL should have accompanied this
9# source.  A copy of the CDDL is also available via the Internet at
10# http://www.illumos.org/license/CDDL.
11#
12
13#
14# Copyright (c) 2015 by Delphix. All rights reserved.
15#
16
17. $STF_SUITE/include/libtest.shlib
18
19#
20# DESCRIPTION:
21#   Verify that zfs mount succeeds with a non-empty directory
22#
23
24#
25# STRATEGY:
26# 1. Unmount the dataset
27# 2. Create a new empty directory
28# 3. Set the dataset's mountpoint
29# 4. Attempt to mount the dataset
30# 5. Verify the mount succeeds
31# 6. Unmount the dataset
32# 7. Create a file in the directory created in step 2
33# 8. Attempt to mount the dataset
34# 9. Verify the mount succeeds
35#
36
37verify_runnable "both"
38
39log_assert "zfs mount succeeds with non-empty directory"
40
41fs=$TESTPOOL/$TESTFS
42
43log_must zfs umount $fs
44log_must mkdir -p $TESTDIR
45log_must zfs set mountpoint=$TESTDIR $fs
46log_must zfs mount $fs
47log_must zfs umount $fs
48log_must touch $TESTDIR/testfile.$$
49log_must zfs mount $fs
50log_must zfs umount $fs
51log_must rm -rf $TESTDIR
52
53log_pass "zfs mount succeeds with non-empty directory as expected."
54