xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_011_neg.ksh (revision b6805bf78d2bbbeeaea8909a05623587b42d58b3)
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 http://www.opensolaris.org/os/licensing.
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 2007 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26#
27
28. $STF_SUITE/include/libtest.shlib
29
30#
31# DESCRIPTION:
32# Verify that zfs mount should fail with bad parameters
33#
34# STRATEGY:
35# 1. Make an array of bad parameters
36# 2. Use zfs mount to mount the filesystem
37# 3. Verify that zfs mount returns error
38#
39
40verify_runnable "both"
41
42function cleanup
43{
44	if snapexists $TESTPOOL/$TESTFS@$TESTSNAP; then
45		log_must $ZFS destroy $TESTPOOL/$TESTFS@$TESTSNAP
46	fi
47
48	if is_global_zone && datasetexists $TESTPOOL/$TESTVOL; then
49		log_must $ZFS destroy $TESTPOOL/$TESTVOL
50	fi
51}
52
53log_assert "zfs mount fails with bad parameters"
54log_onexit cleanup
55
56fs=$TESTPOOL/$TESTFS
57set -A badargs "A" "-A" "-" "-x" "-?" "=" "-o *" "-a"
58
59for arg in "${badargs[@]}"; do
60	log_mustnot eval "$ZFS mount $arg $fs >/dev/null 2>&1"
61done
62
63#verify that zfs mount fails with invalid dataset
64for opt in "-o abc" "-O"; do
65	log_mustnot eval "$ZFS mount $opt /$fs >/dev/null 2>&1"
66done
67
68#verify that zfs mount fails with volume and snapshot
69log_must $ZFS snapshot $TESTPOOL/$TESTFS@$TESTSNAP
70log_mustnot eval "$ZFS mount $TESTPOOL/$TESTFS@$TESTSNAP >/dev/null 2>&1"
71
72if is_global_zone; then
73	log_must $ZFS create -V 10m $TESTPOOL/$TESTVOL
74	log_mustnot eval "$ZFS mount $TESTPOOL/$TESTVOL >/dev/null 2>&1"
75fi
76
77log_pass "zfs mount fails with bad parameters as expected."
78