]>
Commit | Line | Data |
---|---|---|
6bb24f4d BB |
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 | ||
c1d9abf9 JWK |
28 | # |
29 | # Copyright (c) 2016 by Delphix. All rights reserved. | |
30 | # | |
31 | ||
6bb24f4d BB |
32 | . $STF_SUITE/include/libtest.shlib |
33 | . $STF_SUITE/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib | |
34 | ||
35 | # | |
36 | # DESCRIPTION: | |
37 | # Invoke "zfs mount <filesystem>" with a filesystem | |
38 | # which mountpoint be the identical or the top of an existing one, | |
39 | # it will fail with a return code of 1 | |
40 | # | |
41 | # STRATEGY: | |
42 | # 1. Prepare an existing mounted filesystem. | |
43 | # 2. Setup a new filesystem and make sure that it is unmounted. | |
44 | # 3. Mount the new filesystem using the various combinations | |
45 | # - zfs set mountpoint=<identical path> <filesystem> | |
46 | # - zfs set mountpoint=<top path> <filesystem> | |
47 | # 4. Verify that mount failed with return code of 1. | |
48 | # | |
49 | ||
50 | verify_runnable "both" | |
51 | ||
e4a3297a BB |
52 | # See issue: https://github.com/zfsonlinux/zfs/issues/4990 |
53 | if is_linux; then | |
54 | log_unsupported "Test case needs to be updated" | |
55 | fi | |
56 | ||
6bb24f4d BB |
57 | function cleanup |
58 | { | |
59 | log_must force_unmount $TESTPOOL/$TESTFS | |
60 | ||
61 | datasetexists $TESTPOOL/$TESTFS1 && \ | |
62 | cleanup_filesystem $TESTPOOL $TESTFS1 | |
63 | ||
64 | [[ -d $TESTDIR ]] && \ | |
c1d9abf9 JWK |
65 | log_must rm -rf $TESTDIR |
66 | log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS | |
6bb24f4d BB |
67 | log_must force_unmount $TESTPOOL/$TESTFS |
68 | ||
69 | return 0 | |
70 | } | |
71 | ||
72 | typeset -i ret=0 | |
73 | ||
c1d9abf9 | 74 | log_assert "Verify that 'zfs $mountcmd <filesystem>' " \ |
6bb24f4d BB |
75 | "which mountpoint be the identical or the top of an existing one " \ |
76 | "will fail with return code 1." | |
77 | ||
78 | log_onexit cleanup | |
79 | ||
80 | unmounted $TESTPOOL/$TESTFS || \ | |
81 | log_must force_unmount $TESTPOOL/$TESTFS | |
82 | ||
83 | [[ -d $TESTDIR ]] && \ | |
c1d9abf9 | 84 | log_must rm -rf $TESTDIR |
6bb24f4d BB |
85 | |
86 | typeset -i MAXDEPTH=3 | |
87 | typeset -i depth=0 | |
88 | typeset mtpt=$TESTDIR | |
89 | ||
90 | while (( depth < MAXDEPTH )); do | |
91 | mtpt=$mtpt/$depth | |
92 | (( depth = depth + 1)) | |
93 | done | |
94 | ||
c1d9abf9 JWK |
95 | log_must zfs set mountpoint=$mtpt $TESTPOOL/$TESTFS |
96 | log_must zfs $mountcmd $TESTPOOL/$TESTFS | |
6bb24f4d BB |
97 | |
98 | mounted $TESTPOOL/$TESTFS || \ | |
99 | log_unresolved "Filesystem $TESTPOOL/$TESTFS is unmounted" | |
100 | ||
c1d9abf9 | 101 | log_must zfs create $TESTPOOL/$TESTFS1 |
6bb24f4d BB |
102 | |
103 | unmounted $TESTPOOL/$TESTFS1 || \ | |
104 | log_must force_unmount $TESTPOOL/$TESTFS1 | |
105 | ||
106 | while [[ -n $mtpt ]] ; do | |
107 | (( depth == MAXDEPTH )) && \ | |
c1d9abf9 | 108 | log_note "Verify that 'zfs $mountcmd <filesystem>' " \ |
6bb24f4d BB |
109 | "which mountpoint be the identical of an existing one " \ |
110 | "will fail with return code 1." | |
111 | ||
c1d9abf9 JWK |
112 | log_must zfs set mountpoint=$mtpt $TESTPOOL/$TESTFS1 |
113 | log_mustnot zfs $mountcmd $TESTPOOL/$TESTFS1 | |
6bb24f4d BB |
114 | |
115 | unmounted $TESTPOOL/$TESTFS1 || \ | |
116 | log_fail "Filesystem $TESTPOOL/$TESTFS1 is mounted." | |
117 | ||
118 | mtpt=${mtpt%/*} | |
119 | ||
120 | (( depth == MAXDEPTH )) && \ | |
c1d9abf9 | 121 | log_note "Verify that 'zfs $mountcmd <filesystem>' " \ |
6bb24f4d BB |
122 | "which mountpoint be the top of an existing one " \ |
123 | "will fail with return code 1." | |
124 | (( depth = depth - 1 )) | |
125 | done | |
126 | ||
c1d9abf9 | 127 | log_pass "'zfs $mountcmd <filesystem>' " \ |
6bb24f4d BB |
128 | "which mountpoint be the identical or the top of an existing one " \ |
129 | "will fail with return code 1." |