xref: /freebsd/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mount/mount_null_source.ksh (revision 22649d4dba730d46244fd2dff4fd174903c8379f)
1#!/bin/ksh -p
2# SPDX-License-Identifier: CDDL-1.0
3#
4# This file and its contents are supplied under the terms of the
5# Common Development and Distribution License ("CDDL"), version 1.0.
6# You may only use this file in accordance with the terms of version
7# 1.0 of the CDDL.
8#
9# A full copy of the text of the CDDL should have accompanied this
10# source.  A copy of the CDDL is also available via the Internet at
11# https://opensource.org/license/CDDL-1.0.
12#
13
14. $STF_SUITE/include/libtest.shlib
15
16#
17# DESCRIPTION:
18# Verify that mounting ZFS without a source fails with EINVAL.
19#
20# STRATEGY:
21# 1. Create an empty mountpoint.
22# 2. Issue mount(2) with a NULL source using mount_null_source.
23# 3. Verify that mount(2) returns EINVAL.
24#
25
26log_assert "Mounting ZFS without a source fails with EINVAL"
27
28typeset mountpoint="$TEST_BASE_DIR/null-source"
29
30function cleanup
31{
32	if mounted "$mountpoint"; then
33		log_must umount "$mountpoint"
34	fi
35	rm -rf "$mountpoint"
36}
37
38log_onexit cleanup
39log_must mkdir "$mountpoint"
40log_must mount_null_source "$mountpoint"
41
42log_pass "ZFS rejected a mount without a source"
43