author | Rich Morris <Richard.Morris@Sun.COM> |
Wed, 10 Sep 2008 10:59:12 -0400 | |
changeset 7538 | 18c2451107fd |
parent 7366 | 33de5956afbb |
child 8228 | 51e9ca9ee3a5 |
permissions | -rw-r--r-- |
789 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
1544 | 5 |
* Common Development and Distribution License (the "License"). |
6 |
* You may not use this file except in compliance with the License. |
|
789 | 7 |
* |
8 |
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 |
* or http://www.opensolaris.org/os/licensing. |
|
10 |
* See the License for the specific language governing permissions |
|
11 |
* and limitations under the License. |
|
12 |
* |
|
13 |
* When distributing Covered Code, include this CDDL HEADER in each |
|
14 |
* file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 |
* If applicable, add the following below this CDDL HEADER, with the |
|
16 |
* fields enclosed by brackets "[]" replaced with your own identifying |
|
17 |
* information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 |
* |
|
19 |
* CDDL HEADER END |
|
20 |
*/ |
|
3126 | 21 |
|
789 | 22 |
/* |
5951
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
23 |
* Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
789 | 24 |
* Use is subject to license terms. |
25 |
*/ |
|
26 |
||
27 |
/* |
|
28 |
* Routines to manage ZFS mounts. We separate all the nasty routines that have |
|
3126 | 29 |
* to deal with the OS. The following functions are the main entry points -- |
30 |
* they are used by mount and unmount and when changing a filesystem's |
|
31 |
* mountpoint. |
|
789 | 32 |
* |
33 |
* zfs_is_mounted() |
|
34 |
* zfs_mount() |
|
35 |
* zfs_unmount() |
|
36 |
* zfs_unmountall() |
|
37 |
* |
|
3126 | 38 |
* This file also contains the functions used to manage sharing filesystems via |
39 |
* NFS and iSCSI: |
|
789 | 40 |
* |
41 |
* zfs_is_shared() |
|
42 |
* zfs_share() |
|
43 |
* zfs_unshare() |
|
3126 | 44 |
* |
45 |
* zfs_is_shared_nfs() |
|
5331 | 46 |
* zfs_is_shared_smb() |
47 |
* zfs_is_shared_iscsi() |
|
48 |
* zfs_share_proto() |
|
49 |
* zfs_shareall(); |
|
50 |
* zfs_share_iscsi() |
|
3126 | 51 |
* zfs_unshare_nfs() |
5331 | 52 |
* zfs_unshare_smb() |
3126 | 53 |
* zfs_unshareall_nfs() |
5331 | 54 |
* zfs_unshareall_smb() |
55 |
* zfs_unshareall() |
|
56 |
* zfs_unshareall_bypath() |
|
3126 | 57 |
* zfs_unshare_iscsi() |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
58 |
* |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
59 |
* The following functions are available for pool consumers, and will |
3126 | 60 |
* mount/unmount and share/unshare all datasets within pool: |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
61 |
* |
3126 | 62 |
* zpool_enable_datasets() |
63 |
* zpool_disable_datasets() |
|
789 | 64 |
*/ |
65 |
||
66 |
#include <dirent.h> |
|
3134
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
67 |
#include <dlfcn.h> |
789 | 68 |
#include <errno.h> |
69 |
#include <libgen.h> |
|
70 |
#include <libintl.h> |
|
71 |
#include <stdio.h> |
|
72 |
#include <stdlib.h> |
|
73 |
#include <strings.h> |
|
74 |
#include <unistd.h> |
|
75 |
#include <zone.h> |
|
76 |
#include <sys/mntent.h> |
|
77 |
#include <sys/mnttab.h> |
|
78 |
#include <sys/mount.h> |
|
79 |
#include <sys/stat.h> |
|
80 |
||
81 |
#include <libzfs.h> |
|
82 |
||
83 |
#include "libzfs_impl.h" |
|
84 |
||
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
85 |
#include <libshare.h> |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
86 |
#include <sys/systeminfo.h> |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
87 |
#define MAXISALEN 257 /* based on sysinfo(2) man page */ |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
88 |
|
5331 | 89 |
static int zfs_share_proto(zfs_handle_t *, zfs_share_proto_t *); |
90 |
zfs_share_type_t zfs_is_shared_proto(zfs_handle_t *, char **, |
|
91 |
zfs_share_proto_t); |
|
92 |
||
3134
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
93 |
static int (*iscsitgt_zfs_share)(const char *); |
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
94 |
static int (*iscsitgt_zfs_unshare)(const char *); |
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
95 |
static int (*iscsitgt_zfs_is_shared)(const char *); |
4543 | 96 |
static int (*iscsitgt_svc_online)(); |
3134
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
97 |
|
5331 | 98 |
/* |
99 |
* The share protocols table must be in the same order as the zfs_share_prot_t |
|
100 |
* enum in libzfs_impl.h |
|
101 |
*/ |
|
102 |
typedef struct { |
|
103 |
zfs_prop_t p_prop; |
|
104 |
char *p_name; |
|
105 |
int p_share_err; |
|
106 |
int p_unshare_err; |
|
107 |
} proto_table_t; |
|
108 |
||
109 |
proto_table_t proto_table[PROTO_END] = { |
|
110 |
{ZFS_PROP_SHARENFS, "nfs", EZFS_SHARENFSFAILED, EZFS_UNSHARENFSFAILED}, |
|
111 |
{ZFS_PROP_SHARESMB, "smb", EZFS_SHARESMBFAILED, EZFS_UNSHARESMBFAILED}, |
|
112 |
}; |
|
113 |
||
114 |
zfs_share_proto_t nfs_only[] = { |
|
115 |
PROTO_NFS, |
|
116 |
PROTO_END |
|
117 |
}; |
|
118 |
||
119 |
zfs_share_proto_t smb_only[] = { |
|
120 |
PROTO_SMB, |
|
121 |
PROTO_END |
|
122 |
}; |
|
123 |
zfs_share_proto_t share_all_proto[] = { |
|
124 |
PROTO_NFS, |
|
125 |
PROTO_SMB, |
|
126 |
PROTO_END |
|
127 |
}; |
|
128 |
||
3134
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
129 |
#pragma init(zfs_iscsi_init) |
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
130 |
static void |
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
131 |
zfs_iscsi_init(void) |
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
132 |
{ |
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
133 |
void *libiscsitgt; |
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
134 |
|
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
135 |
if ((libiscsitgt = dlopen("/lib/libiscsitgt.so.1", |
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
136 |
RTLD_LAZY | RTLD_GLOBAL)) == NULL || |
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
137 |
(iscsitgt_zfs_share = (int (*)(const char *))dlsym(libiscsitgt, |
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
138 |
"iscsitgt_zfs_share")) == NULL || |
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
139 |
(iscsitgt_zfs_unshare = (int (*)(const char *))dlsym(libiscsitgt, |
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
140 |
"iscsitgt_zfs_unshare")) == NULL || |
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
141 |
(iscsitgt_zfs_is_shared = (int (*)(const char *))dlsym(libiscsitgt, |
4543 | 142 |
"iscsitgt_zfs_is_shared")) == NULL || |
143 |
(iscsitgt_svc_online = (int (*)(const char *))dlsym(libiscsitgt, |
|
144 |
"iscsitgt_svc_online")) == NULL) { |
|
3134
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
145 |
iscsitgt_zfs_share = NULL; |
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
146 |
iscsitgt_zfs_unshare = NULL; |
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
147 |
iscsitgt_zfs_is_shared = NULL; |
4543 | 148 |
iscsitgt_svc_online = NULL; |
3134
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
149 |
} |
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
150 |
} |
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
151 |
|
789 | 152 |
/* |
5331 | 153 |
* Search the sharetab for the given mountpoint and protocol, returning |
154 |
* a zfs_share_type_t value. |
|
789 | 155 |
*/ |
5331 | 156 |
static zfs_share_type_t |
157 |
is_shared(libzfs_handle_t *hdl, const char *mountpoint, zfs_share_proto_t proto) |
|
789 | 158 |
{ |
159 |
char buf[MAXPATHLEN], *tab; |
|
5331 | 160 |
char *ptr; |
789 | 161 |
|
2082 | 162 |
if (hdl->libzfs_sharetab == NULL) |
5331 | 163 |
return (SHARED_NOT_SHARED); |
789 | 164 |
|
2082 | 165 |
(void) fseek(hdl->libzfs_sharetab, 0, SEEK_SET); |
789 | 166 |
|
2082 | 167 |
while (fgets(buf, sizeof (buf), hdl->libzfs_sharetab) != NULL) { |
789 | 168 |
|
169 |
/* the mountpoint is the first entry on each line */ |
|
5331 | 170 |
if ((tab = strchr(buf, '\t')) == NULL) |
171 |
continue; |
|
172 |
||
173 |
*tab = '\0'; |
|
174 |
if (strcmp(buf, mountpoint) == 0) { |
|
175 |
/* |
|
176 |
* the protocol field is the third field |
|
177 |
* skip over second field |
|
178 |
*/ |
|
179 |
ptr = ++tab; |
|
180 |
if ((tab = strchr(ptr, '\t')) == NULL) |
|
181 |
continue; |
|
182 |
ptr = ++tab; |
|
183 |
if ((tab = strchr(ptr, '\t')) == NULL) |
|
184 |
continue; |
|
789 | 185 |
*tab = '\0'; |
5331 | 186 |
if (strcmp(ptr, |
187 |
proto_table[proto].p_name) == 0) { |
|
188 |
switch (proto) { |
|
189 |
case PROTO_NFS: |
|
190 |
return (SHARED_NFS); |
|
191 |
case PROTO_SMB: |
|
192 |
return (SHARED_SMB); |
|
193 |
default: |
|
194 |
return (0); |
|
195 |
} |
|
196 |
} |
|
789 | 197 |
} |
198 |
} |
|
199 |
||
5331 | 200 |
return (SHARED_NOT_SHARED); |
789 | 201 |
} |
202 |
||
203 |
/* |
|
2082 | 204 |
* Returns true if the specified directory is empty. If we can't open the |
205 |
* directory at all, return true so that the mount can fail with a more |
|
789 | 206 |
* informative error message. |
207 |
*/ |
|
2082 | 208 |
static boolean_t |
789 | 209 |
dir_is_empty(const char *dirname) |
210 |
{ |
|
211 |
DIR *dirp; |
|
212 |
struct dirent64 *dp; |
|
213 |
||
214 |
if ((dirp = opendir(dirname)) == NULL) |
|
2082 | 215 |
return (B_TRUE); |
789 | 216 |
|
217 |
while ((dp = readdir64(dirp)) != NULL) { |
|
218 |
||
219 |
if (strcmp(dp->d_name, ".") == 0 || |
|
220 |
strcmp(dp->d_name, "..") == 0) |
|
221 |
continue; |
|
222 |
||
223 |
(void) closedir(dirp); |
|
2082 | 224 |
return (B_FALSE); |
789 | 225 |
} |
226 |
||
227 |
(void) closedir(dirp); |
|
2082 | 228 |
return (B_TRUE); |
789 | 229 |
} |
230 |
||
231 |
/* |
|
232 |
* Checks to see if the mount is active. If the filesystem is mounted, we fill |
|
233 |
* in 'where' with the current mountpoint, and return 1. Otherwise, we return |
|
234 |
* 0. |
|
235 |
*/ |
|
2082 | 236 |
boolean_t |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3380
diff
changeset
|
237 |
is_mounted(libzfs_handle_t *zfs_hdl, const char *special, char **where) |
789 | 238 |
{ |
239 |
struct mnttab search = { 0 }, entry; |
|
240 |
||
241 |
/* |
|
242 |
* Search for the entry in /etc/mnttab. We don't bother getting the |
|
243 |
* mountpoint, as we can just search for the special device. This will |
|
244 |
* also let us find mounts when the mountpoint is 'legacy'. |
|
245 |
*/ |
|
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3380
diff
changeset
|
246 |
search.mnt_special = (char *)special; |
1407
f178d5f7681f
6381720 zfs_unmount() not checking fstype in /etc/mnttab
nd150628
parents:
1371
diff
changeset
|
247 |
search.mnt_fstype = MNTTYPE_ZFS; |
789 | 248 |
|
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3380
diff
changeset
|
249 |
rewind(zfs_hdl->libzfs_mnttab); |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3380
diff
changeset
|
250 |
if (getmntany(zfs_hdl->libzfs_mnttab, &entry, &search) != 0) |
2082 | 251 |
return (B_FALSE); |
789 | 252 |
|
253 |
if (where != NULL) |
|
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3380
diff
changeset
|
254 |
*where = zfs_strdup(zfs_hdl, entry.mnt_mountp); |
789 | 255 |
|
2082 | 256 |
return (B_TRUE); |
789 | 257 |
} |
258 |
||
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3380
diff
changeset
|
259 |
boolean_t |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3380
diff
changeset
|
260 |
zfs_is_mounted(zfs_handle_t *zhp, char **where) |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3380
diff
changeset
|
261 |
{ |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3380
diff
changeset
|
262 |
return (is_mounted(zhp->zfs_hdl, zfs_get_name(zhp), where)); |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3380
diff
changeset
|
263 |
} |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3380
diff
changeset
|
264 |
|
789 | 265 |
/* |
2676 | 266 |
* Returns true if the given dataset is mountable, false otherwise. Returns the |
267 |
* mountpoint in 'buf'. |
|
268 |
*/ |
|
269 |
static boolean_t |
|
270 |
zfs_is_mountable(zfs_handle_t *zhp, char *buf, size_t buflen, |
|
5094 | 271 |
zprop_source_t *source) |
2676 | 272 |
{ |
273 |
char sourceloc[ZFS_MAXNAMELEN]; |
|
5094 | 274 |
zprop_source_t sourcetype; |
2676 | 275 |
|
276 |
if (!zfs_prop_valid_for_type(ZFS_PROP_MOUNTPOINT, zhp->zfs_type)) |
|
277 |
return (B_FALSE); |
|
278 |
||
279 |
verify(zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, buf, buflen, |
|
280 |
&sourcetype, sourceloc, sizeof (sourceloc), B_FALSE) == 0); |
|
281 |
||
282 |
if (strcmp(buf, ZFS_MOUNTPOINT_NONE) == 0 || |
|
283 |
strcmp(buf, ZFS_MOUNTPOINT_LEGACY) == 0) |
|
284 |
return (B_FALSE); |
|
285 |
||
6168
51c045dcc498
PSARC 2008/168 Support for ZFS property value canmount=noauto
hs24103
parents:
6027
diff
changeset
|
286 |
if (zfs_prop_get_int(zhp, ZFS_PROP_CANMOUNT) == ZFS_CANMOUNT_OFF) |
2676 | 287 |
return (B_FALSE); |
288 |
||
289 |
if (zfs_prop_get_int(zhp, ZFS_PROP_ZONED) && |
|
290 |
getzoneid() == GLOBAL_ZONEID) |
|
291 |
return (B_FALSE); |
|
292 |
||
293 |
if (source) |
|
294 |
*source = sourcetype; |
|
295 |
||
296 |
return (B_TRUE); |
|
297 |
} |
|
298 |
||
299 |
/* |
|
789 | 300 |
* Mount the given filesystem. |
301 |
*/ |
|
302 |
int |
|
303 |
zfs_mount(zfs_handle_t *zhp, const char *options, int flags) |
|
304 |
{ |
|
305 |
struct stat buf; |
|
306 |
char mountpoint[ZFS_MAXPROPLEN]; |
|
307 |
char mntopts[MNT_LINE_MAX]; |
|
2082 | 308 |
libzfs_handle_t *hdl = zhp->zfs_hdl; |
789 | 309 |
|
310 |
if (options == NULL) |
|
311 |
mntopts[0] = '\0'; |
|
312 |
else |
|
313 |
(void) strlcpy(mntopts, options, sizeof (mntopts)); |
|
314 |
||
2676 | 315 |
if (!zfs_is_mountable(zhp, mountpoint, sizeof (mountpoint), NULL)) |
2082 | 316 |
return (0); |
789 | 317 |
|
318 |
/* Create the directory if it doesn't already exist */ |
|
319 |
if (lstat(mountpoint, &buf) != 0) { |
|
320 |
if (mkdirp(mountpoint, 0755) != 0) { |
|
2082 | 321 |
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, |
322 |
"failed to create mountpoint")); |
|
3237
98d0c28f2f5e
6480245 renaming a dataset to something with '%s' will cause segfault
lling
parents:
3134
diff
changeset
|
323 |
return (zfs_error_fmt(hdl, EZFS_MOUNTFAILED, |
2082 | 324 |
dgettext(TEXT_DOMAIN, "cannot mount '%s'"), |
325 |
mountpoint)); |
|
789 | 326 |
} |
327 |
} |
|
328 |
||
329 |
/* |
|
330 |
* Determine if the mountpoint is empty. If so, refuse to perform the |
|
331 |
* mount. We don't perform this check if MS_OVERLAY is specified, which |
|
332 |
* would defeat the point. We also avoid this check if 'remount' is |
|
333 |
* specified. |
|
334 |
*/ |
|
335 |
if ((flags & MS_OVERLAY) == 0 && |
|
336 |
strstr(mntopts, MNTOPT_REMOUNT) == NULL && |
|
337 |
!dir_is_empty(mountpoint)) { |
|
2082 | 338 |
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, |
339 |
"directory is not empty")); |
|
3237
98d0c28f2f5e
6480245 renaming a dataset to something with '%s' will cause segfault
lling
parents:
3134
diff
changeset
|
340 |
return (zfs_error_fmt(hdl, EZFS_MOUNTFAILED, |
2082 | 341 |
dgettext(TEXT_DOMAIN, "cannot mount '%s'"), mountpoint)); |
789 | 342 |
} |
343 |
||
344 |
/* perform the mount */ |
|
345 |
if (mount(zfs_get_name(zhp), mountpoint, MS_OPTIONSTR | flags, |
|
346 |
MNTTYPE_ZFS, NULL, 0, mntopts, sizeof (mntopts)) != 0) { |
|
347 |
/* |
|
348 |
* Generic errors are nasty, but there are just way too many |
|
349 |
* from mount(), and they're well-understood. We pick a few |
|
350 |
* common ones to improve upon. |
|
351 |
*/ |
|
4302 | 352 |
if (errno == EBUSY) { |
2082 | 353 |
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, |
354 |
"mountpoint or dataset is busy")); |
|
4543 | 355 |
} else if (errno == EPERM) { |
356 |
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, |
|
357 |
"Insufficient privileges")); |
|
4302 | 358 |
} else { |
2082 | 359 |
zfs_error_aux(hdl, strerror(errno)); |
4302 | 360 |
} |
2082 | 361 |
|
3237
98d0c28f2f5e
6480245 renaming a dataset to something with '%s' will cause segfault
lling
parents:
3134
diff
changeset
|
362 |
return (zfs_error_fmt(hdl, EZFS_MOUNTFAILED, |
2082 | 363 |
dgettext(TEXT_DOMAIN, "cannot mount '%s'"), |
364 |
zhp->zfs_name)); |
|
789 | 365 |
} |
366 |
||
367 |
return (0); |
|
368 |
} |
|
369 |
||
370 |
/* |
|
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
371 |
* Unmount a single filesystem. |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
372 |
*/ |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
373 |
static int |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
374 |
unmount_one(libzfs_handle_t *hdl, const char *mountpoint, int flags) |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
375 |
{ |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
376 |
if (umount2(mountpoint, flags) != 0) { |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
377 |
zfs_error_aux(hdl, strerror(errno)); |
3237
98d0c28f2f5e
6480245 renaming a dataset to something with '%s' will cause segfault
lling
parents:
3134
diff
changeset
|
378 |
return (zfs_error_fmt(hdl, EZFS_UMOUNTFAILED, |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
379 |
dgettext(TEXT_DOMAIN, "cannot unmount '%s'"), |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
380 |
mountpoint)); |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
381 |
} |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
382 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
383 |
return (0); |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
384 |
} |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
385 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
386 |
/* |
789 | 387 |
* Unmount the given filesystem. |
388 |
*/ |
|
389 |
int |
|
390 |
zfs_unmount(zfs_handle_t *zhp, const char *mountpoint, int flags) |
|
391 |
{ |
|
392 |
struct mnttab search = { 0 }, entry; |
|
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
393 |
char *mntpt = NULL; |
789 | 394 |
|
395 |
/* check to see if need to unmount the filesystem */ |
|
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
396 |
search.mnt_special = zhp->zfs_name; |
1407
f178d5f7681f
6381720 zfs_unmount() not checking fstype in /etc/mnttab
nd150628
parents:
1371
diff
changeset
|
397 |
search.mnt_fstype = MNTTYPE_ZFS; |
2082 | 398 |
rewind(zhp->zfs_hdl->libzfs_mnttab); |
789 | 399 |
if (mountpoint != NULL || ((zfs_get_type(zhp) == ZFS_TYPE_FILESYSTEM) && |
2082 | 400 |
getmntany(zhp->zfs_hdl->libzfs_mnttab, &entry, &search) == 0)) { |
789 | 401 |
|
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
402 |
/* |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
403 |
* mountpoint may have come from a call to |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
404 |
* getmnt/getmntany if it isn't NULL. If it is NULL, |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
405 |
* we know it comes from getmntany which can then get |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
406 |
* overwritten later. We strdup it to play it safe. |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
407 |
*/ |
789 | 408 |
if (mountpoint == NULL) |
4302 | 409 |
mntpt = zfs_strdup(zhp->zfs_hdl, entry.mnt_mountp); |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
410 |
else |
4302 | 411 |
mntpt = zfs_strdup(zhp->zfs_hdl, mountpoint); |
789 | 412 |
|
413 |
/* |
|
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
414 |
* Unshare and unmount the filesystem |
789 | 415 |
*/ |
5331 | 416 |
if (zfs_unshare_proto(zhp, mntpt, share_all_proto) != 0) |
4331
f784727d3d6a
6537472 If zfs unmount fails it leaves the file system unshared.
th199096
parents:
4327
diff
changeset
|
417 |
return (-1); |
f784727d3d6a
6537472 If zfs unmount fails it leaves the file system unshared.
th199096
parents:
4327
diff
changeset
|
418 |
|
f784727d3d6a
6537472 If zfs unmount fails it leaves the file system unshared.
th199096
parents:
4327
diff
changeset
|
419 |
if (unmount_one(zhp->zfs_hdl, mntpt, flags) != 0) { |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
420 |
free(mntpt); |
5331 | 421 |
(void) zfs_shareall(zhp); |
789 | 422 |
return (-1); |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
423 |
} |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
424 |
free(mntpt); |
789 | 425 |
} |
426 |
||
427 |
return (0); |
|
428 |
} |
|
429 |
||
430 |
/* |
|
431 |
* Unmount this filesystem and any children inheriting the mountpoint property. |
|
432 |
* To do this, just act like we're changing the mountpoint property, but don't |
|
433 |
* remount the filesystems afterwards. |
|
434 |
*/ |
|
435 |
int |
|
436 |
zfs_unmountall(zfs_handle_t *zhp, int flags) |
|
437 |
{ |
|
438 |
prop_changelist_t *clp; |
|
439 |
int ret; |
|
440 |
||
7366
33de5956afbb
6678308 zfs receive dumps core when -n is used, fails on replication stream
Tim Haley <Tim.Haley@Sun.COM>
parents:
6168
diff
changeset
|
441 |
clp = changelist_gather(zhp, ZFS_PROP_MOUNTPOINT, 0, flags); |
789 | 442 |
if (clp == NULL) |
443 |
return (-1); |
|
444 |
||
445 |
ret = changelist_prefix(clp); |
|
446 |
changelist_free(clp); |
|
447 |
||
448 |
return (ret); |
|
449 |
} |
|
450 |
||
3126 | 451 |
boolean_t |
452 |
zfs_is_shared(zfs_handle_t *zhp) |
|
453 |
{ |
|
5331 | 454 |
zfs_share_type_t rc = 0; |
455 |
zfs_share_proto_t *curr_proto; |
|
456 |
||
3126 | 457 |
if (ZFS_IS_VOLUME(zhp)) |
458 |
return (zfs_is_shared_iscsi(zhp)); |
|
459 |
||
5331 | 460 |
for (curr_proto = share_all_proto; *curr_proto != PROTO_END; |
461 |
curr_proto++) |
|
462 |
rc |= zfs_is_shared_proto(zhp, NULL, *curr_proto); |
|
463 |
||
464 |
return (rc ? B_TRUE : B_FALSE); |
|
3126 | 465 |
} |
466 |
||
467 |
int |
|
468 |
zfs_share(zfs_handle_t *zhp) |
|
469 |
{ |
|
470 |
if (ZFS_IS_VOLUME(zhp)) |
|
471 |
return (zfs_share_iscsi(zhp)); |
|
472 |
||
5331 | 473 |
return (zfs_share_proto(zhp, share_all_proto)); |
3126 | 474 |
} |
475 |
||
476 |
int |
|
477 |
zfs_unshare(zfs_handle_t *zhp) |
|
478 |
{ |
|
479 |
if (ZFS_IS_VOLUME(zhp)) |
|
480 |
return (zfs_unshare_iscsi(zhp)); |
|
481 |
||
5331 | 482 |
return (zfs_unshareall(zhp)); |
3126 | 483 |
} |
484 |
||
789 | 485 |
/* |
486 |
* Check to see if the filesystem is currently shared. |
|
487 |
*/ |
|
5331 | 488 |
zfs_share_type_t |
489 |
zfs_is_shared_proto(zfs_handle_t *zhp, char **where, zfs_share_proto_t proto) |
|
789 | 490 |
{ |
491 |
char *mountpoint; |
|
5331 | 492 |
zfs_share_type_t rc; |
789 | 493 |
|
494 |
if (!zfs_is_mounted(zhp, &mountpoint)) |
|
5331 | 495 |
return (SHARED_NOT_SHARED); |
789 | 496 |
|
5331 | 497 |
if (rc = is_shared(zhp->zfs_hdl, mountpoint, proto)) { |
789 | 498 |
if (where != NULL) |
499 |
*where = mountpoint; |
|
500 |
else |
|
501 |
free(mountpoint); |
|
5331 | 502 |
return (rc); |
789 | 503 |
} else { |
504 |
free(mountpoint); |
|
5331 | 505 |
return (SHARED_NOT_SHARED); |
789 | 506 |
} |
507 |
} |
|
508 |
||
5331 | 509 |
boolean_t |
510 |
zfs_is_shared_nfs(zfs_handle_t *zhp, char **where) |
|
511 |
{ |
|
512 |
return (zfs_is_shared_proto(zhp, where, |
|
513 |
PROTO_NFS) != SHARED_NOT_SHARED); |
|
514 |
} |
|
515 |
||
516 |
boolean_t |
|
517 |
zfs_is_shared_smb(zfs_handle_t *zhp, char **where) |
|
518 |
{ |
|
519 |
return (zfs_is_shared_proto(zhp, where, |
|
520 |
PROTO_SMB) != SHARED_NOT_SHARED); |
|
521 |
} |
|
522 |
||
789 | 523 |
/* |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
524 |
* Make sure things will work if libshare isn't installed by using |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
525 |
* wrapper functions that check to see that the pointers to functions |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
526 |
* initialized in _zfs_init_libshare() are actually present. |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
527 |
*/ |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
528 |
|
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
529 |
static sa_handle_t (*_sa_init)(int); |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
530 |
static void (*_sa_fini)(sa_handle_t); |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
531 |
static sa_share_t (*_sa_find_share)(sa_handle_t, char *); |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
532 |
static int (*_sa_enable_share)(sa_share_t, char *); |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
533 |
static int (*_sa_disable_share)(sa_share_t, char *); |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
534 |
static char *(*_sa_errorstr)(int); |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
535 |
static int (*_sa_parse_legacy_options)(sa_group_t, char *, char *); |
5951
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
536 |
static boolean_t (*_sa_needs_refresh)(sa_handle_t *); |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
537 |
static libzfs_handle_t *(*_sa_get_zfs_handle)(sa_handle_t); |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
538 |
static int (*_sa_zfs_process_share)(sa_handle_t, sa_group_t, sa_share_t, |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
539 |
char *, char *, zprop_source_t, char *, char *, char *); |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
540 |
static void (*_sa_update_sharetab_ts)(sa_handle_t); |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
541 |
|
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
542 |
/* |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
543 |
* _zfs_init_libshare() |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
544 |
* |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
545 |
* Find the libshare.so.1 entry points that we use here and save the |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
546 |
* values to be used later. This is triggered by the runtime loader. |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
547 |
* Make sure the correct ISA version is loaded. |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
548 |
*/ |
5951
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
549 |
|
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
550 |
#pragma init(_zfs_init_libshare) |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
551 |
static void |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
552 |
_zfs_init_libshare(void) |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
553 |
{ |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
554 |
void *libshare; |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
555 |
char path[MAXPATHLEN]; |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
556 |
char isa[MAXISALEN]; |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
557 |
|
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
558 |
#if defined(_LP64) |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
559 |
if (sysinfo(SI_ARCHITECTURE_64, isa, MAXISALEN) == -1) |
4302 | 560 |
isa[0] = '\0'; |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
561 |
#else |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
562 |
isa[0] = '\0'; |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
563 |
#endif |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
564 |
(void) snprintf(path, MAXPATHLEN, |
4302 | 565 |
"/usr/lib/%s/libshare.so.1", isa); |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
566 |
|
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
567 |
if ((libshare = dlopen(path, RTLD_LAZY | RTLD_GLOBAL)) != NULL) { |
4302 | 568 |
_sa_init = (sa_handle_t (*)(int))dlsym(libshare, "sa_init"); |
569 |
_sa_fini = (void (*)(sa_handle_t))dlsym(libshare, "sa_fini"); |
|
570 |
_sa_find_share = (sa_share_t (*)(sa_handle_t, char *)) |
|
571 |
dlsym(libshare, "sa_find_share"); |
|
572 |
_sa_enable_share = (int (*)(sa_share_t, char *))dlsym(libshare, |
|
573 |
"sa_enable_share"); |
|
574 |
_sa_disable_share = (int (*)(sa_share_t, char *))dlsym(libshare, |
|
575 |
"sa_disable_share"); |
|
576 |
_sa_errorstr = (char *(*)(int))dlsym(libshare, "sa_errorstr"); |
|
577 |
_sa_parse_legacy_options = (int (*)(sa_group_t, char *, char *)) |
|
578 |
dlsym(libshare, "sa_parse_legacy_options"); |
|
5951
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
579 |
_sa_needs_refresh = (boolean_t (*)(sa_handle_t *)) |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
580 |
dlsym(libshare, "sa_needs_refresh"); |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
581 |
_sa_get_zfs_handle = (libzfs_handle_t *(*)(sa_handle_t)) |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
582 |
dlsym(libshare, "sa_get_zfs_handle"); |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
583 |
_sa_zfs_process_share = (int (*)(sa_handle_t, sa_group_t, |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
584 |
sa_share_t, char *, char *, zprop_source_t, char *, |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
585 |
char *, char *))dlsym(libshare, "sa_zfs_process_share"); |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
586 |
_sa_update_sharetab_ts = (void (*)(sa_handle_t)) |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
587 |
dlsym(libshare, "sa_update_sharetab_ts"); |
4327
4ca5d5f63ada
6556719 sharemgr: sa_zfs_init() dumps core on failure
dougm
parents:
4302
diff
changeset
|
588 |
if (_sa_init == NULL || _sa_fini == NULL || |
4ca5d5f63ada
6556719 sharemgr: sa_zfs_init() dumps core on failure
dougm
parents:
4302
diff
changeset
|
589 |
_sa_find_share == NULL || _sa_enable_share == NULL || |
4ca5d5f63ada
6556719 sharemgr: sa_zfs_init() dumps core on failure
dougm
parents:
4302
diff
changeset
|
590 |
_sa_disable_share == NULL || _sa_errorstr == NULL || |
5951
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
591 |
_sa_parse_legacy_options == NULL || |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
592 |
_sa_needs_refresh == NULL || _sa_get_zfs_handle == NULL || |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
593 |
_sa_zfs_process_share == NULL || |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
594 |
_sa_update_sharetab_ts == NULL) { |
4327
4ca5d5f63ada
6556719 sharemgr: sa_zfs_init() dumps core on failure
dougm
parents:
4302
diff
changeset
|
595 |
_sa_init = NULL; |
4ca5d5f63ada
6556719 sharemgr: sa_zfs_init() dumps core on failure
dougm
parents:
4302
diff
changeset
|
596 |
_sa_fini = NULL; |
4ca5d5f63ada
6556719 sharemgr: sa_zfs_init() dumps core on failure
dougm
parents:
4302
diff
changeset
|
597 |
_sa_disable_share = NULL; |
4ca5d5f63ada
6556719 sharemgr: sa_zfs_init() dumps core on failure
dougm
parents:
4302
diff
changeset
|
598 |
_sa_enable_share = NULL; |
4ca5d5f63ada
6556719 sharemgr: sa_zfs_init() dumps core on failure
dougm
parents:
4302
diff
changeset
|
599 |
_sa_errorstr = NULL; |
4ca5d5f63ada
6556719 sharemgr: sa_zfs_init() dumps core on failure
dougm
parents:
4302
diff
changeset
|
600 |
_sa_parse_legacy_options = NULL; |
4ca5d5f63ada
6556719 sharemgr: sa_zfs_init() dumps core on failure
dougm
parents:
4302
diff
changeset
|
601 |
(void) dlclose(libshare); |
5951
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
602 |
_sa_needs_refresh = NULL; |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
603 |
_sa_get_zfs_handle = NULL; |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
604 |
_sa_zfs_process_share = NULL; |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
605 |
_sa_update_sharetab_ts = NULL; |
4327
4ca5d5f63ada
6556719 sharemgr: sa_zfs_init() dumps core on failure
dougm
parents:
4302
diff
changeset
|
606 |
} |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
607 |
} |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
608 |
} |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
609 |
|
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
610 |
/* |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
611 |
* zfs_init_libshare(zhandle, service) |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
612 |
* |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
613 |
* Initialize the libshare API if it hasn't already been initialized. |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
614 |
* In all cases it returns 0 if it succeeded and an error if not. The |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
615 |
* service value is which part(s) of the API to initialize and is a |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
616 |
* direct map to the libshare sa_init(service) interface. |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
617 |
*/ |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
618 |
int |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
619 |
zfs_init_libshare(libzfs_handle_t *zhandle, int service) |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
620 |
{ |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
621 |
int ret = SA_OK; |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
622 |
|
4302 | 623 |
if (_sa_init == NULL) |
624 |
ret = SA_CONFIG_ERR; |
|
625 |
||
5951
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
626 |
if (ret == SA_OK && zhandle->libzfs_shareflags & ZFSSHARE_MISS) { |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
627 |
/* |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
628 |
* We had a cache miss. Most likely it is a new ZFS |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
629 |
* dataset that was just created. We want to make sure |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
630 |
* so check timestamps to see if a different process |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
631 |
* has updated any of the configuration. If there was |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
632 |
* some non-ZFS change, we need to re-initialize the |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
633 |
* internal cache. |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
634 |
*/ |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
635 |
zhandle->libzfs_shareflags &= ~ZFSSHARE_MISS; |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
636 |
if (_sa_needs_refresh != NULL && |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
637 |
_sa_needs_refresh(zhandle->libzfs_sharehdl)) { |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
638 |
zfs_uninit_libshare(zhandle); |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
639 |
zhandle->libzfs_sharehdl = _sa_init(service); |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
640 |
} |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
641 |
} |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
642 |
|
4302 | 643 |
if (ret == SA_OK && zhandle && zhandle->libzfs_sharehdl == NULL) |
644 |
zhandle->libzfs_sharehdl = _sa_init(service); |
|
645 |
||
646 |
if (ret == SA_OK && zhandle->libzfs_sharehdl == NULL) |
|
647 |
ret = SA_NO_MEMORY; |
|
648 |
||
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
649 |
return (ret); |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
650 |
} |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
651 |
|
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
652 |
/* |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
653 |
* zfs_uninit_libshare(zhandle) |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
654 |
* |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
655 |
* Uninitialize the libshare API if it hasn't already been |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
656 |
* uninitialized. It is OK to call multiple times. |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
657 |
*/ |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
658 |
void |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
659 |
zfs_uninit_libshare(libzfs_handle_t *zhandle) |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
660 |
{ |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
661 |
if (zhandle != NULL && zhandle->libzfs_sharehdl != NULL) { |
4302 | 662 |
if (_sa_fini != NULL) |
663 |
_sa_fini(zhandle->libzfs_sharehdl); |
|
664 |
zhandle->libzfs_sharehdl = NULL; |
|
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
665 |
} |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
666 |
} |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
667 |
|
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
668 |
/* |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
669 |
* zfs_parse_options(options, proto) |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
670 |
* |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
671 |
* Call the legacy parse interface to get the protocol specific |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
672 |
* options using the NULL arg to indicate that this is a "parse" only. |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
673 |
*/ |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
674 |
int |
5331 | 675 |
zfs_parse_options(char *options, zfs_share_proto_t proto) |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
676 |
{ |
5367 | 677 |
if (_sa_parse_legacy_options != NULL) { |
678 |
return (_sa_parse_legacy_options(NULL, options, |
|
679 |
proto_table[proto].p_name)); |
|
680 |
} |
|
681 |
return (SA_CONFIG_ERR); |
|
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
682 |
} |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
683 |
|
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
684 |
/* |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
685 |
* zfs_sa_find_share(handle, path) |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
686 |
* |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
687 |
* wrapper around sa_find_share to find a share path in the |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
688 |
* configuration. |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
689 |
*/ |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
690 |
static sa_share_t |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
691 |
zfs_sa_find_share(sa_handle_t handle, char *path) |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
692 |
{ |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
693 |
if (_sa_find_share != NULL) |
4302 | 694 |
return (_sa_find_share(handle, path)); |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
695 |
return (NULL); |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
696 |
} |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
697 |
|
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
698 |
/* |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
699 |
* zfs_sa_enable_share(share, proto) |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
700 |
* |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
701 |
* Wrapper for sa_enable_share which enables a share for a specified |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
702 |
* protocol. |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
703 |
*/ |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
704 |
static int |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
705 |
zfs_sa_enable_share(sa_share_t share, char *proto) |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
706 |
{ |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
707 |
if (_sa_enable_share != NULL) |
4302 | 708 |
return (_sa_enable_share(share, proto)); |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
709 |
return (SA_CONFIG_ERR); |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
710 |
} |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
711 |
|
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
712 |
/* |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
713 |
* zfs_sa_disable_share(share, proto) |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
714 |
* |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
715 |
* Wrapper for sa_enable_share which disables a share for a specified |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
716 |
* protocol. |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
717 |
*/ |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
718 |
static int |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
719 |
zfs_sa_disable_share(sa_share_t share, char *proto) |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
720 |
{ |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
721 |
if (_sa_disable_share != NULL) |
4302 | 722 |
return (_sa_disable_share(share, proto)); |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
723 |
return (SA_CONFIG_ERR); |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
724 |
} |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
725 |
|
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
726 |
/* |
5331 | 727 |
* Share the given filesystem according to the options in the specified |
728 |
* protocol specific properties (sharenfs, sharesmb). We rely |
|
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
729 |
* on "libshare" to the dirty work for us. |
789 | 730 |
*/ |
5331 | 731 |
static int |
732 |
zfs_share_proto(zfs_handle_t *zhp, zfs_share_proto_t *proto) |
|
789 | 733 |
{ |
734 |
char mountpoint[ZFS_MAXPROPLEN]; |
|
735 |
char shareopts[ZFS_MAXPROPLEN]; |
|
5951
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
736 |
char sourcestr[ZFS_MAXPROPLEN]; |
2082 | 737 |
libzfs_handle_t *hdl = zhp->zfs_hdl; |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
738 |
sa_share_t share; |
5331 | 739 |
zfs_share_proto_t *curr_proto; |
5951
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
740 |
zprop_source_t sourcetype; |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
741 |
int ret; |
789 | 742 |
|
2676 | 743 |
if (!zfs_is_mountable(zhp, mountpoint, sizeof (mountpoint), NULL)) |
789 | 744 |
return (0); |
745 |
||
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
746 |
if ((ret = zfs_init_libshare(hdl, SA_INIT_SHARE_API)) != SA_OK) { |
4302 | 747 |
(void) zfs_error_fmt(hdl, EZFS_SHARENFSFAILED, |
748 |
dgettext(TEXT_DOMAIN, "cannot share '%s': %s"), |
|
5951
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
749 |
zfs_get_name(zhp), _sa_errorstr != NULL ? |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
750 |
_sa_errorstr(ret) : ""); |
4302 | 751 |
return (-1); |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
752 |
} |
5331 | 753 |
|
754 |
for (curr_proto = proto; *curr_proto != PROTO_END; curr_proto++) { |
|
755 |
/* |
|
756 |
* Return success if there are no share options. |
|
757 |
*/ |
|
758 |
if (zfs_prop_get(zhp, proto_table[*curr_proto].p_prop, |
|
5951
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
759 |
shareopts, sizeof (shareopts), &sourcetype, sourcestr, |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
760 |
ZFS_MAXPROPLEN, B_FALSE) != 0 || |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
761 |
strcmp(shareopts, "off") == 0) |
5331 | 762 |
continue; |
763 |
||
764 |
/* |
|
765 |
* If the 'zoned' property is set, then zfs_is_mountable() |
|
766 |
* will have already bailed out if we are in the global zone. |
|
767 |
* But local zones cannot be NFS servers, so we ignore it for |
|
768 |
* local zones as well. |
|
769 |
*/ |
|
770 |
if (zfs_prop_get_int(zhp, ZFS_PROP_ZONED)) |
|
771 |
continue; |
|
772 |
||
773 |
share = zfs_sa_find_share(hdl->libzfs_sharehdl, mountpoint); |
|
5951
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
774 |
if (share == NULL) { |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
775 |
/* |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
776 |
* This may be a new file system that was just |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
777 |
* created so isn't in the internal cache |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
778 |
* (second time through). Rather than |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
779 |
* reloading the entire configuration, we can |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
780 |
* assume ZFS has done the checking and it is |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
781 |
* safe to add this to the internal |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
782 |
* configuration. |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
783 |
*/ |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
784 |
if (_sa_zfs_process_share(hdl->libzfs_sharehdl, |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
785 |
NULL, NULL, mountpoint, |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
786 |
proto_table[*curr_proto].p_name, sourcetype, |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
787 |
shareopts, sourcestr, zhp->zfs_name) != SA_OK) { |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
788 |
(void) zfs_error_fmt(hdl, |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
789 |
proto_table[*curr_proto].p_share_err, |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
790 |
dgettext(TEXT_DOMAIN, "cannot share '%s'"), |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
791 |
zfs_get_name(zhp)); |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
792 |
return (-1); |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
793 |
} |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
794 |
hdl->libzfs_shareflags |= ZFSSHARE_MISS; |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
795 |
share = zfs_sa_find_share(hdl->libzfs_sharehdl, |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
796 |
mountpoint); |
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
797 |
} |
5331 | 798 |
if (share != NULL) { |
799 |
int err; |
|
800 |
err = zfs_sa_enable_share(share, |
|
801 |
proto_table[*curr_proto].p_name); |
|
802 |
if (err != SA_OK) { |
|
803 |
(void) zfs_error_fmt(hdl, |
|
804 |
proto_table[*curr_proto].p_share_err, |
|
805 |
dgettext(TEXT_DOMAIN, "cannot share '%s'"), |
|
806 |
zfs_get_name(zhp)); |
|
807 |
return (-1); |
|
808 |
} |
|
809 |
} else { |
|
810 |
(void) zfs_error_fmt(hdl, |
|
811 |
proto_table[*curr_proto].p_share_err, |
|
4302 | 812 |
dgettext(TEXT_DOMAIN, "cannot share '%s'"), |
813 |
zfs_get_name(zhp)); |
|
814 |
return (-1); |
|
815 |
} |
|
5331 | 816 |
|
789 | 817 |
} |
5331 | 818 |
return (0); |
819 |
} |
|
789 | 820 |
|
5331 | 821 |
|
822 |
int |
|
823 |
zfs_share_nfs(zfs_handle_t *zhp) |
|
824 |
{ |
|
825 |
return (zfs_share_proto(zhp, nfs_only)); |
|
826 |
} |
|
827 |
||
828 |
int |
|
829 |
zfs_share_smb(zfs_handle_t *zhp) |
|
830 |
{ |
|
831 |
return (zfs_share_proto(zhp, smb_only)); |
|
832 |
} |
|
833 |
||
834 |
int |
|
835 |
zfs_shareall(zfs_handle_t *zhp) |
|
836 |
{ |
|
837 |
return (zfs_share_proto(zhp, share_all_proto)); |
|
789 | 838 |
} |
839 |
||
840 |
/* |
|
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
841 |
* Unshare a filesystem by mountpoint. |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
842 |
*/ |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
843 |
static int |
5331 | 844 |
unshare_one(libzfs_handle_t *hdl, const char *name, const char *mountpoint, |
845 |
zfs_share_proto_t proto) |
|
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
846 |
{ |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
847 |
sa_share_t share; |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
848 |
int err; |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
849 |
char *mntpt; |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
850 |
/* |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
851 |
* Mountpoint could get trashed if libshare calls getmntany |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
852 |
* which id does during API initialization, so strdup the |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
853 |
* value. |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
854 |
*/ |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
855 |
mntpt = zfs_strdup(hdl, mountpoint); |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
856 |
|
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
857 |
/* make sure libshare initialized */ |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
858 |
if ((err = zfs_init_libshare(hdl, SA_INIT_SHARE_API)) != SA_OK) { |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
859 |
free(mntpt); /* don't need the copy anymore */ |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
860 |
return (zfs_error_fmt(hdl, EZFS_SHARENFSFAILED, |
4302 | 861 |
dgettext(TEXT_DOMAIN, "cannot unshare '%s': %s"), |
862 |
name, _sa_errorstr(err))); |
|
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
863 |
} |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
864 |
|
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
865 |
share = zfs_sa_find_share(hdl->libzfs_sharehdl, mntpt); |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
866 |
free(mntpt); /* don't need the copy anymore */ |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
867 |
|
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
868 |
if (share != NULL) { |
5331 | 869 |
err = zfs_sa_disable_share(share, proto_table[proto].p_name); |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
870 |
if (err != SA_OK) { |
4302 | 871 |
return (zfs_error_fmt(hdl, EZFS_UNSHARENFSFAILED, |
872 |
dgettext(TEXT_DOMAIN, "cannot unshare '%s': %s"), |
|
873 |
name, _sa_errorstr(err))); |
|
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
874 |
} |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
875 |
} else { |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
876 |
return (zfs_error_fmt(hdl, EZFS_UNSHARENFSFAILED, |
4302 | 877 |
dgettext(TEXT_DOMAIN, "cannot unshare '%s': not found"), |
878 |
name)); |
|
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
879 |
} |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
880 |
return (0); |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
881 |
} |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
882 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
883 |
/* |
789 | 884 |
* Unshare the given filesystem. |
885 |
*/ |
|
886 |
int |
|
5331 | 887 |
zfs_unshare_proto(zfs_handle_t *zhp, const char *mountpoint, |
888 |
zfs_share_proto_t *proto) |
|
789 | 889 |
{ |
890 |
struct mnttab search = { 0 }, entry; |
|
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
891 |
char *mntpt = NULL; |
789 | 892 |
|
893 |
/* check to see if need to unmount the filesystem */ |
|
894 |
search.mnt_special = (char *)zfs_get_name(zhp); |
|
1407
f178d5f7681f
6381720 zfs_unmount() not checking fstype in /etc/mnttab
nd150628
parents:
1371
diff
changeset
|
895 |
search.mnt_fstype = MNTTYPE_ZFS; |
2082 | 896 |
rewind(zhp->zfs_hdl->libzfs_mnttab); |
4302 | 897 |
if (mountpoint != NULL) |
5331 | 898 |
mntpt = zfs_strdup(zhp->zfs_hdl, mountpoint); |
4302 | 899 |
|
789 | 900 |
if (mountpoint != NULL || ((zfs_get_type(zhp) == ZFS_TYPE_FILESYSTEM) && |
2082 | 901 |
getmntany(zhp->zfs_hdl->libzfs_mnttab, &entry, &search) == 0)) { |
5331 | 902 |
zfs_share_proto_t *curr_proto; |
789 | 903 |
|
904 |
if (mountpoint == NULL) |
|
5331 | 905 |
mntpt = zfs_strdup(zhp->zfs_hdl, entry.mnt_mountp); |
906 |
||
907 |
for (curr_proto = proto; *curr_proto != PROTO_END; |
|
908 |
curr_proto++) { |
|
789 | 909 |
|
5331 | 910 |
if (is_shared(zhp->zfs_hdl, mntpt, *curr_proto) && |
911 |
unshare_one(zhp->zfs_hdl, zhp->zfs_name, |
|
912 |
mntpt, *curr_proto) != 0) { |
|
913 |
if (mntpt != NULL) |
|
914 |
free(mntpt); |
|
915 |
return (-1); |
|
916 |
} |
|
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
917 |
} |
789 | 918 |
} |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
919 |
if (mntpt != NULL) |
4302 | 920 |
free(mntpt); |
789 | 921 |
|
922 |
return (0); |
|
923 |
} |
|
924 |
||
5331 | 925 |
int |
926 |
zfs_unshare_nfs(zfs_handle_t *zhp, const char *mountpoint) |
|
927 |
{ |
|
928 |
return (zfs_unshare_proto(zhp, mountpoint, nfs_only)); |
|
929 |
} |
|
930 |
||
931 |
int |
|
932 |
zfs_unshare_smb(zfs_handle_t *zhp, const char *mountpoint) |
|
933 |
{ |
|
934 |
return (zfs_unshare_proto(zhp, mountpoint, smb_only)); |
|
935 |
} |
|
936 |
||
789 | 937 |
/* |
5331 | 938 |
* Same as zfs_unmountall(), but for NFS and SMB unshares. |
789 | 939 |
*/ |
940 |
int |
|
5331 | 941 |
zfs_unshareall_proto(zfs_handle_t *zhp, zfs_share_proto_t *proto) |
789 | 942 |
{ |
943 |
prop_changelist_t *clp; |
|
944 |
int ret; |
|
945 |
||
7366
33de5956afbb
6678308 zfs receive dumps core when -n is used, fails on replication stream
Tim Haley <Tim.Haley@Sun.COM>
parents:
6168
diff
changeset
|
946 |
clp = changelist_gather(zhp, ZFS_PROP_SHARENFS, 0, 0); |
789 | 947 |
if (clp == NULL) |
948 |
return (-1); |
|
949 |
||
5331 | 950 |
ret = changelist_unshare(clp, proto); |
789 | 951 |
changelist_free(clp); |
952 |
||
953 |
return (ret); |
|
954 |
} |
|
955 |
||
5331 | 956 |
int |
957 |
zfs_unshareall_nfs(zfs_handle_t *zhp) |
|
958 |
{ |
|
959 |
return (zfs_unshareall_proto(zhp, nfs_only)); |
|
960 |
} |
|
961 |
||
962 |
int |
|
963 |
zfs_unshareall_smb(zfs_handle_t *zhp) |
|
964 |
{ |
|
965 |
return (zfs_unshareall_proto(zhp, smb_only)); |
|
966 |
} |
|
967 |
||
968 |
int |
|
969 |
zfs_unshareall(zfs_handle_t *zhp) |
|
970 |
{ |
|
971 |
return (zfs_unshareall_proto(zhp, share_all_proto)); |
|
972 |
} |
|
973 |
||
974 |
int |
|
975 |
zfs_unshareall_bypath(zfs_handle_t *zhp, const char *mountpoint) |
|
976 |
{ |
|
977 |
return (zfs_unshare_proto(zhp, mountpoint, share_all_proto)); |
|
978 |
} |
|
979 |
||
789 | 980 |
/* |
981 |
* Remove the mountpoint associated with the current dataset, if necessary. |
|
982 |
* We only remove the underlying directory if: |
|
983 |
* |
|
984 |
* - The mountpoint is not 'none' or 'legacy' |
|
985 |
* - The mountpoint is non-empty |
|
986 |
* - The mountpoint is the default or inherited |
|
987 |
* - The 'zoned' property is set, or we're in a local zone |
|
988 |
* |
|
989 |
* Any other directories we leave alone. |
|
990 |
*/ |
|
991 |
void |
|
992 |
remove_mountpoint(zfs_handle_t *zhp) |
|
993 |
{ |
|
994 |
char mountpoint[ZFS_MAXPROPLEN]; |
|
5094 | 995 |
zprop_source_t source; |
789 | 996 |
|
2676 | 997 |
if (!zfs_is_mountable(zhp, mountpoint, sizeof (mountpoint), |
998 |
&source)) |
|
789 | 999 |
return; |
1000 |
||
5094 | 1001 |
if (source == ZPROP_SRC_DEFAULT || |
1002 |
source == ZPROP_SRC_INHERITED) { |
|
789 | 1003 |
/* |
1004 |
* Try to remove the directory, silently ignoring any errors. |
|
1005 |
* The filesystem may have since been removed or moved around, |
|
2676 | 1006 |
* and this error isn't really useful to the administrator in |
1007 |
* any way. |
|
789 | 1008 |
*/ |
1009 |
(void) rmdir(mountpoint); |
|
1010 |
} |
|
1011 |
} |
|
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1012 |
|
3126 | 1013 |
boolean_t |
1014 |
zfs_is_shared_iscsi(zfs_handle_t *zhp) |
|
1015 |
{ |
|
4543 | 1016 |
|
1017 |
/* |
|
1018 |
* If iscsi deamon isn't running then we aren't shared |
|
1019 |
*/ |
|
1020 |
if (iscsitgt_svc_online && iscsitgt_svc_online() == 1) |
|
5331 | 1021 |
return (B_FALSE); |
4543 | 1022 |
else |
1023 |
return (iscsitgt_zfs_is_shared != NULL && |
|
1024 |
iscsitgt_zfs_is_shared(zhp->zfs_name) != 0); |
|
3126 | 1025 |
} |
1026 |
||
1027 |
int |
|
1028 |
zfs_share_iscsi(zfs_handle_t *zhp) |
|
1029 |
{ |
|
1030 |
char shareopts[ZFS_MAXPROPLEN]; |
|
1031 |
const char *dataset = zhp->zfs_name; |
|
1032 |
libzfs_handle_t *hdl = zhp->zfs_hdl; |
|
1033 |
||
1034 |
/* |
|
1035 |
* Return success if there are no share options. |
|
1036 |
*/ |
|
1037 |
if (zfs_prop_get(zhp, ZFS_PROP_SHAREISCSI, shareopts, |
|
1038 |
sizeof (shareopts), NULL, NULL, 0, B_FALSE) != 0 || |
|
1039 |
strcmp(shareopts, "off") == 0) |
|
1040 |
return (0); |
|
1041 |
||
4543 | 1042 |
if (iscsitgt_zfs_share == NULL || iscsitgt_zfs_share(dataset) != 0) { |
1043 |
int error = EZFS_SHAREISCSIFAILED; |
|
1044 |
||
1045 |
/* |
|
1046 |
* If service isn't availabele and EPERM was |
|
1047 |
* returned then use special error. |
|
1048 |
*/ |
|
1049 |
if (iscsitgt_svc_online && errno == EPERM && |
|
1050 |
(iscsitgt_svc_online() != 0)) |
|
1051 |
error = EZFS_ISCSISVCUNAVAIL; |
|
1052 |
||
1053 |
return (zfs_error_fmt(hdl, error, |
|
3126 | 1054 |
dgettext(TEXT_DOMAIN, "cannot share '%s'"), dataset)); |
4543 | 1055 |
} |
3126 | 1056 |
|
1057 |
return (0); |
|
1058 |
} |
|
1059 |
||
1060 |
int |
|
1061 |
zfs_unshare_iscsi(zfs_handle_t *zhp) |
|
1062 |
{ |
|
1063 |
const char *dataset = zfs_get_name(zhp); |
|
1064 |
libzfs_handle_t *hdl = zhp->zfs_hdl; |
|
1065 |
||
1066 |
/* |
|
3380
c121b2a2bd0e
6510448 zfs_unshare_iscsi() gives bogus error message when libiscsitgt cannot be opened or is missing
gw25295
parents:
3237
diff
changeset
|
1067 |
* Return if the volume is not shared |
c121b2a2bd0e
6510448 zfs_unshare_iscsi() gives bogus error message when libiscsitgt cannot be opened or is missing
gw25295
parents:
3237
diff
changeset
|
1068 |
*/ |
5331 | 1069 |
if (zfs_is_shared_iscsi(zhp) != SHARED_ISCSI) |
3380
c121b2a2bd0e
6510448 zfs_unshare_iscsi() gives bogus error message when libiscsitgt cannot be opened or is missing
gw25295
parents:
3237
diff
changeset
|
1070 |
return (0); |
c121b2a2bd0e
6510448 zfs_unshare_iscsi() gives bogus error message when libiscsitgt cannot be opened or is missing
gw25295
parents:
3237
diff
changeset
|
1071 |
|
c121b2a2bd0e
6510448 zfs_unshare_iscsi() gives bogus error message when libiscsitgt cannot be opened or is missing
gw25295
parents:
3237
diff
changeset
|
1072 |
/* |
3126 | 1073 |
* If this fails with ENODEV it indicates that zvol wasn't shared so |
1074 |
* we should return success in that case. |
|
1075 |
*/ |
|
3134
59cd24b2b5d6
6494840 libzfs should dlopen libiscsitgt rather than linking to it
ahl
parents:
3126
diff
changeset
|
1076 |
if (iscsitgt_zfs_unshare == NULL || |
4543 | 1077 |
(iscsitgt_zfs_unshare(dataset) != 0 && errno != ENODEV)) { |
1078 |
if (errno == EPERM) |
|
1079 |
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, |
|
1080 |
"Insufficient privileges to unshare iscsi")); |
|
3237
98d0c28f2f5e
6480245 renaming a dataset to something with '%s' will cause segfault
lling
parents:
3134
diff
changeset
|
1081 |
return (zfs_error_fmt(hdl, EZFS_UNSHAREISCSIFAILED, |
3126 | 1082 |
dgettext(TEXT_DOMAIN, "cannot unshare '%s'"), dataset)); |
4543 | 1083 |
} |
3126 | 1084 |
|
1085 |
return (0); |
|
1086 |
} |
|
1087 |
||
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1088 |
typedef struct mount_cbdata { |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1089 |
zfs_handle_t **cb_datasets; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1090 |
int cb_used; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1091 |
int cb_alloc; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1092 |
} mount_cbdata_t; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1093 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1094 |
static int |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1095 |
mount_cb(zfs_handle_t *zhp, void *data) |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1096 |
{ |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1097 |
mount_cbdata_t *cbp = data; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1098 |
|
3126 | 1099 |
if (!(zfs_get_type(zhp) & (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME))) { |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1100 |
zfs_close(zhp); |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1101 |
return (0); |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1102 |
} |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1103 |
|
6168
51c045dcc498
PSARC 2008/168 Support for ZFS property value canmount=noauto
hs24103
parents:
6027
diff
changeset
|
1104 |
if (zfs_prop_get_int(zhp, ZFS_PROP_CANMOUNT) == ZFS_CANMOUNT_NOAUTO) { |
51c045dcc498
PSARC 2008/168 Support for ZFS property value canmount=noauto
hs24103
parents:
6027
diff
changeset
|
1105 |
zfs_close(zhp); |
51c045dcc498
PSARC 2008/168 Support for ZFS property value canmount=noauto
hs24103
parents:
6027
diff
changeset
|
1106 |
return (0); |
51c045dcc498
PSARC 2008/168 Support for ZFS property value canmount=noauto
hs24103
parents:
6027
diff
changeset
|
1107 |
} |
51c045dcc498
PSARC 2008/168 Support for ZFS property value canmount=noauto
hs24103
parents:
6027
diff
changeset
|
1108 |
|
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1109 |
if (cbp->cb_alloc == cbp->cb_used) { |
2676 | 1110 |
void *ptr; |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1111 |
|
2676 | 1112 |
if ((ptr = zfs_realloc(zhp->zfs_hdl, |
1113 |
cbp->cb_datasets, cbp->cb_alloc * sizeof (void *), |
|
1114 |
cbp->cb_alloc * 2 * sizeof (void *))) == NULL) |
|
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1115 |
return (-1); |
2676 | 1116 |
cbp->cb_datasets = ptr; |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1117 |
|
2676 | 1118 |
cbp->cb_alloc *= 2; |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1119 |
} |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1120 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1121 |
cbp->cb_datasets[cbp->cb_used++] = zhp; |
3126 | 1122 |
|
6027
68b03551f113
6609196 'zfs destroy -r' can needlessly iterate over all filesystems in pool
rm160521
parents:
5951
diff
changeset
|
1123 |
return (zfs_iter_filesystems(zhp, mount_cb, cbp)); |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1124 |
} |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1125 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1126 |
static int |
3126 | 1127 |
dataset_cmp(const void *a, const void *b) |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1128 |
{ |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1129 |
zfs_handle_t **za = (zfs_handle_t **)a; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1130 |
zfs_handle_t **zb = (zfs_handle_t **)b; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1131 |
char mounta[MAXPATHLEN]; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1132 |
char mountb[MAXPATHLEN]; |
3126 | 1133 |
boolean_t gota, gotb; |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1134 |
|
3126 | 1135 |
if ((gota = (zfs_get_type(*za) == ZFS_TYPE_FILESYSTEM)) != 0) |
1136 |
verify(zfs_prop_get(*za, ZFS_PROP_MOUNTPOINT, mounta, |
|
1137 |
sizeof (mounta), NULL, NULL, 0, B_FALSE) == 0); |
|
1138 |
if ((gotb = (zfs_get_type(*zb) == ZFS_TYPE_FILESYSTEM)) != 0) |
|
1139 |
verify(zfs_prop_get(*zb, ZFS_PROP_MOUNTPOINT, mountb, |
|
1140 |
sizeof (mountb), NULL, NULL, 0, B_FALSE) == 0); |
|
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1141 |
|
3126 | 1142 |
if (gota && gotb) |
1143 |
return (strcmp(mounta, mountb)); |
|
1144 |
||
1145 |
if (gota) |
|
1146 |
return (-1); |
|
1147 |
if (gotb) |
|
1148 |
return (1); |
|
1149 |
||
1150 |
return (strcmp(zfs_get_name(a), zfs_get_name(b))); |
|
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1151 |
} |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1152 |
|
3126 | 1153 |
/* |
1154 |
* Mount and share all datasets within the given pool. This assumes that no |
|
1155 |
* datasets within the pool are currently mounted. Because users can create |
|
1156 |
* complicated nested hierarchies of mountpoints, we first gather all the |
|
1157 |
* datasets and mountpoints within the pool, and sort them by mountpoint. Once |
|
1158 |
* we have the list of all filesystems, we iterate over them in order and mount |
|
1159 |
* and/or share each one. |
|
1160 |
*/ |
|
1161 |
#pragma weak zpool_mount_datasets = zpool_enable_datasets |
|
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1162 |
int |
3126 | 1163 |
zpool_enable_datasets(zpool_handle_t *zhp, const char *mntopts, int flags) |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1164 |
{ |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1165 |
mount_cbdata_t cb = { 0 }; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1166 |
libzfs_handle_t *hdl = zhp->zpool_hdl; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1167 |
zfs_handle_t *zfsp; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1168 |
int i, ret = -1; |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
1169 |
int *good; |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1170 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1171 |
/* |
6027
68b03551f113
6609196 'zfs destroy -r' can needlessly iterate over all filesystems in pool
rm160521
parents:
5951
diff
changeset
|
1172 |
* Gather all non-snap datasets within the pool. |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1173 |
*/ |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1174 |
if ((cb.cb_datasets = zfs_alloc(hdl, 4 * sizeof (void *))) == NULL) |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1175 |
return (-1); |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1176 |
cb.cb_alloc = 4; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1177 |
|
5094 | 1178 |
if ((zfsp = zfs_open(hdl, zhp->zpool_name, ZFS_TYPE_DATASET)) == NULL) |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1179 |
goto out; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1180 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1181 |
cb.cb_datasets[0] = zfsp; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1182 |
cb.cb_used = 1; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1183 |
|
6027
68b03551f113
6609196 'zfs destroy -r' can needlessly iterate over all filesystems in pool
rm160521
parents:
5951
diff
changeset
|
1184 |
if (zfs_iter_filesystems(zfsp, mount_cb, &cb) != 0) |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1185 |
goto out; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1186 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1187 |
/* |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1188 |
* Sort the datasets by mountpoint. |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1189 |
*/ |
3126 | 1190 |
qsort(cb.cb_datasets, cb.cb_used, sizeof (void *), dataset_cmp); |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1191 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1192 |
/* |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
1193 |
* And mount all the datasets, keeping track of which ones |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
1194 |
* succeeded or failed. By using zfs_alloc(), the good pointer |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
1195 |
* will always be non-NULL. |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1196 |
*/ |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
1197 |
good = zfs_alloc(zhp->zpool_hdl, cb.cb_used * sizeof (int)); |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1198 |
ret = 0; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1199 |
for (i = 0; i < cb.cb_used; i++) { |
4302 | 1200 |
if (zfs_mount(cb.cb_datasets[i], mntopts, flags) != 0) |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
1201 |
ret = -1; |
4302 | 1202 |
else |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
1203 |
good[i] = 1; |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
1204 |
} |
5951
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
1205 |
|
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
1206 |
/* |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
1207 |
* Then share all the ones that need to be shared. This needs |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
1208 |
* to be a separate pass in order to avoid excessive reloading |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
1209 |
* of the configuration. Good should never be NULL since |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
1210 |
* zfs_alloc is supposed to exit if memory isn't available. |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
1211 |
*/ |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
1212 |
for (i = 0; i < cb.cb_used; i++) { |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
1213 |
if (good[i] && zfs_share(cb.cb_datasets[i]) != 0) |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1214 |
ret = -1; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1215 |
} |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1216 |
|
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
1217 |
free(good); |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3444
diff
changeset
|
1218 |
|
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1219 |
out: |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1220 |
for (i = 0; i < cb.cb_used; i++) |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1221 |
zfs_close(cb.cb_datasets[i]); |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1222 |
free(cb.cb_datasets); |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1223 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1224 |
return (ret); |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1225 |
} |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1226 |
|
3126 | 1227 |
|
1228 |
static int |
|
1229 |
zvol_cb(const char *dataset, void *data) |
|
1230 |
{ |
|
1231 |
libzfs_handle_t *hdl = data; |
|
1232 |
zfs_handle_t *zhp; |
|
1233 |
||
1234 |
/* |
|
1235 |
* Ignore snapshots and ignore failures from non-existant datasets. |
|
1236 |
*/ |
|
1237 |
if (strchr(dataset, '@') != NULL || |
|
1238 |
(zhp = zfs_open(hdl, dataset, ZFS_TYPE_VOLUME)) == NULL) |
|
1239 |
return (0); |
|
1240 |
||
4543 | 1241 |
if (zfs_unshare_iscsi(zhp) != 0) |
1242 |
return (-1); |
|
3126 | 1243 |
|
1244 |
zfs_close(zhp); |
|
1245 |
||
1246 |
return (0); |
|
1247 |
} |
|
1248 |
||
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1249 |
static int |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1250 |
mountpoint_compare(const void *a, const void *b) |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1251 |
{ |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1252 |
const char *mounta = *((char **)a); |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1253 |
const char *mountb = *((char **)b); |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1254 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1255 |
return (strcmp(mountb, mounta)); |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1256 |
} |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1257 |
|
3126 | 1258 |
/* |
1259 |
* Unshare and unmount all datasets within the given pool. We don't want to |
|
1260 |
* rely on traversing the DSL to discover the filesystems within the pool, |
|
1261 |
* because this may be expensive (if not all of them are mounted), and can fail |
|
1262 |
* arbitrarily (on I/O error, for example). Instead, we walk /etc/mnttab and |
|
1263 |
* gather all the filesystems that are currently mounted. |
|
1264 |
*/ |
|
1265 |
#pragma weak zpool_unmount_datasets = zpool_disable_datasets |
|
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1266 |
int |
3126 | 1267 |
zpool_disable_datasets(zpool_handle_t *zhp, boolean_t force) |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1268 |
{ |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1269 |
int used, alloc; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1270 |
struct mnttab entry; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1271 |
size_t namelen; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1272 |
char **mountpoints = NULL; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1273 |
zfs_handle_t **datasets = NULL; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1274 |
libzfs_handle_t *hdl = zhp->zpool_hdl; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1275 |
int i; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1276 |
int ret = -1; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1277 |
int flags = (force ? MS_FORCE : 0); |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1278 |
|
3126 | 1279 |
/* |
1280 |
* First unshare all zvols. |
|
1281 |
*/ |
|
1282 |
if (zpool_iter_zvol(zhp, zvol_cb, hdl) != 0) |
|
1283 |
return (-1); |
|
1284 |
||
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1285 |
namelen = strlen(zhp->zpool_name); |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1286 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1287 |
rewind(hdl->libzfs_mnttab); |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1288 |
used = alloc = 0; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1289 |
while (getmntent(hdl->libzfs_mnttab, &entry) == 0) { |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1290 |
/* |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1291 |
* Ignore non-ZFS entries. |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1292 |
*/ |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1293 |
if (entry.mnt_fstype == NULL || |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1294 |
strcmp(entry.mnt_fstype, MNTTYPE_ZFS) != 0) |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1295 |
continue; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1296 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1297 |
/* |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1298 |
* Ignore filesystems not within this pool. |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1299 |
*/ |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1300 |
if (entry.mnt_mountp == NULL || |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1301 |
strncmp(entry.mnt_special, zhp->zpool_name, namelen) != 0 || |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1302 |
(entry.mnt_special[namelen] != '/' && |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1303 |
entry.mnt_special[namelen] != '\0')) |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1304 |
continue; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1305 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1306 |
/* |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1307 |
* At this point we've found a filesystem within our pool. Add |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1308 |
* it to our growing list. |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1309 |
*/ |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1310 |
if (used == alloc) { |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1311 |
if (alloc == 0) { |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1312 |
if ((mountpoints = zfs_alloc(hdl, |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1313 |
8 * sizeof (void *))) == NULL) |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1314 |
goto out; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1315 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1316 |
if ((datasets = zfs_alloc(hdl, |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1317 |
8 * sizeof (void *))) == NULL) |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1318 |
goto out; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1319 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1320 |
alloc = 8; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1321 |
} else { |
2676 | 1322 |
void *ptr; |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1323 |
|
2676 | 1324 |
if ((ptr = zfs_realloc(hdl, mountpoints, |
1325 |
alloc * sizeof (void *), |
|
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1326 |
alloc * 2 * sizeof (void *))) == NULL) |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1327 |
goto out; |
2676 | 1328 |
mountpoints = ptr; |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1329 |
|
2676 | 1330 |
if ((ptr = zfs_realloc(hdl, datasets, |
1331 |
alloc * sizeof (void *), |
|
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1332 |
alloc * 2 * sizeof (void *))) == NULL) |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1333 |
goto out; |
2676 | 1334 |
datasets = ptr; |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1335 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1336 |
alloc *= 2; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1337 |
} |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1338 |
} |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1339 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1340 |
if ((mountpoints[used] = zfs_strdup(hdl, |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1341 |
entry.mnt_mountp)) == NULL) |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1342 |
goto out; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1343 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1344 |
/* |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1345 |
* This is allowed to fail, in case there is some I/O error. It |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1346 |
* is only used to determine if we need to remove the underlying |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1347 |
* mountpoint, so failure is not fatal. |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1348 |
*/ |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1349 |
datasets[used] = make_dataset_handle(hdl, entry.mnt_special); |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1350 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1351 |
used++; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1352 |
} |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1353 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1354 |
/* |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1355 |
* At this point, we have the entire list of filesystems, so sort it by |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1356 |
* mountpoint. |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1357 |
*/ |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1358 |
qsort(mountpoints, used, sizeof (char *), mountpoint_compare); |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1359 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1360 |
/* |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1361 |
* Walk through and first unshare everything. |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1362 |
*/ |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1363 |
for (i = 0; i < used; i++) { |
5331 | 1364 |
zfs_share_proto_t *curr_proto; |
1365 |
for (curr_proto = share_all_proto; *curr_proto != PROTO_END; |
|
1366 |
curr_proto++) { |
|
1367 |
if (is_shared(hdl, mountpoints[i], *curr_proto) && |
|
1368 |
unshare_one(hdl, mountpoints[i], |
|
1369 |
mountpoints[i], *curr_proto) != 0) |
|
1370 |
goto out; |
|
1371 |
} |
|
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1372 |
} |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1373 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1374 |
/* |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1375 |
* Now unmount everything, removing the underlying directories as |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1376 |
* appropriate. |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1377 |
*/ |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1378 |
for (i = 0; i < used; i++) { |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1379 |
if (unmount_one(hdl, mountpoints[i], flags) != 0) |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1380 |
goto out; |
2676 | 1381 |
} |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1382 |
|
2676 | 1383 |
for (i = 0; i < used; i++) { |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1384 |
if (datasets[i]) |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1385 |
remove_mountpoint(datasets[i]); |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1386 |
} |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1387 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1388 |
ret = 0; |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1389 |
out: |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1390 |
for (i = 0; i < used; i++) { |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1391 |
if (datasets[i]) |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1392 |
zfs_close(datasets[i]); |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1393 |
free(mountpoints[i]); |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1394 |
} |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1395 |
free(datasets); |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1396 |
free(mountpoints); |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1397 |
|
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1398 |
return (ret); |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2082
diff
changeset
|
1399 |
} |