xref: /illumos-gate/usr/src/lib/libzfs/common/libzfs.h (revision 43d68d68)
1fa9e4066Sahrens /*
2fa9e4066Sahrens  * CDDL HEADER START
3fa9e4066Sahrens  *
4fa9e4066Sahrens  * The contents of this file are subject to the terms of the
5441d80aaSlling  * Common Development and Distribution License (the "License").
6441d80aaSlling  * You may not use this file except in compliance with the License.
7fa9e4066Sahrens  *
8fa9e4066Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fa9e4066Sahrens  * or http://www.opensolaris.org/os/licensing.
10fa9e4066Sahrens  * See the License for the specific language governing permissions
11fa9e4066Sahrens  * and limitations under the License.
12fa9e4066Sahrens  *
13fa9e4066Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
14fa9e4066Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fa9e4066Sahrens  * If applicable, add the following below this CDDL HEADER, with the
16fa9e4066Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
17fa9e4066Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
18fa9e4066Sahrens  *
19fa9e4066Sahrens  * CDDL HEADER END
20fa9e4066Sahrens  */
21f3861e1aSahl 
22fa9e4066Sahrens /*
233f9d6ad7SLin Ling  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
244263d13fSGeorge Wilson  * Copyright (c) 2012 by Delphix. All rights reserved.
254e3c9f44SBill Pijewski  * Copyright (c) 2012, Joyent, Inc. All rights reserved.
26a7a845e4SSteven Hartland  * Copyright (c) 2013 Steven Hartland. All rights reserved.
27*43d68d68SYuri Pankov  * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
28fa9e4066Sahrens  */
29fa9e4066Sahrens 
30fa9e4066Sahrens #ifndef	_LIBZFS_H
31fa9e4066Sahrens #define	_LIBZFS_H
32fa9e4066Sahrens 
33fa9e4066Sahrens #include <assert.h>
34fa9e4066Sahrens #include <libnvpair.h>
35ebedde84SEric Taylor #include <sys/mnttab.h>
36fa9e4066Sahrens #include <sys/param.h>
37fa9e4066Sahrens #include <sys/types.h>
38fa9e4066Sahrens #include <sys/varargs.h>
39fa9e4066Sahrens #include <sys/fs/zfs.h>
40ecd6cf80Smarks #include <sys/avl.h>
41ecd6cf80Smarks #include <ucred.h>
42fa9e4066Sahrens 
43fa9e4066Sahrens #ifdef	__cplusplus
44fa9e4066Sahrens extern "C" {
45fa9e4066Sahrens #endif
46fa9e4066Sahrens 
47fa9e4066Sahrens /*
48fa9e4066Sahrens  * Miscellaneous ZFS constants
49fa9e4066Sahrens  */
50fa9e4066Sahrens #define	ZFS_MAXNAMELEN		MAXNAMELEN
51fa9e4066Sahrens #define	ZPOOL_MAXNAMELEN	MAXNAMELEN
52fa9e4066Sahrens #define	ZFS_MAXPROPLEN		MAXPATHLEN
53990b4856Slling #define	ZPOOL_MAXPROPLEN	MAXPATHLEN
54fa9e4066Sahrens 
5599653d4eSeschrock /*
5699653d4eSeschrock  * libzfs errors
5799653d4eSeschrock  */
584445fffbSMatthew Ahrens typedef enum zfs_error {
594445fffbSMatthew Ahrens 	EZFS_SUCCESS = 0,	/* no error -- success */
6099653d4eSeschrock 	EZFS_NOMEM = 2000,	/* out of memory */
6199653d4eSeschrock 	EZFS_BADPROP,		/* invalid property value */
6299653d4eSeschrock 	EZFS_PROPREADONLY,	/* cannot set readonly property */
6399653d4eSeschrock 	EZFS_PROPTYPE,		/* property does not apply to dataset type */
6499653d4eSeschrock 	EZFS_PROPNONINHERIT,	/* property is not inheritable */
6599653d4eSeschrock 	EZFS_PROPSPACE,		/* bad quota or reservation */
6699653d4eSeschrock 	EZFS_BADTYPE,		/* dataset is not of appropriate type */
6799653d4eSeschrock 	EZFS_BUSY,		/* pool or dataset is busy */
6899653d4eSeschrock 	EZFS_EXISTS,		/* pool or dataset already exists */
6999653d4eSeschrock 	EZFS_NOENT,		/* no such pool or dataset */
7099653d4eSeschrock 	EZFS_BADSTREAM,		/* bad backup stream */
7199653d4eSeschrock 	EZFS_DSREADONLY,	/* dataset is readonly */
7299653d4eSeschrock 	EZFS_VOLTOOBIG,		/* volume is too large for 32-bit system */
7399653d4eSeschrock 	EZFS_INVALIDNAME,	/* invalid dataset name */
7499653d4eSeschrock 	EZFS_BADRESTORE,	/* unable to restore to destination */
7599653d4eSeschrock 	EZFS_BADBACKUP,		/* backup failed */
7699653d4eSeschrock 	EZFS_BADTARGET,		/* bad attach/detach/replace target */
7799653d4eSeschrock 	EZFS_NODEVICE,		/* no such device in pool */
7899653d4eSeschrock 	EZFS_BADDEV,		/* invalid device to add */
7999653d4eSeschrock 	EZFS_NOREPLICAS,	/* no valid replicas */
8099653d4eSeschrock 	EZFS_RESILVERING,	/* currently resilvering */
8199653d4eSeschrock 	EZFS_BADVERSION,	/* unsupported version */
8299653d4eSeschrock 	EZFS_POOLUNAVAIL,	/* pool is currently unavailable */
8399653d4eSeschrock 	EZFS_DEVOVERFLOW,	/* too many devices in one vdev */
8499653d4eSeschrock 	EZFS_BADPATH,		/* must be an absolute path */
8599653d4eSeschrock 	EZFS_CROSSTARGET,	/* rename or clone across pool or dataset */
8699653d4eSeschrock 	EZFS_ZONED,		/* used improperly in local zone */
8799653d4eSeschrock 	EZFS_MOUNTFAILED,	/* failed to mount dataset */
8899653d4eSeschrock 	EZFS_UMOUNTFAILED,	/* failed to unmount dataset */
89f3861e1aSahl 	EZFS_UNSHARENFSFAILED,	/* unshare(1M) failed */
90f3861e1aSahl 	EZFS_SHARENFSFAILED,	/* share(1M) failed */
9199653d4eSeschrock 	EZFS_PERM,		/* permission denied */
9299653d4eSeschrock 	EZFS_NOSPC,		/* out of space */
936e27f868SSam Falkner 	EZFS_FAULT,		/* bad address */
9499653d4eSeschrock 	EZFS_IO,		/* I/O error */
9599653d4eSeschrock 	EZFS_INTR,		/* signal received */
9699653d4eSeschrock 	EZFS_ISSPARE,		/* device is a hot spare */
9799653d4eSeschrock 	EZFS_INVALCONFIG,	/* invalid vdev configuration */
983bb79becSeschrock 	EZFS_RECURSIVE,		/* recursive dependency */
9906eeb2adSek 	EZFS_NOHISTORY,		/* no history object */
100b1b8ab34Slling 	EZFS_POOLPROPS,		/* couldn't retrieve pool props */
101b1b8ab34Slling 	EZFS_POOL_NOTSUP,	/* ops not supported for this type of pool */
102b1b8ab34Slling 	EZFS_POOL_INVALARG,	/* invalid argument for this pool operation */
103b7661cccSmmusante 	EZFS_NAMETOOLONG,	/* dataset name is too long */
1048488aeb5Staylor 	EZFS_OPENFAILED,	/* open of device failed */
1058488aeb5Staylor 	EZFS_NOCAP,		/* couldn't get capacity */
1068488aeb5Staylor 	EZFS_LABELFAILED,	/* write of label failed */
107ecd6cf80Smarks 	EZFS_BADWHO,		/* invalid permission who */
108ecd6cf80Smarks 	EZFS_BADPERM,		/* invalid permission */
109ecd6cf80Smarks 	EZFS_BADPERMSET,	/* invalid permission set name */
110ecd6cf80Smarks 	EZFS_NODELEGATION,	/* delegated administration is disabled */
111da6c28aaSamw 	EZFS_UNSHARESMBFAILED,	/* failed to unshare over smb */
112da6c28aaSamw 	EZFS_SHARESMBFAILED,	/* failed to share over smb */
1132f8aaab3Seschrock 	EZFS_BADCACHE,		/* bad cache file */
114fa94a07fSbrendan 	EZFS_ISL2CACHE,		/* device is for the level 2 ARC */
115e7cbe64fSgw 	EZFS_VDEVNOTSUP,	/* unsupported vdev type */
11615e6edf1Sgw 	EZFS_NOTSUP,		/* ops not supported on this dataset */
11789a89ebfSlling 	EZFS_ACTIVE_SPARE,	/* pool has active shared spare devices */
118e6ca193dSGeorge Wilson 	EZFS_UNPLAYED_LOGS,	/* log device has unplayed logs */
119842727c2SChris Kirby 	EZFS_REFTAG_RELE,	/* snapshot release: tag not found */
120842727c2SChris Kirby 	EZFS_REFTAG_HOLD,	/* snapshot hold: tag already exists */
121ca45db41SChris Kirby 	EZFS_TAGTOOLONG,	/* snapshot hold/rele: tag too long */
1229e69d7d0SLori Alt 	EZFS_PIPEFAILED,	/* pipe create failed */
1239e69d7d0SLori Alt 	EZFS_THREADCREATEFAILED, /* thread create failed */
1241195e687SMark J Musante 	EZFS_POSTSPLIT_ONLINE,	/* onlining a disk after splitting it */
1253f9d6ad7SLin Ling 	EZFS_SCRUBBING,		/* currently scrubbing */
1263f9d6ad7SLin Ling 	EZFS_NO_SCRUB,		/* no active scrub */
12799d5e173STim Haley 	EZFS_DIFF,		/* general failure of zfs diff */
12899d5e173STim Haley 	EZFS_DIFFDATA,		/* bad zfs diff data */
129f9af39baSGeorge Wilson 	EZFS_POOLREADONLY,	/* pool is in read-only mode */
130b1b8ab34Slling 	EZFS_UNKNOWN
1314445fffbSMatthew Ahrens } zfs_error_t;
13299653d4eSeschrock 
133ecd6cf80Smarks /*
134ecd6cf80Smarks  * The following data structures are all part
135ecd6cf80Smarks  * of the zfs_allow_t data structure which is
136ecd6cf80Smarks  * used for printing 'allow' permissions.
137ecd6cf80Smarks  * It is a linked list of zfs_allow_t's which
138ecd6cf80Smarks  * then contain avl tree's for user/group/sets/...
139ecd6cf80Smarks  * and each one of the entries in those trees have
140ecd6cf80Smarks  * avl tree's for the permissions they belong to and
141ecd6cf80Smarks  * whether they are local,descendent or local+descendent
142ecd6cf80Smarks  * permissions.  The AVL trees are used primarily for
143ecd6cf80Smarks  * sorting purposes, but also so that we can quickly find
144ecd6cf80Smarks  * a given user and or permission.
145ecd6cf80Smarks  */
146ecd6cf80Smarks typedef struct zfs_perm_node {
147ecd6cf80Smarks 	avl_node_t z_node;
148ecd6cf80Smarks 	char z_pname[MAXPATHLEN];
149ecd6cf80Smarks } zfs_perm_node_t;
150ecd6cf80Smarks 
151ecd6cf80Smarks typedef struct zfs_allow_node {
152ecd6cf80Smarks 	avl_node_t z_node;
153ecd6cf80Smarks 	char z_key[MAXPATHLEN];		/* name, such as joe */
154ecd6cf80Smarks 	avl_tree_t z_localdescend;	/* local+descendent perms */
155ecd6cf80Smarks 	avl_tree_t z_local;		/* local permissions */
156ecd6cf80Smarks 	avl_tree_t z_descend;		/* descendent permissions */
157ecd6cf80Smarks } zfs_allow_node_t;
158ecd6cf80Smarks 
159ecd6cf80Smarks typedef struct zfs_allow {
160ecd6cf80Smarks 	struct zfs_allow *z_next;
161ecd6cf80Smarks 	char z_setpoint[MAXPATHLEN];
162ecd6cf80Smarks 	avl_tree_t z_sets;
163ecd6cf80Smarks 	avl_tree_t z_crperms;
164ecd6cf80Smarks 	avl_tree_t z_user;
165ecd6cf80Smarks 	avl_tree_t z_group;
166ecd6cf80Smarks 	avl_tree_t z_everyone;
167ecd6cf80Smarks } zfs_allow_t;
168ecd6cf80Smarks 
169fa9e4066Sahrens /*
170fa9e4066Sahrens  * Basic handle types
171fa9e4066Sahrens  */
172fa9e4066Sahrens typedef struct zfs_handle zfs_handle_t;
173fa9e4066Sahrens typedef struct zpool_handle zpool_handle_t;
17499653d4eSeschrock typedef struct libzfs_handle libzfs_handle_t;
17599653d4eSeschrock 
17699653d4eSeschrock /*
17799653d4eSeschrock  * Library initialization
17899653d4eSeschrock  */
17999653d4eSeschrock extern libzfs_handle_t *libzfs_init(void);
18099653d4eSeschrock extern void libzfs_fini(libzfs_handle_t *);
18199653d4eSeschrock 
18299653d4eSeschrock extern libzfs_handle_t *zpool_get_handle(zpool_handle_t *);
18399653d4eSeschrock extern libzfs_handle_t *zfs_get_handle(zfs_handle_t *);
18499653d4eSeschrock 
18599653d4eSeschrock extern void libzfs_print_on_error(libzfs_handle_t *, boolean_t);
18699653d4eSeschrock 
1874445fffbSMatthew Ahrens extern void zfs_save_arguments(int argc, char **, char *, int);
1884445fffbSMatthew Ahrens extern int zpool_log_history(libzfs_handle_t *, const char *);
1894445fffbSMatthew Ahrens 
19099653d4eSeschrock extern int libzfs_errno(libzfs_handle_t *);
19199653d4eSeschrock extern const char *libzfs_error_action(libzfs_handle_t *);
19299653d4eSeschrock extern const char *libzfs_error_description(libzfs_handle_t *);
193ebedde84SEric Taylor extern void libzfs_mnttab_init(libzfs_handle_t *);
194ebedde84SEric Taylor extern void libzfs_mnttab_fini(libzfs_handle_t *);
195b2634b9cSEric Taylor extern void libzfs_mnttab_cache(libzfs_handle_t *, boolean_t);
196ebedde84SEric Taylor extern int libzfs_mnttab_find(libzfs_handle_t *, const char *,
197ebedde84SEric Taylor     struct mnttab *);
198ebedde84SEric Taylor extern void libzfs_mnttab_add(libzfs_handle_t *, const char *,
199ebedde84SEric Taylor     const char *, const char *);
200ebedde84SEric Taylor extern void libzfs_mnttab_remove(libzfs_handle_t *, const char *);
201fa9e4066Sahrens 
202fa9e4066Sahrens /*
203fa9e4066Sahrens  * Basic handle functions
204fa9e4066Sahrens  */
20599653d4eSeschrock extern zpool_handle_t *zpool_open(libzfs_handle_t *, const char *);
20699653d4eSeschrock extern zpool_handle_t *zpool_open_canfail(libzfs_handle_t *, const char *);
207fa9e4066Sahrens extern void zpool_close(zpool_handle_t *);
208fa9e4066Sahrens extern const char *zpool_get_name(zpool_handle_t *);
209fa9e4066Sahrens extern int zpool_get_state(zpool_handle_t *);
210990b4856Slling extern char *zpool_state_to_name(vdev_state_t, vdev_aux_t);
21129ab75c9Srm extern void zpool_free_handles(libzfs_handle_t *);
212fa9e4066Sahrens 
213fa9e4066Sahrens /*
214fa9e4066Sahrens  * Iterate over all active pools in the system.
215fa9e4066Sahrens  */
216fa9e4066Sahrens typedef int (*zpool_iter_f)(zpool_handle_t *, void *);
21799653d4eSeschrock extern int zpool_iter(libzfs_handle_t *, zpool_iter_f, void *);
218fa9e4066Sahrens 
219fa9e4066Sahrens /*
220fa9e4066Sahrens  * Functions to create and destroy pools
221fa9e4066Sahrens  */
22299653d4eSeschrock extern int zpool_create(libzfs_handle_t *, const char *, nvlist_t *,
2230a48a24eStimh     nvlist_t *, nvlist_t *);
2244445fffbSMatthew Ahrens extern int zpool_destroy(zpool_handle_t *, const char *);
225fa9e4066Sahrens extern int zpool_add(zpool_handle_t *, nvlist_t *);
226fa9e4066Sahrens 
2271195e687SMark J Musante typedef struct splitflags {
2281195e687SMark J Musante 	/* do not split, but return the config that would be split off */
2291195e687SMark J Musante 	int dryrun : 1;
2301195e687SMark J Musante 
2311195e687SMark J Musante 	/* after splitting, import the pool */
2321195e687SMark J Musante 	int import : 1;
2331195e687SMark J Musante } splitflags_t;
2341195e687SMark J Musante 
235fa9e4066Sahrens /*
236fa9e4066Sahrens  * Functions to manipulate pool and vdev state
237fa9e4066Sahrens  */
2383f9d6ad7SLin Ling extern int zpool_scan(zpool_handle_t *, pool_scan_func_t);
239468c413aSTim Haley extern int zpool_clear(zpool_handle_t *, const char *, nvlist_t *);
240e9103aaeSGarrett D'Amore extern int zpool_reguid(zpool_handle_t *);
2414263d13fSGeorge Wilson extern int zpool_reopen(zpool_handle_t *);
242fa9e4066Sahrens 
2433d7072f8Seschrock extern int zpool_vdev_online(zpool_handle_t *, const char *, int,
2443d7072f8Seschrock     vdev_state_t *);
2453d7072f8Seschrock extern int zpool_vdev_offline(zpool_handle_t *, const char *, boolean_t);
2463d7072f8Seschrock extern int zpool_vdev_attach(zpool_handle_t *, const char *,
2473d7072f8Seschrock     const char *, nvlist_t *, int);
248fa9e4066Sahrens extern int zpool_vdev_detach(zpool_handle_t *, const char *);
24999653d4eSeschrock extern int zpool_vdev_remove(zpool_handle_t *, const char *);
2501195e687SMark J Musante extern int zpool_vdev_split(zpool_handle_t *, char *, nvlist_t **, nvlist_t *,
2511195e687SMark J Musante     splitflags_t);
2523d7072f8Seschrock 
253069f55e2SEric Schrock extern int zpool_vdev_fault(zpool_handle_t *, uint64_t, vdev_aux_t);
254069f55e2SEric Schrock extern int zpool_vdev_degrade(zpool_handle_t *, uint64_t, vdev_aux_t);
2553d7072f8Seschrock extern int zpool_vdev_clear(zpool_handle_t *, uint64_t);
2563d7072f8Seschrock 
257fa94a07fSbrendan extern nvlist_t *zpool_find_vdev(zpool_handle_t *, const char *, boolean_t *,
258ee0eb9f2SEric Schrock     boolean_t *, boolean_t *);
259573ca77eSGeorge Wilson extern nvlist_t *zpool_find_vdev_by_physpath(zpool_handle_t *, const char *,
260573ca77eSGeorge Wilson     boolean_t *, boolean_t *, boolean_t *);
2618488aeb5Staylor extern int zpool_label_disk(libzfs_handle_t *, zpool_handle_t *, char *);
262fa9e4066Sahrens 
263b1b8ab34Slling /*
264b1b8ab34Slling  * Functions to manage pool properties
265b1b8ab34Slling  */
266b1b8ab34Slling extern int zpool_set_prop(zpool_handle_t *, const char *, const char *);
2673d7072f8Seschrock extern int zpool_get_prop(zpool_handle_t *, zpool_prop_t, char *,
268990b4856Slling     size_t proplen, zprop_source_t *);
269990b4856Slling extern uint64_t zpool_get_prop_int(zpool_handle_t *, zpool_prop_t,
270990b4856Slling     zprop_source_t *);
271990b4856Slling 
272b1b8ab34Slling extern const char *zpool_prop_to_name(zpool_prop_t);
273b1b8ab34Slling extern const char *zpool_prop_values(zpool_prop_t);
274b1b8ab34Slling 
275fa9e4066Sahrens /*
276fa9e4066Sahrens  * Pool health statistics.
277fa9e4066Sahrens  */
278fa9e4066Sahrens typedef enum {
279fa9e4066Sahrens 	/*
280fa9e4066Sahrens 	 * The following correspond to faults as defined in the (fault.fs.zfs.*)
281b81d61a6Slling 	 * event namespace.  Each is associated with a corresponding message ID.
282fa9e4066Sahrens 	 */
283fa9e4066Sahrens 	ZPOOL_STATUS_CORRUPT_CACHE,	/* corrupt /kernel/drv/zpool.cache */
284fa9e4066Sahrens 	ZPOOL_STATUS_MISSING_DEV_R,	/* missing device with replicas */
285fa9e4066Sahrens 	ZPOOL_STATUS_MISSING_DEV_NR,	/* missing device with no replicas */
286fa9e4066Sahrens 	ZPOOL_STATUS_CORRUPT_LABEL_R,	/* bad device label with replicas */
287b81d61a6Slling 	ZPOOL_STATUS_CORRUPT_LABEL_NR,	/* bad device label with no replicas */
288fa9e4066Sahrens 	ZPOOL_STATUS_BAD_GUID_SUM,	/* sum of device guids didn't match */
289fa9e4066Sahrens 	ZPOOL_STATUS_CORRUPT_POOL,	/* pool metadata is corrupted */
290fa9e4066Sahrens 	ZPOOL_STATUS_CORRUPT_DATA,	/* data errors in user (meta)data */
291fa9e4066Sahrens 	ZPOOL_STATUS_FAILING_DEV,	/* device experiencing errors */
292eaca9bbdSeschrock 	ZPOOL_STATUS_VERSION_NEWER,	/* newer on-disk version */
29395173954Sek 	ZPOOL_STATUS_HOSTID_MISMATCH,	/* last accessed by another system */
29432b87932Sek 	ZPOOL_STATUS_IO_FAILURE_WAIT,	/* failed I/O, failmode 'wait' */
29532b87932Sek 	ZPOOL_STATUS_IO_FAILURE_CONTINUE, /* failed I/O, failmode 'continue' */
296f67f35c3SEric Schrock 	ZPOOL_STATUS_BAD_LOG,		/* cannot read log chain(s) */
297f67f35c3SEric Schrock 
298ad135b5dSChristopher Siden 	/*
299ad135b5dSChristopher Siden 	 * If the pool has unsupported features but can still be opened in
300ad135b5dSChristopher Siden 	 * read-only mode, its status is ZPOOL_STATUS_UNSUP_FEAT_WRITE. If the
301ad135b5dSChristopher Siden 	 * pool has unsupported features but cannot be opened at all, its
302ad135b5dSChristopher Siden 	 * status is ZPOOL_STATUS_UNSUP_FEAT_READ.
303ad135b5dSChristopher Siden 	 */
304ad135b5dSChristopher Siden 	ZPOOL_STATUS_UNSUP_FEAT_READ,	/* unsupported features for read */
305ad135b5dSChristopher Siden 	ZPOOL_STATUS_UNSUP_FEAT_WRITE,	/* unsupported features for write */
306ad135b5dSChristopher Siden 
307f67f35c3SEric Schrock 	/*
308f67f35c3SEric Schrock 	 * These faults have no corresponding message ID.  At the time we are
309f67f35c3SEric Schrock 	 * checking the status, the original reason for the FMA fault (I/O or
310f67f35c3SEric Schrock 	 * checksum errors) has been lost.
311f67f35c3SEric Schrock 	 */
3123d7072f8Seschrock 	ZPOOL_STATUS_FAULTED_DEV_R,	/* faulted device with replicas */
3133d7072f8Seschrock 	ZPOOL_STATUS_FAULTED_DEV_NR,	/* faulted device with no replicas */
314fa9e4066Sahrens 
315fa9e4066Sahrens 	/*
316fa9e4066Sahrens 	 * The following are not faults per se, but still an error possibly
317b81d61a6Slling 	 * requiring administrative attention.  There is no corresponding
318fa9e4066Sahrens 	 * message ID.
319fa9e4066Sahrens 	 */
32057221772SChristopher Siden 	ZPOOL_STATUS_VERSION_OLDER,	/* older legacy on-disk version */
32157221772SChristopher Siden 	ZPOOL_STATUS_FEAT_DISABLED,	/* supported features are disabled */
322fa9e4066Sahrens 	ZPOOL_STATUS_RESILVERING,	/* device being resilvered */
323fa9e4066Sahrens 	ZPOOL_STATUS_OFFLINE_DEV,	/* device online */
324c25309d4SGeorge Wilson 	ZPOOL_STATUS_REMOVED_DEV,	/* removed device */
325fa9e4066Sahrens 
326fa9e4066Sahrens 	/*
327fa9e4066Sahrens 	 * Finally, the following indicates a healthy pool.
328fa9e4066Sahrens 	 */
329fa9e4066Sahrens 	ZPOOL_STATUS_OK
330fa9e4066Sahrens } zpool_status_t;
331fa9e4066Sahrens 
332ea8dc4b6Seschrock extern zpool_status_t zpool_get_status(zpool_handle_t *, char **);
333ea8dc4b6Seschrock extern zpool_status_t zpool_import_status(nvlist_t *, char **);
3349eb19f4dSGeorge Wilson extern void zpool_dump_ddt(const ddt_stat_t *dds, const ddt_histogram_t *ddh);
335fa9e4066Sahrens 
336fa9e4066Sahrens /*
337fa9e4066Sahrens  * Statistics and configuration functions.
338fa9e4066Sahrens  */
339ea8dc4b6Seschrock extern nvlist_t *zpool_get_config(zpool_handle_t *, nvlist_t **);
340ad135b5dSChristopher Siden extern nvlist_t *zpool_get_features(zpool_handle_t *);
34194de1d4cSeschrock extern int zpool_refresh_stats(zpool_handle_t *, boolean_t *);
34255434c77Sek extern int zpool_get_errlog(zpool_handle_t *, nvlist_t **);
343ea8dc4b6Seschrock 
344fa9e4066Sahrens /*
345fa9e4066Sahrens  * Import and export functions
346fa9e4066Sahrens  */
3474445fffbSMatthew Ahrens extern int zpool_export(zpool_handle_t *, boolean_t, const char *);
3484445fffbSMatthew Ahrens extern int zpool_export_force(zpool_handle_t *, const char *);
34999653d4eSeschrock extern int zpool_import(libzfs_handle_t *, nvlist_t *, const char *,
350990b4856Slling     char *altroot);
351990b4856Slling extern int zpool_import_props(libzfs_handle_t *, nvlist_t *, const char *,
3524b964adaSGeorge Wilson     nvlist_t *, int);
353ad135b5dSChristopher Siden extern void zpool_print_unsup_feat(nvlist_t *config);
354fa9e4066Sahrens 
355fa9e4066Sahrens /*
356fa9e4066Sahrens  * Search for pools to import
357fa9e4066Sahrens  */
358d41c4376SMark J Musante 
359d41c4376SMark J Musante typedef struct importargs {
360d41c4376SMark J Musante 	char **path;		/* a list of paths to search		*/
361d41c4376SMark J Musante 	int paths;		/* number of paths to search		*/
362d41c4376SMark J Musante 	char *poolname;		/* name of a pool to find		*/
363d41c4376SMark J Musante 	uint64_t guid;		/* guid of a pool to find		*/
364d41c4376SMark J Musante 	char *cachefile;	/* cachefile to use for import		*/
365d41c4376SMark J Musante 	int can_be_active : 1;	/* can the pool be active?		*/
366d41c4376SMark J Musante 	int unique : 1;		/* does 'poolname' already exist?	*/
367d41c4376SMark J Musante 	int exists : 1;		/* set on return if pool already exists	*/
368d41c4376SMark J Musante } importargs_t;
369d41c4376SMark J Musante 
370d41c4376SMark J Musante extern nvlist_t *zpool_search_import(libzfs_handle_t *, importargs_t *);
371d41c4376SMark J Musante 
372d41c4376SMark J Musante /* legacy pool search routines */
37324e697d4Sck extern nvlist_t *zpool_find_import(libzfs_handle_t *, int, char **);
3743a57275aSck extern nvlist_t *zpool_find_import_cached(libzfs_handle_t *, const char *,
375e829d913Sck     char *, uint64_t);
376fa9e4066Sahrens 
377c67d9675Seschrock /*
378c67d9675Seschrock  * Miscellaneous pool functions
379c67d9675Seschrock  */
380ecd6cf80Smarks struct zfs_cmd;
381ecd6cf80Smarks 
3824445fffbSMatthew Ahrens extern const char *zfs_history_event_names[];
3838f18d1faSGeorge Wilson 
38488ecc943SGeorge Wilson extern char *zpool_vdev_name(libzfs_handle_t *, zpool_handle_t *, nvlist_t *,
38588ecc943SGeorge Wilson     boolean_t verbose);
386990b4856Slling extern int zpool_upgrade(zpool_handle_t *, uint64_t);
38706eeb2adSek extern int zpool_get_history(zpool_handle_t *, nvlist_t **);
3888f18d1faSGeorge Wilson extern int zpool_history_unpack(char *, uint64_t, uint64_t *,
3898f18d1faSGeorge Wilson     nvlist_t ***, uint_t *);
39055434c77Sek extern void zpool_obj_to_path(zpool_handle_t *, uint64_t, uint64_t, char *,
39155434c77Sek     size_t len);
392ecd6cf80Smarks extern int zfs_ioctl(libzfs_handle_t *, int, struct zfs_cmd *);
393753a6d45SSherry Moore extern int zpool_get_physpath(zpool_handle_t *, char *, size_t);
394468c413aSTim Haley extern void zpool_explain_recover(libzfs_handle_t *, const char *, int,
395468c413aSTim Haley     nvlist_t *);
396753a6d45SSherry Moore 
397fa9e4066Sahrens /*
398fa9e4066Sahrens  * Basic handle manipulations.  These functions do not create or destroy the
399fa9e4066Sahrens  * underlying datasets, only the references to them.
400fa9e4066Sahrens  */
40199653d4eSeschrock extern zfs_handle_t *zfs_open(libzfs_handle_t *, const char *, int);
40219b94df9SMatthew Ahrens extern zfs_handle_t *zfs_handle_dup(zfs_handle_t *);
403fa9e4066Sahrens extern void zfs_close(zfs_handle_t *);
404fa9e4066Sahrens extern zfs_type_t zfs_get_type(const zfs_handle_t *);
405fa9e4066Sahrens extern const char *zfs_get_name(const zfs_handle_t *);
406d5b5bb25SRich Morris extern zpool_handle_t *zfs_get_pool_handle(const zfs_handle_t *);
407fa9e4066Sahrens 
408fa9e4066Sahrens /*
409fa9e4066Sahrens  * Property management functions.  Some functions are shared with the kernel,
410b81d61a6Slling  * and are found in sys/fs/zfs.h.
411fa9e4066Sahrens  */
412990b4856Slling 
413990b4856Slling /*
414990b4856Slling  * zfs dataset property management
415990b4856Slling  */
416990b4856Slling extern const char *zfs_prop_default_string(zfs_prop_t);
417990b4856Slling extern uint64_t zfs_prop_default_numeric(zfs_prop_t);
418990b4856Slling extern const char *zfs_prop_column_name(zfs_prop_t);
419990b4856Slling extern boolean_t zfs_prop_align_right(zfs_prop_t);
420990b4856Slling 
4210a48a24eStimh extern nvlist_t *zfs_valid_proplist(libzfs_handle_t *, zfs_type_t,
4220a48a24eStimh     nvlist_t *, uint64_t, zfs_handle_t *, const char *);
4230a48a24eStimh 
424e9dbad6fSeschrock extern const char *zfs_prop_to_name(zfs_prop_t);
425e9dbad6fSeschrock extern int zfs_prop_set(zfs_handle_t *, const char *, const char *);
426e9dbad6fSeschrock extern int zfs_prop_get(zfs_handle_t *, zfs_prop_t, char *, size_t,
427990b4856Slling     zprop_source_t *, char *, size_t, boolean_t);
42892241e0bSTom Erickson extern int zfs_prop_get_recvd(zfs_handle_t *, const char *, char *, size_t,
42992241e0bSTom Erickson     boolean_t);
430e9dbad6fSeschrock extern int zfs_prop_get_numeric(zfs_handle_t *, zfs_prop_t, uint64_t *,
431990b4856Slling     zprop_source_t *, char *, size_t);
432edea4b55SLin Ling extern int zfs_prop_get_userquota_int(zfs_handle_t *zhp, const char *propname,
433edea4b55SLin Ling     uint64_t *propvalue);
43414843421SMatthew Ahrens extern int zfs_prop_get_userquota(zfs_handle_t *zhp, const char *propname,
43514843421SMatthew Ahrens     char *propbuf, int proplen, boolean_t literal);
43619b94df9SMatthew Ahrens extern int zfs_prop_get_written_int(zfs_handle_t *zhp, const char *propname,
43719b94df9SMatthew Ahrens     uint64_t *propvalue);
43819b94df9SMatthew Ahrens extern int zfs_prop_get_written(zfs_handle_t *zhp, const char *propname,
43919b94df9SMatthew Ahrens     char *propbuf, int proplen, boolean_t literal);
440ad135b5dSChristopher Siden extern int zfs_prop_get_feature(zfs_handle_t *zhp, const char *propname,
441ad135b5dSChristopher Siden     char *buf, size_t len);
442e9dbad6fSeschrock extern uint64_t zfs_prop_get_int(zfs_handle_t *, zfs_prop_t);
44392241e0bSTom Erickson extern int zfs_prop_inherit(zfs_handle_t *, const char *, boolean_t);
444e9dbad6fSeschrock extern const char *zfs_prop_values(zfs_prop_t);
445e9dbad6fSeschrock extern int zfs_prop_is_string(zfs_prop_t prop);
446990b4856Slling extern nvlist_t *zfs_get_user_props(zfs_handle_t *);
44792241e0bSTom Erickson extern nvlist_t *zfs_get_recvd_props(zfs_handle_t *);
44819b94df9SMatthew Ahrens extern nvlist_t *zfs_get_clones_nvl(zfs_handle_t *);
44919b94df9SMatthew Ahrens 
450e9dbad6fSeschrock 
451990b4856Slling typedef struct zprop_list {
452990b4856Slling 	int		pl_prop;
453e9dbad6fSeschrock 	char		*pl_user_prop;
454990b4856Slling 	struct zprop_list *pl_next;
455e9dbad6fSeschrock 	boolean_t	pl_all;
456e9dbad6fSeschrock 	size_t		pl_width;
45792241e0bSTom Erickson 	size_t		pl_recvd_width;
458e9dbad6fSeschrock 	boolean_t	pl_fixed;
459990b4856Slling } zprop_list_t;
460e9dbad6fSeschrock 
461*43d68d68SYuri Pankov extern int zfs_expand_proplist(zfs_handle_t *, zprop_list_t **, boolean_t,
462*43d68d68SYuri Pankov     boolean_t);
4632e5e9e19SSanjeev Bagewadi extern void zfs_prune_proplist(zfs_handle_t *, uint8_t *);
464fa9e4066Sahrens 
465fa9e4066Sahrens #define	ZFS_MOUNTPOINT_NONE	"none"
466fa9e4066Sahrens #define	ZFS_MOUNTPOINT_LEGACY	"legacy"
467fa9e4066Sahrens 
468ad135b5dSChristopher Siden #define	ZFS_FEATURE_DISABLED	"disabled"
469ad135b5dSChristopher Siden #define	ZFS_FEATURE_ENABLED	"enabled"
470ad135b5dSChristopher Siden #define	ZFS_FEATURE_ACTIVE	"active"
471ad135b5dSChristopher Siden 
472ad135b5dSChristopher Siden #define	ZFS_UNSUPPORTED_INACTIVE	"inactive"
473ad135b5dSChristopher Siden #define	ZFS_UNSUPPORTED_READONLY	"readonly"
474ad135b5dSChristopher Siden 
475b1b8ab34Slling /*
476990b4856Slling  * zpool property management
477990b4856Slling  */
478990b4856Slling extern int zpool_expand_proplist(zpool_handle_t *, zprop_list_t **);
479ad135b5dSChristopher Siden extern int zpool_prop_get_feature(zpool_handle_t *, const char *, char *,
480ad135b5dSChristopher Siden     size_t);
481990b4856Slling extern const char *zpool_prop_default_string(zpool_prop_t);
482990b4856Slling extern uint64_t zpool_prop_default_numeric(zpool_prop_t);
483990b4856Slling extern const char *zpool_prop_column_name(zpool_prop_t);
484990b4856Slling extern boolean_t zpool_prop_align_right(zpool_prop_t);
485990b4856Slling 
486990b4856Slling /*
487990b4856Slling  * Functions shared by zfs and zpool property management.
488b1b8ab34Slling  */
489990b4856Slling extern int zprop_iter(zprop_func func, void *cb, boolean_t show_all,
490990b4856Slling     boolean_t ordered, zfs_type_t type);
491990b4856Slling extern int zprop_get_list(libzfs_handle_t *, char *, zprop_list_t **,
492990b4856Slling     zfs_type_t);
493990b4856Slling extern void zprop_free_list(zprop_list_t *);
494990b4856Slling 
49592241e0bSTom Erickson #define	ZFS_GET_NCOLS	5
49692241e0bSTom Erickson 
49792241e0bSTom Erickson typedef enum {
49892241e0bSTom Erickson 	GET_COL_NONE,
49992241e0bSTom Erickson 	GET_COL_NAME,
50092241e0bSTom Erickson 	GET_COL_PROPERTY,
50192241e0bSTom Erickson 	GET_COL_VALUE,
50292241e0bSTom Erickson 	GET_COL_RECVD,
50392241e0bSTom Erickson 	GET_COL_SOURCE
50492241e0bSTom Erickson } zfs_get_column_t;
50592241e0bSTom Erickson 
506990b4856Slling /*
507990b4856Slling  * Functions for printing zfs or zpool properties
508990b4856Slling  */
509990b4856Slling typedef struct zprop_get_cbdata {
510b1b8ab34Slling 	int cb_sources;
51192241e0bSTom Erickson 	zfs_get_column_t cb_columns[ZFS_GET_NCOLS];
51292241e0bSTom Erickson 	int cb_colwidths[ZFS_GET_NCOLS + 1];
513b1b8ab34Slling 	boolean_t cb_scripted;
514b1b8ab34Slling 	boolean_t cb_literal;
515b1b8ab34Slling 	boolean_t cb_first;
516990b4856Slling 	zprop_list_t *cb_proplist;
517990b4856Slling 	zfs_type_t cb_type;
518990b4856Slling } zprop_get_cbdata_t;
519b1b8ab34Slling 
520990b4856Slling void zprop_print_one_property(const char *, zprop_get_cbdata_t *,
52192241e0bSTom Erickson     const char *, const char *, zprop_source_t, const char *,
52292241e0bSTom Erickson     const char *);
523b1b8ab34Slling 
524fa9e4066Sahrens /*
525fa9e4066Sahrens  * Iterator functions.
526fa9e4066Sahrens  */
527fa9e4066Sahrens typedef int (*zfs_iter_f)(zfs_handle_t *, void *);
52899653d4eSeschrock extern int zfs_iter_root(libzfs_handle_t *, zfs_iter_f, void *);
529fa9e4066Sahrens extern int zfs_iter_children(zfs_handle_t *, zfs_iter_f, void *);
5303bb79becSeschrock extern int zfs_iter_dependents(zfs_handle_t *, boolean_t, zfs_iter_f, void *);
5317f7322feSeschrock extern int zfs_iter_filesystems(zfs_handle_t *, zfs_iter_f, void *);
5327f7322feSeschrock extern int zfs_iter_snapshots(zfs_handle_t *, zfs_iter_f, void *);
533ca45db41SChris Kirby extern int zfs_iter_snapshots_sorted(zfs_handle_t *, zfs_iter_f, void *);
53419b94df9SMatthew Ahrens extern int zfs_iter_snapspec(zfs_handle_t *, const char *, zfs_iter_f, void *);
535fa9e4066Sahrens 
5369d9a58e3SEric Taylor typedef struct get_all_cb {
5379d9a58e3SEric Taylor 	zfs_handle_t	**cb_handles;
5389d9a58e3SEric Taylor 	size_t		cb_alloc;
5399d9a58e3SEric Taylor 	size_t		cb_used;
5409d9a58e3SEric Taylor 	boolean_t	cb_verbose;
5419d9a58e3SEric Taylor 	int		(*cb_getone)(zfs_handle_t *, void *);
5429d9a58e3SEric Taylor } get_all_cb_t;
5439d9a58e3SEric Taylor 
5449d9a58e3SEric Taylor void libzfs_add_handle(get_all_cb_t *, zfs_handle_t *);
5459d9a58e3SEric Taylor int libzfs_dataset_cmp(const void *, const void *);
5469d9a58e3SEric Taylor 
547fa9e4066Sahrens /*
548fa9e4066Sahrens  * Functions to create and destroy datasets.
549fa9e4066Sahrens  */
55099653d4eSeschrock extern int zfs_create(libzfs_handle_t *, const char *, zfs_type_t,
551e9dbad6fSeschrock     nvlist_t *);
5527f1f55eaSvb extern int zfs_create_ancestors(libzfs_handle_t *, const char *);
553842727c2SChris Kirby extern int zfs_destroy(zfs_handle_t *, boolean_t);
554842727c2SChris Kirby extern int zfs_destroy_snaps(zfs_handle_t *, char *, boolean_t);
5553b2aab18SMatthew Ahrens extern int zfs_destroy_snaps_nvl(libzfs_handle_t *, nvlist_t *, boolean_t);
556e9dbad6fSeschrock extern int zfs_clone(zfs_handle_t *, const char *, nvlist_t *);
557bb0ade09Sahrens extern int zfs_snapshot(libzfs_handle_t *, const char *, boolean_t, nvlist_t *);
5584445fffbSMatthew Ahrens extern int zfs_snapshot_nvl(libzfs_handle_t *hdl, nvlist_t *snaps,
5594445fffbSMatthew Ahrens     nvlist_t *props);
560c391e322Sahrens extern int zfs_rollback(zfs_handle_t *, zfs_handle_t *, boolean_t);
5616a9cb0eaSEric Schrock extern int zfs_rename(zfs_handle_t *, const char *, boolean_t, boolean_t);
5629e69d7d0SLori Alt 
5639e69d7d0SLori Alt typedef struct sendflags {
5649e69d7d0SLori Alt 	/* print informational messages (ie, -v was specified) */
56519b94df9SMatthew Ahrens 	boolean_t verbose;
5669e69d7d0SLori Alt 
56792241e0bSTom Erickson 	/* recursive send  (ie, -R) */
56819b94df9SMatthew Ahrens 	boolean_t replicate;
5699e69d7d0SLori Alt 
5709e69d7d0SLori Alt 	/* for incrementals, do all intermediate snapshots */
57119b94df9SMatthew Ahrens 	boolean_t doall;
5729e69d7d0SLori Alt 
5739e69d7d0SLori Alt 	/* if dataset is a clone, do incremental from its origin */
57419b94df9SMatthew Ahrens 	boolean_t fromorigin;
5759e69d7d0SLori Alt 
5769e69d7d0SLori Alt 	/* do deduplication */
57719b94df9SMatthew Ahrens 	boolean_t dedup;
57892241e0bSTom Erickson 
57992241e0bSTom Erickson 	/* send properties (ie, -p) */
58019b94df9SMatthew Ahrens 	boolean_t props;
58119b94df9SMatthew Ahrens 
58219b94df9SMatthew Ahrens 	/* do not send (no-op, ie. -n) */
58319b94df9SMatthew Ahrens 	boolean_t dryrun;
58419b94df9SMatthew Ahrens 
58519b94df9SMatthew Ahrens 	/* parsable verbose output (ie. -P) */
58619b94df9SMatthew Ahrens 	boolean_t parsable;
5874e3c9f44SBill Pijewski 
5884e3c9f44SBill Pijewski 	/* show progress (ie. -v) */
5894e3c9f44SBill Pijewski 	boolean_t progress;
5909e69d7d0SLori Alt } sendflags_t;
5919e69d7d0SLori Alt 
5929e69d7d0SLori Alt typedef boolean_t (snapfilter_cb_t)(zfs_handle_t *, void *);
5939e69d7d0SLori Alt 
59419b94df9SMatthew Ahrens extern int zfs_send(zfs_handle_t *, const char *, const char *,
59519b94df9SMatthew Ahrens     sendflags_t *, int, snapfilter_cb_t, void *, nvlist_t **);
5969e69d7d0SLori Alt 
59799653d4eSeschrock extern int zfs_promote(zfs_handle_t *);
5983b2aab18SMatthew Ahrens extern int zfs_hold(zfs_handle_t *, const char *, const char *,
599a7a845e4SSteven Hartland     boolean_t, int);
600a7a845e4SSteven Hartland extern int zfs_hold_nvl(zfs_handle_t *, int, nvlist_t *);
601842727c2SChris Kirby extern int zfs_release(zfs_handle_t *, const char *, const char *, boolean_t);
6021af68beaSAlexander Stetsenko extern int zfs_get_holds(zfs_handle_t *, nvlist_t **);
603c1449561SEric Taylor extern uint64_t zvol_volsize_to_reservation(uint64_t, nvlist_t *);
604fa9e4066Sahrens 
6050aea4b19SMatthew Ahrens typedef int (*zfs_userspace_cb_t)(void *arg, const char *domain,
60614843421SMatthew Ahrens     uid_t rid, uint64_t space);
60714843421SMatthew Ahrens 
6081af68beaSAlexander Stetsenko extern int zfs_userspace(zfs_handle_t *, zfs_userquota_prop_t,
6091af68beaSAlexander Stetsenko     zfs_userspace_cb_t, void *);
6101af68beaSAlexander Stetsenko 
6111af68beaSAlexander Stetsenko extern int zfs_get_fsacl(zfs_handle_t *, nvlist_t **);
6121af68beaSAlexander Stetsenko extern int zfs_set_fsacl(zfs_handle_t *, boolean_t, nvlist_t *);
61314843421SMatthew Ahrens 
6143cb34c60Sahrens typedef struct recvflags {
6154ccbb6e7Sahrens 	/* print informational messages (ie, -v was specified) */
61619b94df9SMatthew Ahrens 	boolean_t verbose;
6174ccbb6e7Sahrens 
6184ccbb6e7Sahrens 	/* the destination is a prefix, not the exact fs (ie, -d) */
61919b94df9SMatthew Ahrens 	boolean_t isprefix;
6204ccbb6e7Sahrens 
621f64930f5STom Erickson 	/*
622f64930f5STom Erickson 	 * Only the tail of the sent snapshot path is appended to the
623f64930f5STom Erickson 	 * destination to determine the received snapshot name (ie, -e).
624f64930f5STom Erickson 	 */
62519b94df9SMatthew Ahrens 	boolean_t istail;
626f64930f5STom Erickson 
6274ccbb6e7Sahrens 	/* do not actually do the recv, just check if it would work (ie, -n) */
62819b94df9SMatthew Ahrens 	boolean_t dryrun;
6294ccbb6e7Sahrens 
6304ccbb6e7Sahrens 	/* rollback/destroy filesystems as necessary (eg, -F) */
63119b94df9SMatthew Ahrens 	boolean_t force;
6324ccbb6e7Sahrens 
6334ccbb6e7Sahrens 	/* set "canmount=off" on all modified filesystems */
63419b94df9SMatthew Ahrens 	boolean_t canmountoff;
6354ccbb6e7Sahrens 
6364ccbb6e7Sahrens 	/* byteswap flag is used internally; callers need not specify */
63719b94df9SMatthew Ahrens 	boolean_t byteswap;
63833408eefSLori Alt 
63933408eefSLori Alt 	/* do not mount file systems as they are extracted (private) */
64019b94df9SMatthew Ahrens 	boolean_t nomount;
6413cb34c60Sahrens } recvflags_t;
6423cb34c60Sahrens 
64319b94df9SMatthew Ahrens extern int zfs_receive(libzfs_handle_t *, const char *, recvflags_t *,
6443cb34c60Sahrens     int, avl_tree_t *);
6453cb34c60Sahrens 
64699d5e173STim Haley typedef enum diff_flags {
64799d5e173STim Haley 	ZFS_DIFF_PARSEABLE = 0x1,
64899d5e173STim Haley 	ZFS_DIFF_TIMESTAMP = 0x2,
64999d5e173STim Haley 	ZFS_DIFF_CLASSIFY = 0x4
65099d5e173STim Haley } diff_flags_t;
65199d5e173STim Haley 
65299d5e173STim Haley extern int zfs_show_diffs(zfs_handle_t *, int, const char *, const char *,
65399d5e173STim Haley     int);
65499d5e173STim Haley 
655fa9e4066Sahrens /*
656fa9e4066Sahrens  * Miscellaneous functions.
657fa9e4066Sahrens  */
658fa9e4066Sahrens extern const char *zfs_type_to_name(zfs_type_t);
659fa9e4066Sahrens extern void zfs_refresh_properties(zfs_handle_t *);
660fa9e4066Sahrens extern int zfs_name_valid(const char *, zfs_type_t);
6615aba80dbSck extern zfs_handle_t *zfs_path_to_zhandle(libzfs_handle_t *, char *, zfs_type_t);
6627f1f55eaSvb extern boolean_t zfs_dataset_exists(libzfs_handle_t *, const char *,
6637f1f55eaSvb     zfs_type_t);
6647b97dc1aSrm extern int zfs_spa_version(zfs_handle_t *, int *);
665fa9e4066Sahrens 
666fa9e4066Sahrens /*
667fa9e4066Sahrens  * Mount support functions.
668fa9e4066Sahrens  */
66955434c77Sek extern boolean_t is_mounted(libzfs_handle_t *, const char *special, char **);
67099653d4eSeschrock extern boolean_t zfs_is_mounted(zfs_handle_t *, char **);
671fa9e4066Sahrens extern int zfs_mount(zfs_handle_t *, const char *, int);
672fa9e4066Sahrens extern int zfs_unmount(zfs_handle_t *, const char *, int);
673fa9e4066Sahrens extern int zfs_unmountall(zfs_handle_t *, int);
674fa9e4066Sahrens 
675fa9e4066Sahrens /*
676fa9e4066Sahrens  * Share support functions.
677fa9e4066Sahrens  */
678f3861e1aSahl extern boolean_t zfs_is_shared(zfs_handle_t *);
679fa9e4066Sahrens extern int zfs_share(zfs_handle_t *);
680f3861e1aSahl extern int zfs_unshare(zfs_handle_t *);
681f3861e1aSahl 
682f3861e1aSahl /*
6833d7072f8Seschrock  * Protocol-specific share support functions.
684f3861e1aSahl  */
685f3861e1aSahl extern boolean_t zfs_is_shared_nfs(zfs_handle_t *, char **);
686da6c28aaSamw extern boolean_t zfs_is_shared_smb(zfs_handle_t *, char **);
687f3861e1aSahl extern int zfs_share_nfs(zfs_handle_t *);
688da6c28aaSamw extern int zfs_share_smb(zfs_handle_t *);
689da6c28aaSamw extern int zfs_shareall(zfs_handle_t *);
690f3861e1aSahl extern int zfs_unshare_nfs(zfs_handle_t *, const char *);
691da6c28aaSamw extern int zfs_unshare_smb(zfs_handle_t *, const char *);
692f3861e1aSahl extern int zfs_unshareall_nfs(zfs_handle_t *);
693da6c28aaSamw extern int zfs_unshareall_smb(zfs_handle_t *);
694da6c28aaSamw extern int zfs_unshareall_bypath(zfs_handle_t *, const char *);
695da6c28aaSamw extern int zfs_unshareall(zfs_handle_t *);
696743a77edSAlan Wright extern int zfs_deleg_share_nfs(libzfs_handle_t *, char *, char *, char *,
697da6c28aaSamw     void *, void *, int, zfs_share_op_t);
698fa9e4066Sahrens 
699fa9e4066Sahrens /*
700fa9e4066Sahrens  * When dealing with nvlists, verify() is extremely useful
701fa9e4066Sahrens  */
702fa9e4066Sahrens #ifdef NDEBUG
703fa9e4066Sahrens #define	verify(EX)	((void)(EX))
704fa9e4066Sahrens #else
705fa9e4066Sahrens #define	verify(EX)	assert(EX)
706fa9e4066Sahrens #endif
707fa9e4066Sahrens 
708fa9e4066Sahrens /*
709fa9e4066Sahrens  * Utility function to convert a number to a human-readable form.
710fa9e4066Sahrens  */
711fa9e4066Sahrens extern void zfs_nicenum(uint64_t, char *, size_t);
712e9dbad6fSeschrock extern int zfs_nicestrtonum(libzfs_handle_t *, const char *, uint64_t *);
713fa9e4066Sahrens 
714fa9e4066Sahrens /*
715fa9e4066Sahrens  * Given a device or file, determine if it is part of a pool.
716fa9e4066Sahrens  */
71799653d4eSeschrock extern int zpool_in_use(libzfs_handle_t *, int, pool_state_t *, char **,
71899653d4eSeschrock     boolean_t *);
719fa9e4066Sahrens 
720fa9e4066Sahrens /*
721096d22d4SEric Schrock  * Label manipulation.
722fa9e4066Sahrens  */
72399653d4eSeschrock extern int zpool_read_label(int, nvlist_t **);
724096d22d4SEric Schrock extern int zpool_clear_label(int);
725fa9e4066Sahrens 
726e7cbe64fSgw /* is this zvol valid for use as a dump device? */
727e7cbe64fSgw extern int zvol_check_dump_config(char *);
728e7cbe64fSgw 
729743a77edSAlan Wright /*
730743a77edSAlan Wright  * Management interfaces for SMB ACL files
731743a77edSAlan Wright  */
732743a77edSAlan Wright 
733743a77edSAlan Wright int zfs_smb_acl_add(libzfs_handle_t *, char *, char *, char *);
734743a77edSAlan Wright int zfs_smb_acl_remove(libzfs_handle_t *, char *, char *, char *);
735743a77edSAlan Wright int zfs_smb_acl_purge(libzfs_handle_t *, char *, char *);
736743a77edSAlan Wright int zfs_smb_acl_rename(libzfs_handle_t *, char *, char *, char *, char *);
737743a77edSAlan Wright 
7383bb79becSeschrock /*
739f3861e1aSahl  * Enable and disable datasets within a pool by mounting/unmounting and
740f3861e1aSahl  * sharing/unsharing them.
7413bb79becSeschrock  */
742f3861e1aSahl extern int zpool_enable_datasets(zpool_handle_t *, const char *, int);
743f3861e1aSahl extern int zpool_disable_datasets(zpool_handle_t *, boolean_t);
7443bb79becSeschrock 
745069f55e2SEric Schrock /*
746069f55e2SEric Schrock  * Mappings between vdev and FRU.
747069f55e2SEric Schrock  */
748069f55e2SEric Schrock extern void libzfs_fru_refresh(libzfs_handle_t *);
749069f55e2SEric Schrock extern const char *libzfs_fru_lookup(libzfs_handle_t *, const char *);
750069f55e2SEric Schrock extern const char *libzfs_fru_devpath(libzfs_handle_t *, const char *);
751069f55e2SEric Schrock extern boolean_t libzfs_fru_compare(libzfs_handle_t *, const char *,
752069f55e2SEric Schrock     const char *);
753069f55e2SEric Schrock extern boolean_t libzfs_fru_notself(libzfs_handle_t *, const char *);
754069f55e2SEric Schrock extern int zpool_fru_set(zpool_handle_t *, uint64_t, const char *);
755069f55e2SEric Schrock 
756fa9e4066Sahrens #ifdef	__cplusplus
757fa9e4066Sahrens }
758fa9e4066Sahrens #endif
759fa9e4066Sahrens 
760fa9e4066Sahrens #endif	/* _LIBZFS_H */
761