xref: /illumos-gate/usr/src/lib/libzfs/common/libzfs.h (revision 7855d95b)
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.
240d8fa8f8SMartin Matuska  * Copyright (c) 2011 Pawel Jakub Dawidek. All rights reserved.
25e9316f76SJoe Stein  * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
264e3c9f44SBill Pijewski  * Copyright (c) 2012, Joyent, Inc. All rights reserved.
27a7a845e4SSteven Hartland  * Copyright (c) 2013 Steven Hartland. All rights reserved.
28c3d26abcSMatthew Ahrens  * Copyright (c) 2014 Integros [integros.com]
298808ac5dSYuri Pankov  * Copyright 2016 Nexenta Systems, Inc.
30fa9e4066Sahrens  */
31fa9e4066Sahrens 
32fa9e4066Sahrens #ifndef	_LIBZFS_H
33fa9e4066Sahrens #define	_LIBZFS_H
34fa9e4066Sahrens 
35fa9e4066Sahrens #include <assert.h>
36fa9e4066Sahrens #include <libnvpair.h>
37ebedde84SEric Taylor #include <sys/mnttab.h>
38fa9e4066Sahrens #include <sys/param.h>
39fa9e4066Sahrens #include <sys/types.h>
40fa9e4066Sahrens #include <sys/varargs.h>
41fa9e4066Sahrens #include <sys/fs/zfs.h>
42ecd6cf80Smarks #include <sys/avl.h>
43ecd6cf80Smarks #include <ucred.h>
445d7b4d43SMatthew Ahrens #include <libzfs_core.h>
45fa9e4066Sahrens 
46fa9e4066Sahrens #ifdef	__cplusplus
47fa9e4066Sahrens extern "C" {
48fa9e4066Sahrens #endif
49fa9e4066Sahrens 
50fa9e4066Sahrens /*
51fa9e4066Sahrens  * Miscellaneous ZFS constants
52fa9e4066Sahrens  */
53fa9e4066Sahrens #define	ZFS_MAXPROPLEN		MAXPATHLEN
54990b4856Slling #define	ZPOOL_MAXPROPLEN	MAXPATHLEN
55fa9e4066Sahrens 
5699653d4eSeschrock /*
5799653d4eSeschrock  * libzfs errors
5899653d4eSeschrock  */
594445fffbSMatthew Ahrens typedef enum zfs_error {
604445fffbSMatthew Ahrens 	EZFS_SUCCESS = 0,	/* no error -- success */
6199653d4eSeschrock 	EZFS_NOMEM = 2000,	/* out of memory */
6299653d4eSeschrock 	EZFS_BADPROP,		/* invalid property value */
6399653d4eSeschrock 	EZFS_PROPREADONLY,	/* cannot set readonly property */
6499653d4eSeschrock 	EZFS_PROPTYPE,		/* property does not apply to dataset type */
6599653d4eSeschrock 	EZFS_PROPNONINHERIT,	/* property is not inheritable */
6699653d4eSeschrock 	EZFS_PROPSPACE,		/* bad quota or reservation */
6799653d4eSeschrock 	EZFS_BADTYPE,		/* dataset is not of appropriate type */
6899653d4eSeschrock 	EZFS_BUSY,		/* pool or dataset is busy */
6999653d4eSeschrock 	EZFS_EXISTS,		/* pool or dataset already exists */
7099653d4eSeschrock 	EZFS_NOENT,		/* no such pool or dataset */
7199653d4eSeschrock 	EZFS_BADSTREAM,		/* bad backup stream */
7299653d4eSeschrock 	EZFS_DSREADONLY,	/* dataset is readonly */
7399653d4eSeschrock 	EZFS_VOLTOOBIG,		/* volume is too large for 32-bit system */
7499653d4eSeschrock 	EZFS_INVALIDNAME,	/* invalid dataset name */
7599653d4eSeschrock 	EZFS_BADRESTORE,	/* unable to restore to destination */
7699653d4eSeschrock 	EZFS_BADBACKUP,		/* backup failed */
7799653d4eSeschrock 	EZFS_BADTARGET,		/* bad attach/detach/replace target */
7899653d4eSeschrock 	EZFS_NODEVICE,		/* no such device in pool */
7999653d4eSeschrock 	EZFS_BADDEV,		/* invalid device to add */
8099653d4eSeschrock 	EZFS_NOREPLICAS,	/* no valid replicas */
8199653d4eSeschrock 	EZFS_RESILVERING,	/* currently resilvering */
8299653d4eSeschrock 	EZFS_BADVERSION,	/* unsupported version */
8399653d4eSeschrock 	EZFS_POOLUNAVAIL,	/* pool is currently unavailable */
8499653d4eSeschrock 	EZFS_DEVOVERFLOW,	/* too many devices in one vdev */
8599653d4eSeschrock 	EZFS_BADPATH,		/* must be an absolute path */
8699653d4eSeschrock 	EZFS_CROSSTARGET,	/* rename or clone across pool or dataset */
8799653d4eSeschrock 	EZFS_ZONED,		/* used improperly in local zone */
8899653d4eSeschrock 	EZFS_MOUNTFAILED,	/* failed to mount dataset */
8999653d4eSeschrock 	EZFS_UMOUNTFAILED,	/* failed to unmount dataset */
90f3861e1aSahl 	EZFS_UNSHARENFSFAILED,	/* unshare(1M) failed */
91f3861e1aSahl 	EZFS_SHARENFSFAILED,	/* share(1M) failed */
9299653d4eSeschrock 	EZFS_PERM,		/* permission denied */
9399653d4eSeschrock 	EZFS_NOSPC,		/* out of space */
946e27f868SSam Falkner 	EZFS_FAULT,		/* bad address */
9599653d4eSeschrock 	EZFS_IO,		/* I/O error */
9699653d4eSeschrock 	EZFS_INTR,		/* signal received */
9799653d4eSeschrock 	EZFS_ISSPARE,		/* device is a hot spare */
9899653d4eSeschrock 	EZFS_INVALCONFIG,	/* invalid vdev configuration */
993bb79becSeschrock 	EZFS_RECURSIVE,		/* recursive dependency */
10006eeb2adSek 	EZFS_NOHISTORY,		/* no history object */
101b1b8ab34Slling 	EZFS_POOLPROPS,		/* couldn't retrieve pool props */
102b1b8ab34Slling 	EZFS_POOL_NOTSUP,	/* ops not supported for this type of pool */
103b1b8ab34Slling 	EZFS_POOL_INVALARG,	/* invalid argument for this pool operation */
104b7661cccSmmusante 	EZFS_NAMETOOLONG,	/* dataset name is too long */
1058488aeb5Staylor 	EZFS_OPENFAILED,	/* open of device failed */
1068488aeb5Staylor 	EZFS_NOCAP,		/* couldn't get capacity */
1078488aeb5Staylor 	EZFS_LABELFAILED,	/* write of label failed */
108ecd6cf80Smarks 	EZFS_BADWHO,		/* invalid permission who */
109ecd6cf80Smarks 	EZFS_BADPERM,		/* invalid permission */
110ecd6cf80Smarks 	EZFS_BADPERMSET,	/* invalid permission set name */
111ecd6cf80Smarks 	EZFS_NODELEGATION,	/* delegated administration is disabled */
112da6c28aaSamw 	EZFS_UNSHARESMBFAILED,	/* failed to unshare over smb */
113da6c28aaSamw 	EZFS_SHARESMBFAILED,	/* failed to share over smb */
1142f8aaab3Seschrock 	EZFS_BADCACHE,		/* bad cache file */
115fa94a07fSbrendan 	EZFS_ISL2CACHE,		/* device is for the level 2 ARC */
116e7cbe64fSgw 	EZFS_VDEVNOTSUP,	/* unsupported vdev type */
11715e6edf1Sgw 	EZFS_NOTSUP,		/* ops not supported on this dataset */
11889a89ebfSlling 	EZFS_ACTIVE_SPARE,	/* pool has active shared spare devices */
119e6ca193dSGeorge Wilson 	EZFS_UNPLAYED_LOGS,	/* log device has unplayed logs */
120842727c2SChris Kirby 	EZFS_REFTAG_RELE,	/* snapshot release: tag not found */
121842727c2SChris Kirby 	EZFS_REFTAG_HOLD,	/* snapshot hold: tag already exists */
122ca45db41SChris Kirby 	EZFS_TAGTOOLONG,	/* snapshot hold/rele: tag too long */
1239e69d7d0SLori Alt 	EZFS_PIPEFAILED,	/* pipe create failed */
1249e69d7d0SLori Alt 	EZFS_THREADCREATEFAILED, /* thread create failed */
1251195e687SMark J Musante 	EZFS_POSTSPLIT_ONLINE,	/* onlining a disk after splitting it */
1263f9d6ad7SLin Ling 	EZFS_SCRUBBING,		/* currently scrubbing */
1273f9d6ad7SLin Ling 	EZFS_NO_SCRUB,		/* no active scrub */
12899d5e173STim Haley 	EZFS_DIFF,		/* general failure of zfs diff */
12999d5e173STim Haley 	EZFS_DIFFDATA,		/* bad zfs diff data */
130f9af39baSGeorge Wilson 	EZFS_POOLREADONLY,	/* pool is in read-only mode */
131b1b8ab34Slling 	EZFS_UNKNOWN
1324445fffbSMatthew Ahrens } zfs_error_t;
13399653d4eSeschrock 
134*7855d95bSToomas Soome /*
135*7855d95bSToomas Soome  * UEFI boot support parameters. When creating whole disk boot pool,
136*7855d95bSToomas Soome  * zpool create should allow to create EFI System partition for UEFI boot
137*7855d95bSToomas Soome  * program. In case of BIOS, the EFI System partition is not used
138*7855d95bSToomas Soome  * even if it does exist.
139*7855d95bSToomas Soome  */
140*7855d95bSToomas Soome typedef enum zpool_boot_label {
141*7855d95bSToomas Soome 	ZPOOL_NO_BOOT_LABEL = 0,
142*7855d95bSToomas Soome 	ZPOOL_CREATE_BOOT_LABEL,
143*7855d95bSToomas Soome 	ZPOOL_COPY_BOOT_LABEL
144*7855d95bSToomas Soome } zpool_boot_label_t;
145*7855d95bSToomas Soome 
146ecd6cf80Smarks /*
147ecd6cf80Smarks  * The following data structures are all part
148ecd6cf80Smarks  * of the zfs_allow_t data structure which is
149ecd6cf80Smarks  * used for printing 'allow' permissions.
150ecd6cf80Smarks  * It is a linked list of zfs_allow_t's which
151ecd6cf80Smarks  * then contain avl tree's for user/group/sets/...
152ecd6cf80Smarks  * and each one of the entries in those trees have
153ecd6cf80Smarks  * avl tree's for the permissions they belong to and
154ecd6cf80Smarks  * whether they are local,descendent or local+descendent
155ecd6cf80Smarks  * permissions.  The AVL trees are used primarily for
156ecd6cf80Smarks  * sorting purposes, but also so that we can quickly find
157ecd6cf80Smarks  * a given user and or permission.
158ecd6cf80Smarks  */
159ecd6cf80Smarks typedef struct zfs_perm_node {
160ecd6cf80Smarks 	avl_node_t z_node;
161ecd6cf80Smarks 	char z_pname[MAXPATHLEN];
162ecd6cf80Smarks } zfs_perm_node_t;
163ecd6cf80Smarks 
164ecd6cf80Smarks typedef struct zfs_allow_node {
165ecd6cf80Smarks 	avl_node_t z_node;
166ecd6cf80Smarks 	char z_key[MAXPATHLEN];		/* name, such as joe */
167ecd6cf80Smarks 	avl_tree_t z_localdescend;	/* local+descendent perms */
168ecd6cf80Smarks 	avl_tree_t z_local;		/* local permissions */
169ecd6cf80Smarks 	avl_tree_t z_descend;		/* descendent permissions */
170ecd6cf80Smarks } zfs_allow_node_t;
171ecd6cf80Smarks 
172ecd6cf80Smarks typedef struct zfs_allow {
173ecd6cf80Smarks 	struct zfs_allow *z_next;
174ecd6cf80Smarks 	char z_setpoint[MAXPATHLEN];
175ecd6cf80Smarks 	avl_tree_t z_sets;
176ecd6cf80Smarks 	avl_tree_t z_crperms;
177ecd6cf80Smarks 	avl_tree_t z_user;
178ecd6cf80Smarks 	avl_tree_t z_group;
179ecd6cf80Smarks 	avl_tree_t z_everyone;
180ecd6cf80Smarks } zfs_allow_t;
181ecd6cf80Smarks 
182fa9e4066Sahrens /*
183fa9e4066Sahrens  * Basic handle types
184fa9e4066Sahrens  */
185fa9e4066Sahrens typedef struct zfs_handle zfs_handle_t;
186fa9e4066Sahrens typedef struct zpool_handle zpool_handle_t;
18799653d4eSeschrock typedef struct libzfs_handle libzfs_handle_t;
18899653d4eSeschrock 
18999653d4eSeschrock /*
19099653d4eSeschrock  * Library initialization
19199653d4eSeschrock  */
19299653d4eSeschrock extern libzfs_handle_t *libzfs_init(void);
19399653d4eSeschrock extern void libzfs_fini(libzfs_handle_t *);
19499653d4eSeschrock 
19599653d4eSeschrock extern libzfs_handle_t *zpool_get_handle(zpool_handle_t *);
19699653d4eSeschrock extern libzfs_handle_t *zfs_get_handle(zfs_handle_t *);
19799653d4eSeschrock 
19899653d4eSeschrock extern void libzfs_print_on_error(libzfs_handle_t *, boolean_t);
19999653d4eSeschrock 
2004445fffbSMatthew Ahrens extern void zfs_save_arguments(int argc, char **, char *, int);
2014445fffbSMatthew Ahrens extern int zpool_log_history(libzfs_handle_t *, const char *);
2024445fffbSMatthew Ahrens 
20399653d4eSeschrock extern int libzfs_errno(libzfs_handle_t *);
20499653d4eSeschrock extern const char *libzfs_error_action(libzfs_handle_t *);
20599653d4eSeschrock extern const char *libzfs_error_description(libzfs_handle_t *);
20678f17100SMatthew Ahrens extern int zfs_standard_error(libzfs_handle_t *, int, const char *);
207ebedde84SEric Taylor extern void libzfs_mnttab_init(libzfs_handle_t *);
208ebedde84SEric Taylor extern void libzfs_mnttab_fini(libzfs_handle_t *);
209b2634b9cSEric Taylor extern void libzfs_mnttab_cache(libzfs_handle_t *, boolean_t);
210ebedde84SEric Taylor extern int libzfs_mnttab_find(libzfs_handle_t *, const char *,
211ebedde84SEric Taylor     struct mnttab *);
212ebedde84SEric Taylor extern void libzfs_mnttab_add(libzfs_handle_t *, const char *,
213ebedde84SEric Taylor     const char *, const char *);
214ebedde84SEric Taylor extern void libzfs_mnttab_remove(libzfs_handle_t *, const char *);
215fa9e4066Sahrens 
216fa9e4066Sahrens /*
217fa9e4066Sahrens  * Basic handle functions
218fa9e4066Sahrens  */
21999653d4eSeschrock extern zpool_handle_t *zpool_open(libzfs_handle_t *, const char *);
22099653d4eSeschrock extern zpool_handle_t *zpool_open_canfail(libzfs_handle_t *, const char *);
221fa9e4066Sahrens extern void zpool_close(zpool_handle_t *);
222fa9e4066Sahrens extern const char *zpool_get_name(zpool_handle_t *);
223fa9e4066Sahrens extern int zpool_get_state(zpool_handle_t *);
2246401734dSWill Andrews extern const char *zpool_state_to_name(vdev_state_t, vdev_aux_t);
2256401734dSWill Andrews extern const char *zpool_pool_state_to_name(pool_state_t);
22629ab75c9Srm extern void zpool_free_handles(libzfs_handle_t *);
227fa9e4066Sahrens 
228fa9e4066Sahrens /*
229fa9e4066Sahrens  * Iterate over all active pools in the system.
230fa9e4066Sahrens  */
231fa9e4066Sahrens typedef int (*zpool_iter_f)(zpool_handle_t *, void *);
23299653d4eSeschrock extern int zpool_iter(libzfs_handle_t *, zpool_iter_f, void *);
2338808ac5dSYuri Pankov extern boolean_t zpool_skip_pool(const char *);
234fa9e4066Sahrens 
235fa9e4066Sahrens /*
236fa9e4066Sahrens  * Functions to create and destroy pools
237fa9e4066Sahrens  */
23899653d4eSeschrock extern int zpool_create(libzfs_handle_t *, const char *, nvlist_t *,
2390a48a24eStimh     nvlist_t *, nvlist_t *);
2404445fffbSMatthew Ahrens extern int zpool_destroy(zpool_handle_t *, const char *);
241fa9e4066Sahrens extern int zpool_add(zpool_handle_t *, nvlist_t *);
242fa9e4066Sahrens 
2431195e687SMark J Musante typedef struct splitflags {
2441195e687SMark J Musante 	/* do not split, but return the config that would be split off */
2451195e687SMark J Musante 	int dryrun : 1;
2461195e687SMark J Musante 
2471195e687SMark J Musante 	/* after splitting, import the pool */
2481195e687SMark J Musante 	int import : 1;
2491195e687SMark J Musante } splitflags_t;
2501195e687SMark J Musante 
251fa9e4066Sahrens /*
252fa9e4066Sahrens  * Functions to manipulate pool and vdev state
253fa9e4066Sahrens  */
2543f9d6ad7SLin Ling extern int zpool_scan(zpool_handle_t *, pool_scan_func_t);
255468c413aSTim Haley extern int zpool_clear(zpool_handle_t *, const char *, nvlist_t *);
256e9103aaeSGarrett D'Amore extern int zpool_reguid(zpool_handle_t *);
2574263d13fSGeorge Wilson extern int zpool_reopen(zpool_handle_t *);
258fa9e4066Sahrens 
2593d7072f8Seschrock extern int zpool_vdev_online(zpool_handle_t *, const char *, int,
2603d7072f8Seschrock     vdev_state_t *);
2613d7072f8Seschrock extern int zpool_vdev_offline(zpool_handle_t *, const char *, boolean_t);
2623d7072f8Seschrock extern int zpool_vdev_attach(zpool_handle_t *, const char *,
2633d7072f8Seschrock     const char *, nvlist_t *, int);
264fa9e4066Sahrens extern int zpool_vdev_detach(zpool_handle_t *, const char *);
26599653d4eSeschrock extern int zpool_vdev_remove(zpool_handle_t *, const char *);
2661195e687SMark J Musante extern int zpool_vdev_split(zpool_handle_t *, char *, nvlist_t **, nvlist_t *,
2671195e687SMark J Musante     splitflags_t);
2683d7072f8Seschrock 
269069f55e2SEric Schrock extern int zpool_vdev_fault(zpool_handle_t *, uint64_t, vdev_aux_t);
270069f55e2SEric Schrock extern int zpool_vdev_degrade(zpool_handle_t *, uint64_t, vdev_aux_t);
2713d7072f8Seschrock extern int zpool_vdev_clear(zpool_handle_t *, uint64_t);
2723d7072f8Seschrock 
273fa94a07fSbrendan extern nvlist_t *zpool_find_vdev(zpool_handle_t *, const char *, boolean_t *,
274ee0eb9f2SEric Schrock     boolean_t *, boolean_t *);
275573ca77eSGeorge Wilson extern nvlist_t *zpool_find_vdev_by_physpath(zpool_handle_t *, const char *,
276573ca77eSGeorge Wilson     boolean_t *, boolean_t *, boolean_t *);
277*7855d95bSToomas Soome extern int zpool_label_disk(libzfs_handle_t *, zpool_handle_t *, const char *,
278*7855d95bSToomas Soome     zpool_boot_label_t, uint64_t, int *);
279fa9e4066Sahrens 
280b1b8ab34Slling /*
281b1b8ab34Slling  * Functions to manage pool properties
282b1b8ab34Slling  */
283b1b8ab34Slling extern int zpool_set_prop(zpool_handle_t *, const char *, const char *);
2843d7072f8Seschrock extern int zpool_get_prop(zpool_handle_t *, zpool_prop_t, char *,
285c58b3526SAdam Stevko     size_t proplen, zprop_source_t *, boolean_t);
286990b4856Slling extern uint64_t zpool_get_prop_int(zpool_handle_t *, zpool_prop_t,
287990b4856Slling     zprop_source_t *);
288990b4856Slling 
289b1b8ab34Slling extern const char *zpool_prop_to_name(zpool_prop_t);
290b1b8ab34Slling extern const char *zpool_prop_values(zpool_prop_t);
291b1b8ab34Slling 
292fa9e4066Sahrens /*
293fa9e4066Sahrens  * Pool health statistics.
294fa9e4066Sahrens  */
295fa9e4066Sahrens typedef enum {
296fa9e4066Sahrens 	/*
297fa9e4066Sahrens 	 * The following correspond to faults as defined in the (fault.fs.zfs.*)
298b81d61a6Slling 	 * event namespace.  Each is associated with a corresponding message ID.
299fa9e4066Sahrens 	 */
300fa9e4066Sahrens 	ZPOOL_STATUS_CORRUPT_CACHE,	/* corrupt /kernel/drv/zpool.cache */
301fa9e4066Sahrens 	ZPOOL_STATUS_MISSING_DEV_R,	/* missing device with replicas */
302fa9e4066Sahrens 	ZPOOL_STATUS_MISSING_DEV_NR,	/* missing device with no replicas */
303fa9e4066Sahrens 	ZPOOL_STATUS_CORRUPT_LABEL_R,	/* bad device label with replicas */
304b81d61a6Slling 	ZPOOL_STATUS_CORRUPT_LABEL_NR,	/* bad device label with no replicas */
305fa9e4066Sahrens 	ZPOOL_STATUS_BAD_GUID_SUM,	/* sum of device guids didn't match */
306fa9e4066Sahrens 	ZPOOL_STATUS_CORRUPT_POOL,	/* pool metadata is corrupted */
307fa9e4066Sahrens 	ZPOOL_STATUS_CORRUPT_DATA,	/* data errors in user (meta)data */
308fa9e4066Sahrens 	ZPOOL_STATUS_FAILING_DEV,	/* device experiencing errors */
309eaca9bbdSeschrock 	ZPOOL_STATUS_VERSION_NEWER,	/* newer on-disk version */
31095173954Sek 	ZPOOL_STATUS_HOSTID_MISMATCH,	/* last accessed by another system */
31132b87932Sek 	ZPOOL_STATUS_IO_FAILURE_WAIT,	/* failed I/O, failmode 'wait' */
31232b87932Sek 	ZPOOL_STATUS_IO_FAILURE_CONTINUE, /* failed I/O, failmode 'continue' */
313f67f35c3SEric Schrock 	ZPOOL_STATUS_BAD_LOG,		/* cannot read log chain(s) */
314f67f35c3SEric Schrock 
315ad135b5dSChristopher Siden 	/*
316ad135b5dSChristopher Siden 	 * If the pool has unsupported features but can still be opened in
317ad135b5dSChristopher Siden 	 * read-only mode, its status is ZPOOL_STATUS_UNSUP_FEAT_WRITE. If the
318ad135b5dSChristopher Siden 	 * pool has unsupported features but cannot be opened at all, its
319ad135b5dSChristopher Siden 	 * status is ZPOOL_STATUS_UNSUP_FEAT_READ.
320ad135b5dSChristopher Siden 	 */
321ad135b5dSChristopher Siden 	ZPOOL_STATUS_UNSUP_FEAT_READ,	/* unsupported features for read */
322ad135b5dSChristopher Siden 	ZPOOL_STATUS_UNSUP_FEAT_WRITE,	/* unsupported features for write */
323ad135b5dSChristopher Siden 
324f67f35c3SEric Schrock 	/*
325f67f35c3SEric Schrock 	 * These faults have no corresponding message ID.  At the time we are
326f67f35c3SEric Schrock 	 * checking the status, the original reason for the FMA fault (I/O or
327f67f35c3SEric Schrock 	 * checksum errors) has been lost.
328f67f35c3SEric Schrock 	 */
3293d7072f8Seschrock 	ZPOOL_STATUS_FAULTED_DEV_R,	/* faulted device with replicas */
3303d7072f8Seschrock 	ZPOOL_STATUS_FAULTED_DEV_NR,	/* faulted device with no replicas */
331fa9e4066Sahrens 
332fa9e4066Sahrens 	/*
333fa9e4066Sahrens 	 * The following are not faults per se, but still an error possibly
334b81d61a6Slling 	 * requiring administrative attention.  There is no corresponding
335fa9e4066Sahrens 	 * message ID.
336fa9e4066Sahrens 	 */
33757221772SChristopher Siden 	ZPOOL_STATUS_VERSION_OLDER,	/* older legacy on-disk version */
33857221772SChristopher Siden 	ZPOOL_STATUS_FEAT_DISABLED,	/* supported features are disabled */
339fa9e4066Sahrens 	ZPOOL_STATUS_RESILVERING,	/* device being resilvered */
340cb605c4dSGerhard Roethlin 	ZPOOL_STATUS_OFFLINE_DEV,	/* device offline */
341c25309d4SGeorge Wilson 	ZPOOL_STATUS_REMOVED_DEV,	/* removed device */
342fa9e4066Sahrens 
343fa9e4066Sahrens 	/*
344fa9e4066Sahrens 	 * Finally, the following indicates a healthy pool.
345fa9e4066Sahrens 	 */
346fa9e4066Sahrens 	ZPOOL_STATUS_OK
347fa9e4066Sahrens } zpool_status_t;
348fa9e4066Sahrens 
349ea8dc4b6Seschrock extern zpool_status_t zpool_get_status(zpool_handle_t *, char **);
350ea8dc4b6Seschrock extern zpool_status_t zpool_import_status(nvlist_t *, char **);
3519eb19f4dSGeorge Wilson extern void zpool_dump_ddt(const ddt_stat_t *dds, const ddt_histogram_t *ddh);
352fa9e4066Sahrens 
353fa9e4066Sahrens /*
354fa9e4066Sahrens  * Statistics and configuration functions.
355fa9e4066Sahrens  */
356ea8dc4b6Seschrock extern nvlist_t *zpool_get_config(zpool_handle_t *, nvlist_t **);
357ad135b5dSChristopher Siden extern nvlist_t *zpool_get_features(zpool_handle_t *);
35894de1d4cSeschrock extern int zpool_refresh_stats(zpool_handle_t *, boolean_t *);
35955434c77Sek extern int zpool_get_errlog(zpool_handle_t *, nvlist_t **);
360*7855d95bSToomas Soome extern boolean_t zpool_is_bootable(zpool_handle_t *);
361ea8dc4b6Seschrock 
362fa9e4066Sahrens /*
363fa9e4066Sahrens  * Import and export functions
364fa9e4066Sahrens  */
3654445fffbSMatthew Ahrens extern int zpool_export(zpool_handle_t *, boolean_t, const char *);
3664445fffbSMatthew Ahrens extern int zpool_export_force(zpool_handle_t *, const char *);
36799653d4eSeschrock extern int zpool_import(libzfs_handle_t *, nvlist_t *, const char *,
368990b4856Slling     char *altroot);
369990b4856Slling extern int zpool_import_props(libzfs_handle_t *, nvlist_t *, const char *,
3704b964adaSGeorge Wilson     nvlist_t *, int);
371ad135b5dSChristopher Siden extern void zpool_print_unsup_feat(nvlist_t *config);
372fa9e4066Sahrens 
373fa9e4066Sahrens /*
374fa9e4066Sahrens  * Search for pools to import
375fa9e4066Sahrens  */
376d41c4376SMark J Musante 
377d41c4376SMark J Musante typedef struct importargs {
378d41c4376SMark J Musante 	char **path;		/* a list of paths to search		*/
379d41c4376SMark J Musante 	int paths;		/* number of paths to search		*/
380d41c4376SMark J Musante 	char *poolname;		/* name of a pool to find		*/
381d41c4376SMark J Musante 	uint64_t guid;		/* guid of a pool to find		*/
382d41c4376SMark J Musante 	char *cachefile;	/* cachefile to use for import		*/
383d41c4376SMark J Musante 	int can_be_active : 1;	/* can the pool be active?		*/
384d41c4376SMark J Musante 	int unique : 1;		/* does 'poolname' already exist?	*/
385d41c4376SMark J Musante 	int exists : 1;		/* set on return if pool already exists	*/
386d41c4376SMark J Musante } importargs_t;
387d41c4376SMark J Musante 
388d41c4376SMark J Musante extern nvlist_t *zpool_search_import(libzfs_handle_t *, importargs_t *);
389d41c4376SMark J Musante 
390d41c4376SMark J Musante /* legacy pool search routines */
39124e697d4Sck extern nvlist_t *zpool_find_import(libzfs_handle_t *, int, char **);
3923a57275aSck extern nvlist_t *zpool_find_import_cached(libzfs_handle_t *, const char *,
393e829d913Sck     char *, uint64_t);
394fa9e4066Sahrens 
395c67d9675Seschrock /*
396c67d9675Seschrock  * Miscellaneous pool functions
397c67d9675Seschrock  */
398ecd6cf80Smarks struct zfs_cmd;
399ecd6cf80Smarks 
4004445fffbSMatthew Ahrens extern const char *zfs_history_event_names[];
4018f18d1faSGeorge Wilson 
40288ecc943SGeorge Wilson extern char *zpool_vdev_name(libzfs_handle_t *, zpool_handle_t *, nvlist_t *,
40388ecc943SGeorge Wilson     boolean_t verbose);
404990b4856Slling extern int zpool_upgrade(zpool_handle_t *, uint64_t);
40506eeb2adSek extern int zpool_get_history(zpool_handle_t *, nvlist_t **);
4068f18d1faSGeorge Wilson extern int zpool_history_unpack(char *, uint64_t, uint64_t *,
4078f18d1faSGeorge Wilson     nvlist_t ***, uint_t *);
40855434c77Sek extern void zpool_obj_to_path(zpool_handle_t *, uint64_t, uint64_t, char *,
40955434c77Sek     size_t len);
410ecd6cf80Smarks extern int zfs_ioctl(libzfs_handle_t *, int, struct zfs_cmd *);
411753a6d45SSherry Moore extern int zpool_get_physpath(zpool_handle_t *, char *, size_t);
412468c413aSTim Haley extern void zpool_explain_recover(libzfs_handle_t *, const char *, int,
413468c413aSTim Haley     nvlist_t *);
414753a6d45SSherry Moore 
415fa9e4066Sahrens /*
416fa9e4066Sahrens  * Basic handle manipulations.  These functions do not create or destroy the
417fa9e4066Sahrens  * underlying datasets, only the references to them.
418fa9e4066Sahrens  */
41999653d4eSeschrock extern zfs_handle_t *zfs_open(libzfs_handle_t *, const char *, int);
42019b94df9SMatthew Ahrens extern zfs_handle_t *zfs_handle_dup(zfs_handle_t *);
421fa9e4066Sahrens extern void zfs_close(zfs_handle_t *);
422fa9e4066Sahrens extern zfs_type_t zfs_get_type(const zfs_handle_t *);
423fa9e4066Sahrens extern const char *zfs_get_name(const zfs_handle_t *);
424d5b5bb25SRich Morris extern zpool_handle_t *zfs_get_pool_handle(const zfs_handle_t *);
4258808ac5dSYuri Pankov extern const char *zfs_get_pool_name(const zfs_handle_t *);
426fa9e4066Sahrens 
427fa9e4066Sahrens /*
428fa9e4066Sahrens  * Property management functions.  Some functions are shared with the kernel,
429b81d61a6Slling  * and are found in sys/fs/zfs.h.
430fa9e4066Sahrens  */
431990b4856Slling 
432990b4856Slling /*
433990b4856Slling  * zfs dataset property management
434990b4856Slling  */
435990b4856Slling extern const char *zfs_prop_default_string(zfs_prop_t);
436990b4856Slling extern uint64_t zfs_prop_default_numeric(zfs_prop_t);
437990b4856Slling extern const char *zfs_prop_column_name(zfs_prop_t);
438990b4856Slling extern boolean_t zfs_prop_align_right(zfs_prop_t);
439990b4856Slling 
4400a48a24eStimh extern nvlist_t *zfs_valid_proplist(libzfs_handle_t *, zfs_type_t,
441e9316f76SJoe Stein     nvlist_t *, uint64_t, zfs_handle_t *, zpool_handle_t *, const char *);
4420a48a24eStimh 
443e9dbad6fSeschrock extern const char *zfs_prop_to_name(zfs_prop_t);
444e9dbad6fSeschrock extern int zfs_prop_set(zfs_handle_t *, const char *, const char *);
44530925561SChris Williamson extern int zfs_prop_set_list(zfs_handle_t *, nvlist_t *);
446e9dbad6fSeschrock extern int zfs_prop_get(zfs_handle_t *, zfs_prop_t, char *, size_t,
447990b4856Slling     zprop_source_t *, char *, size_t, boolean_t);
44892241e0bSTom Erickson extern int zfs_prop_get_recvd(zfs_handle_t *, const char *, char *, size_t,
44992241e0bSTom Erickson     boolean_t);
450e9dbad6fSeschrock extern int zfs_prop_get_numeric(zfs_handle_t *, zfs_prop_t, uint64_t *,
451990b4856Slling     zprop_source_t *, char *, size_t);
452edea4b55SLin Ling extern int zfs_prop_get_userquota_int(zfs_handle_t *zhp, const char *propname,
453edea4b55SLin Ling     uint64_t *propvalue);
45414843421SMatthew Ahrens extern int zfs_prop_get_userquota(zfs_handle_t *zhp, const char *propname,
45514843421SMatthew Ahrens     char *propbuf, int proplen, boolean_t literal);
45619b94df9SMatthew Ahrens extern int zfs_prop_get_written_int(zfs_handle_t *zhp, const char *propname,
45719b94df9SMatthew Ahrens     uint64_t *propvalue);
45819b94df9SMatthew Ahrens extern int zfs_prop_get_written(zfs_handle_t *zhp, const char *propname,
45919b94df9SMatthew Ahrens     char *propbuf, int proplen, boolean_t literal);
460ad135b5dSChristopher Siden extern int zfs_prop_get_feature(zfs_handle_t *zhp, const char *propname,
461ad135b5dSChristopher Siden     char *buf, size_t len);
462e9dbad6fSeschrock extern uint64_t zfs_prop_get_int(zfs_handle_t *, zfs_prop_t);
46392241e0bSTom Erickson extern int zfs_prop_inherit(zfs_handle_t *, const char *, boolean_t);
464e9dbad6fSeschrock extern const char *zfs_prop_values(zfs_prop_t);
465e9dbad6fSeschrock extern int zfs_prop_is_string(zfs_prop_t prop);
466990b4856Slling extern nvlist_t *zfs_get_user_props(zfs_handle_t *);
46792241e0bSTom Erickson extern nvlist_t *zfs_get_recvd_props(zfs_handle_t *);
46819b94df9SMatthew Ahrens extern nvlist_t *zfs_get_clones_nvl(zfs_handle_t *);
46919b94df9SMatthew Ahrens 
470e9dbad6fSeschrock 
471990b4856Slling typedef struct zprop_list {
472990b4856Slling 	int		pl_prop;
473e9dbad6fSeschrock 	char		*pl_user_prop;
474990b4856Slling 	struct zprop_list *pl_next;
475e9dbad6fSeschrock 	boolean_t	pl_all;
476e9dbad6fSeschrock 	size_t		pl_width;
47792241e0bSTom Erickson 	size_t		pl_recvd_width;
478e9dbad6fSeschrock 	boolean_t	pl_fixed;
479990b4856Slling } zprop_list_t;
480e9dbad6fSeschrock 
48143d68d68SYuri Pankov extern int zfs_expand_proplist(zfs_handle_t *, zprop_list_t **, boolean_t,
48243d68d68SYuri Pankov     boolean_t);
4832e5e9e19SSanjeev Bagewadi extern void zfs_prune_proplist(zfs_handle_t *, uint8_t *);
484fa9e4066Sahrens 
485fa9e4066Sahrens #define	ZFS_MOUNTPOINT_NONE	"none"
486fa9e4066Sahrens #define	ZFS_MOUNTPOINT_LEGACY	"legacy"
487fa9e4066Sahrens 
488ad135b5dSChristopher Siden #define	ZFS_FEATURE_DISABLED	"disabled"
489ad135b5dSChristopher Siden #define	ZFS_FEATURE_ENABLED	"enabled"
490ad135b5dSChristopher Siden #define	ZFS_FEATURE_ACTIVE	"active"
491ad135b5dSChristopher Siden 
492ad135b5dSChristopher Siden #define	ZFS_UNSUPPORTED_INACTIVE	"inactive"
493ad135b5dSChristopher Siden #define	ZFS_UNSUPPORTED_READONLY	"readonly"
494ad135b5dSChristopher Siden 
495b1b8ab34Slling /*
496990b4856Slling  * zpool property management
497990b4856Slling  */
498990b4856Slling extern int zpool_expand_proplist(zpool_handle_t *, zprop_list_t **);
499ad135b5dSChristopher Siden extern int zpool_prop_get_feature(zpool_handle_t *, const char *, char *,
500ad135b5dSChristopher Siden     size_t);
501990b4856Slling extern const char *zpool_prop_default_string(zpool_prop_t);
502990b4856Slling extern uint64_t zpool_prop_default_numeric(zpool_prop_t);
503990b4856Slling extern const char *zpool_prop_column_name(zpool_prop_t);
504990b4856Slling extern boolean_t zpool_prop_align_right(zpool_prop_t);
505990b4856Slling 
506990b4856Slling /*
507990b4856Slling  * Functions shared by zfs and zpool property management.
508b1b8ab34Slling  */
509990b4856Slling extern int zprop_iter(zprop_func func, void *cb, boolean_t show_all,
510990b4856Slling     boolean_t ordered, zfs_type_t type);
511990b4856Slling extern int zprop_get_list(libzfs_handle_t *, char *, zprop_list_t **,
512990b4856Slling     zfs_type_t);
513990b4856Slling extern void zprop_free_list(zprop_list_t *);
514990b4856Slling 
51592241e0bSTom Erickson #define	ZFS_GET_NCOLS	5
51692241e0bSTom Erickson 
51792241e0bSTom Erickson typedef enum {
51892241e0bSTom Erickson 	GET_COL_NONE,
51992241e0bSTom Erickson 	GET_COL_NAME,
52092241e0bSTom Erickson 	GET_COL_PROPERTY,
52192241e0bSTom Erickson 	GET_COL_VALUE,
52292241e0bSTom Erickson 	GET_COL_RECVD,
52392241e0bSTom Erickson 	GET_COL_SOURCE
52492241e0bSTom Erickson } zfs_get_column_t;
52592241e0bSTom Erickson 
526990b4856Slling /*
527990b4856Slling  * Functions for printing zfs or zpool properties
528990b4856Slling  */
529990b4856Slling typedef struct zprop_get_cbdata {
530b1b8ab34Slling 	int cb_sources;
53192241e0bSTom Erickson 	zfs_get_column_t cb_columns[ZFS_GET_NCOLS];
53292241e0bSTom Erickson 	int cb_colwidths[ZFS_GET_NCOLS + 1];
533b1b8ab34Slling 	boolean_t cb_scripted;
534b1b8ab34Slling 	boolean_t cb_literal;
535b1b8ab34Slling 	boolean_t cb_first;
536990b4856Slling 	zprop_list_t *cb_proplist;
537990b4856Slling 	zfs_type_t cb_type;
538990b4856Slling } zprop_get_cbdata_t;
539b1b8ab34Slling 
540990b4856Slling void zprop_print_one_property(const char *, zprop_get_cbdata_t *,
54192241e0bSTom Erickson     const char *, const char *, zprop_source_t, const char *,
54292241e0bSTom Erickson     const char *);
543b1b8ab34Slling 
544fa9e4066Sahrens /*
545fa9e4066Sahrens  * Iterator functions.
546fa9e4066Sahrens  */
547fa9e4066Sahrens typedef int (*zfs_iter_f)(zfs_handle_t *, void *);
54899653d4eSeschrock extern int zfs_iter_root(libzfs_handle_t *, zfs_iter_f, void *);
549fa9e4066Sahrens extern int zfs_iter_children(zfs_handle_t *, zfs_iter_f, void *);
5503bb79becSeschrock extern int zfs_iter_dependents(zfs_handle_t *, boolean_t, zfs_iter_f, void *);
5517f7322feSeschrock extern int zfs_iter_filesystems(zfs_handle_t *, zfs_iter_f, void *);
5520d8fa8f8SMartin Matuska extern int zfs_iter_snapshots(zfs_handle_t *, boolean_t, zfs_iter_f, void *);
553ca45db41SChris Kirby extern int zfs_iter_snapshots_sorted(zfs_handle_t *, zfs_iter_f, void *);
55419b94df9SMatthew Ahrens extern int zfs_iter_snapspec(zfs_handle_t *, const char *, zfs_iter_f, void *);
55578f17100SMatthew Ahrens extern int zfs_iter_bookmarks(zfs_handle_t *, zfs_iter_f, void *);
556fa9e4066Sahrens 
5579d9a58e3SEric Taylor typedef struct get_all_cb {
5589d9a58e3SEric Taylor 	zfs_handle_t	**cb_handles;
5599d9a58e3SEric Taylor 	size_t		cb_alloc;
5609d9a58e3SEric Taylor 	size_t		cb_used;
5619d9a58e3SEric Taylor 	boolean_t	cb_verbose;
5629d9a58e3SEric Taylor 	int		(*cb_getone)(zfs_handle_t *, void *);
5639d9a58e3SEric Taylor } get_all_cb_t;
5649d9a58e3SEric Taylor 
5659d9a58e3SEric Taylor void libzfs_add_handle(get_all_cb_t *, zfs_handle_t *);
5669d9a58e3SEric Taylor int libzfs_dataset_cmp(const void *, const void *);
5679d9a58e3SEric Taylor 
568fa9e4066Sahrens /*
569fa9e4066Sahrens  * Functions to create and destroy datasets.
570fa9e4066Sahrens  */
57199653d4eSeschrock extern int zfs_create(libzfs_handle_t *, const char *, zfs_type_t,
572e9dbad6fSeschrock     nvlist_t *);
5737f1f55eaSvb extern int zfs_create_ancestors(libzfs_handle_t *, const char *);
574842727c2SChris Kirby extern int zfs_destroy(zfs_handle_t *, boolean_t);
575842727c2SChris Kirby extern int zfs_destroy_snaps(zfs_handle_t *, char *, boolean_t);
5763b2aab18SMatthew Ahrens extern int zfs_destroy_snaps_nvl(libzfs_handle_t *, nvlist_t *, boolean_t);
577e9dbad6fSeschrock extern int zfs_clone(zfs_handle_t *, const char *, nvlist_t *);
578bb0ade09Sahrens extern int zfs_snapshot(libzfs_handle_t *, const char *, boolean_t, nvlist_t *);
5794445fffbSMatthew Ahrens extern int zfs_snapshot_nvl(libzfs_handle_t *hdl, nvlist_t *snaps,
5804445fffbSMatthew Ahrens     nvlist_t *props);
581c391e322Sahrens extern int zfs_rollback(zfs_handle_t *, zfs_handle_t *, boolean_t);
5826a9cb0eaSEric Schrock extern int zfs_rename(zfs_handle_t *, const char *, boolean_t, boolean_t);
5839e69d7d0SLori Alt 
5849e69d7d0SLori Alt typedef struct sendflags {
5859e69d7d0SLori Alt 	/* print informational messages (ie, -v was specified) */
58619b94df9SMatthew Ahrens 	boolean_t verbose;
5879e69d7d0SLori Alt 
58892241e0bSTom Erickson 	/* recursive send  (ie, -R) */
58919b94df9SMatthew Ahrens 	boolean_t replicate;
5909e69d7d0SLori Alt 
5919e69d7d0SLori Alt 	/* for incrementals, do all intermediate snapshots */
59219b94df9SMatthew Ahrens 	boolean_t doall;
5939e69d7d0SLori Alt 
5949e69d7d0SLori Alt 	/* if dataset is a clone, do incremental from its origin */
59519b94df9SMatthew Ahrens 	boolean_t fromorigin;
5969e69d7d0SLori Alt 
5979e69d7d0SLori Alt 	/* do deduplication */
59819b94df9SMatthew Ahrens 	boolean_t dedup;
59992241e0bSTom Erickson 
60092241e0bSTom Erickson 	/* send properties (ie, -p) */
60119b94df9SMatthew Ahrens 	boolean_t props;
60219b94df9SMatthew Ahrens 
60319b94df9SMatthew Ahrens 	/* do not send (no-op, ie. -n) */
60419b94df9SMatthew Ahrens 	boolean_t dryrun;
60519b94df9SMatthew Ahrens 
60619b94df9SMatthew Ahrens 	/* parsable verbose output (ie. -P) */
60719b94df9SMatthew Ahrens 	boolean_t parsable;
6084e3c9f44SBill Pijewski 
6094e3c9f44SBill Pijewski 	/* show progress (ie. -v) */
6104e3c9f44SBill Pijewski 	boolean_t progress;
6115d7b4d43SMatthew Ahrens 
612b5152584SMatthew Ahrens 	/* large blocks (>128K) are permitted */
613b5152584SMatthew Ahrens 	boolean_t largeblock;
614b5152584SMatthew Ahrens 
6155d7b4d43SMatthew Ahrens 	/* WRITE_EMBEDDED records of type DATA are permitted */
6165d7b4d43SMatthew Ahrens 	boolean_t embed_data;
6175602294fSDan Kimmel 
6185602294fSDan Kimmel 	/* compressed WRITE records are permitted */
6195602294fSDan Kimmel 	boolean_t compress;
6209e69d7d0SLori Alt } sendflags_t;
6219e69d7d0SLori Alt 
6229e69d7d0SLori Alt typedef boolean_t (snapfilter_cb_t)(zfs_handle_t *, void *);
6239e69d7d0SLori Alt 
62419b94df9SMatthew Ahrens extern int zfs_send(zfs_handle_t *, const char *, const char *,
62519b94df9SMatthew Ahrens     sendflags_t *, int, snapfilter_cb_t, void *, nvlist_t **);
6265d7b4d43SMatthew Ahrens extern int zfs_send_one(zfs_handle_t *, const char *, int, enum lzc_send_flags);
6279c3fd121SMatthew Ahrens extern int zfs_send_resume(libzfs_handle_t *, sendflags_t *, int outfd,
6289c3fd121SMatthew Ahrens     const char *);
6299c3fd121SMatthew Ahrens extern nvlist_t *zfs_send_resume_token_to_nvlist(libzfs_handle_t *hdl,
6309c3fd121SMatthew Ahrens     const char *token);
6319e69d7d0SLori Alt 
63299653d4eSeschrock extern int zfs_promote(zfs_handle_t *);
6333b2aab18SMatthew Ahrens extern int zfs_hold(zfs_handle_t *, const char *, const char *,
634a7a845e4SSteven Hartland     boolean_t, int);
635a7a845e4SSteven Hartland extern int zfs_hold_nvl(zfs_handle_t *, int, nvlist_t *);
636842727c2SChris Kirby extern int zfs_release(zfs_handle_t *, const char *, const char *, boolean_t);
6371af68beaSAlexander Stetsenko extern int zfs_get_holds(zfs_handle_t *, nvlist_t **);
638c1449561SEric Taylor extern uint64_t zvol_volsize_to_reservation(uint64_t, nvlist_t *);
639fa9e4066Sahrens 
6400aea4b19SMatthew Ahrens typedef int (*zfs_userspace_cb_t)(void *arg, const char *domain,
64114843421SMatthew Ahrens     uid_t rid, uint64_t space);
64214843421SMatthew Ahrens 
6431af68beaSAlexander Stetsenko extern int zfs_userspace(zfs_handle_t *, zfs_userquota_prop_t,
6441af68beaSAlexander Stetsenko     zfs_userspace_cb_t, void *);
6451af68beaSAlexander Stetsenko 
6461af68beaSAlexander Stetsenko extern int zfs_get_fsacl(zfs_handle_t *, nvlist_t **);
6471af68beaSAlexander Stetsenko extern int zfs_set_fsacl(zfs_handle_t *, boolean_t, nvlist_t *);
64814843421SMatthew Ahrens 
6493cb34c60Sahrens typedef struct recvflags {
6504ccbb6e7Sahrens 	/* print informational messages (ie, -v was specified) */
65119b94df9SMatthew Ahrens 	boolean_t verbose;
6524ccbb6e7Sahrens 
6534ccbb6e7Sahrens 	/* the destination is a prefix, not the exact fs (ie, -d) */
65419b94df9SMatthew Ahrens 	boolean_t isprefix;
6554ccbb6e7Sahrens 
656f64930f5STom Erickson 	/*
657f64930f5STom Erickson 	 * Only the tail of the sent snapshot path is appended to the
658f64930f5STom Erickson 	 * destination to determine the received snapshot name (ie, -e).
659f64930f5STom Erickson 	 */
66019b94df9SMatthew Ahrens 	boolean_t istail;
661f64930f5STom Erickson 
6624ccbb6e7Sahrens 	/* do not actually do the recv, just check if it would work (ie, -n) */
66319b94df9SMatthew Ahrens 	boolean_t dryrun;
6644ccbb6e7Sahrens 
6654ccbb6e7Sahrens 	/* rollback/destroy filesystems as necessary (eg, -F) */
66619b94df9SMatthew Ahrens 	boolean_t force;
6674ccbb6e7Sahrens 
6684ccbb6e7Sahrens 	/* set "canmount=off" on all modified filesystems */
66919b94df9SMatthew Ahrens 	boolean_t canmountoff;
6704ccbb6e7Sahrens 
6719c3fd121SMatthew Ahrens 	/*
6729c3fd121SMatthew Ahrens 	 * Mark the file systems as "resumable" and do not destroy them if the
6739c3fd121SMatthew Ahrens 	 * receive is interrupted
6749c3fd121SMatthew Ahrens 	 */
6759c3fd121SMatthew Ahrens 	boolean_t resumable;
6769c3fd121SMatthew Ahrens 
6774ccbb6e7Sahrens 	/* byteswap flag is used internally; callers need not specify */
67819b94df9SMatthew Ahrens 	boolean_t byteswap;
67933408eefSLori Alt 
68033408eefSLori Alt 	/* do not mount file systems as they are extracted (private) */
68119b94df9SMatthew Ahrens 	boolean_t nomount;
6823cb34c60Sahrens } recvflags_t;
6833cb34c60Sahrens 
684a2cdcdd2SPaul Dagnelie extern int zfs_receive(libzfs_handle_t *, const char *, nvlist_t *,
685a2cdcdd2SPaul Dagnelie     recvflags_t *, int, avl_tree_t *);
6863cb34c60Sahrens 
68799d5e173STim Haley typedef enum diff_flags {
68899d5e173STim Haley 	ZFS_DIFF_PARSEABLE = 0x1,
68999d5e173STim Haley 	ZFS_DIFF_TIMESTAMP = 0x2,
69099d5e173STim Haley 	ZFS_DIFF_CLASSIFY = 0x4
69199d5e173STim Haley } diff_flags_t;
69299d5e173STim Haley 
69399d5e173STim Haley extern int zfs_show_diffs(zfs_handle_t *, int, const char *, const char *,
69499d5e173STim Haley     int);
69599d5e173STim Haley 
696fa9e4066Sahrens /*
697fa9e4066Sahrens  * Miscellaneous functions.
698fa9e4066Sahrens  */
699fa9e4066Sahrens extern const char *zfs_type_to_name(zfs_type_t);
700fa9e4066Sahrens extern void zfs_refresh_properties(zfs_handle_t *);
701fa9e4066Sahrens extern int zfs_name_valid(const char *, zfs_type_t);
7025aba80dbSck extern zfs_handle_t *zfs_path_to_zhandle(libzfs_handle_t *, char *, zfs_type_t);
7037f1f55eaSvb extern boolean_t zfs_dataset_exists(libzfs_handle_t *, const char *,
7047f1f55eaSvb     zfs_type_t);
7057b97dc1aSrm extern int zfs_spa_version(zfs_handle_t *, int *);
70678f17100SMatthew Ahrens extern boolean_t zfs_bookmark_exists(const char *path);
707fa9e4066Sahrens 
708fa9e4066Sahrens /*
709fa9e4066Sahrens  * Mount support functions.
710fa9e4066Sahrens  */
71155434c77Sek extern boolean_t is_mounted(libzfs_handle_t *, const char *special, char **);
71299653d4eSeschrock extern boolean_t zfs_is_mounted(zfs_handle_t *, char **);
713fa9e4066Sahrens extern int zfs_mount(zfs_handle_t *, const char *, int);
714fa9e4066Sahrens extern int zfs_unmount(zfs_handle_t *, const char *, int);
715fa9e4066Sahrens extern int zfs_unmountall(zfs_handle_t *, int);
716fa9e4066Sahrens 
717fa9e4066Sahrens /*
718fa9e4066Sahrens  * Share support functions.
719fa9e4066Sahrens  */
720f3861e1aSahl extern boolean_t zfs_is_shared(zfs_handle_t *);
721fa9e4066Sahrens extern int zfs_share(zfs_handle_t *);
722f3861e1aSahl extern int zfs_unshare(zfs_handle_t *);
723f3861e1aSahl 
724f3861e1aSahl /*
7253d7072f8Seschrock  * Protocol-specific share support functions.
726f3861e1aSahl  */
727f3861e1aSahl extern boolean_t zfs_is_shared_nfs(zfs_handle_t *, char **);
728da6c28aaSamw extern boolean_t zfs_is_shared_smb(zfs_handle_t *, char **);
729f3861e1aSahl extern int zfs_share_nfs(zfs_handle_t *);
730da6c28aaSamw extern int zfs_share_smb(zfs_handle_t *);
731da6c28aaSamw extern int zfs_shareall(zfs_handle_t *);
732f3861e1aSahl extern int zfs_unshare_nfs(zfs_handle_t *, const char *);
733da6c28aaSamw extern int zfs_unshare_smb(zfs_handle_t *, const char *);
734f3861e1aSahl extern int zfs_unshareall_nfs(zfs_handle_t *);
735da6c28aaSamw extern int zfs_unshareall_smb(zfs_handle_t *);
736da6c28aaSamw extern int zfs_unshareall_bypath(zfs_handle_t *, const char *);
737da6c28aaSamw extern int zfs_unshareall(zfs_handle_t *);
738743a77edSAlan Wright extern int zfs_deleg_share_nfs(libzfs_handle_t *, char *, char *, char *,
739da6c28aaSamw     void *, void *, int, zfs_share_op_t);
740fa9e4066Sahrens 
741fa9e4066Sahrens /*
742fa9e4066Sahrens  * When dealing with nvlists, verify() is extremely useful
743fa9e4066Sahrens  */
744fa9e4066Sahrens #ifdef NDEBUG
745fa9e4066Sahrens #define	verify(EX)	((void)(EX))
746fa9e4066Sahrens #else
747fa9e4066Sahrens #define	verify(EX)	assert(EX)
748fa9e4066Sahrens #endif
749fa9e4066Sahrens 
750fa9e4066Sahrens /*
751fa9e4066Sahrens  * Utility function to convert a number to a human-readable form.
752fa9e4066Sahrens  */
753fa9e4066Sahrens extern void zfs_nicenum(uint64_t, char *, size_t);
754e9dbad6fSeschrock extern int zfs_nicestrtonum(libzfs_handle_t *, const char *, uint64_t *);
755fa9e4066Sahrens 
756fa9e4066Sahrens /*
757fa9e4066Sahrens  * Given a device or file, determine if it is part of a pool.
758fa9e4066Sahrens  */
75999653d4eSeschrock extern int zpool_in_use(libzfs_handle_t *, int, pool_state_t *, char **,
76099653d4eSeschrock     boolean_t *);
761fa9e4066Sahrens 
762fa9e4066Sahrens /*
763096d22d4SEric Schrock  * Label manipulation.
764fa9e4066Sahrens  */
76599653d4eSeschrock extern int zpool_read_label(int, nvlist_t **);
766096d22d4SEric Schrock extern int zpool_clear_label(int);
767fa9e4066Sahrens 
768e7cbe64fSgw /* is this zvol valid for use as a dump device? */
769e7cbe64fSgw extern int zvol_check_dump_config(char *);
770e7cbe64fSgw 
771743a77edSAlan Wright /*
772743a77edSAlan Wright  * Management interfaces for SMB ACL files
773743a77edSAlan Wright  */
774743a77edSAlan Wright 
775743a77edSAlan Wright int zfs_smb_acl_add(libzfs_handle_t *, char *, char *, char *);
776743a77edSAlan Wright int zfs_smb_acl_remove(libzfs_handle_t *, char *, char *, char *);
777743a77edSAlan Wright int zfs_smb_acl_purge(libzfs_handle_t *, char *, char *);
778743a77edSAlan Wright int zfs_smb_acl_rename(libzfs_handle_t *, char *, char *, char *, char *);
779743a77edSAlan Wright 
7803bb79becSeschrock /*
781f3861e1aSahl  * Enable and disable datasets within a pool by mounting/unmounting and
782f3861e1aSahl  * sharing/unsharing them.
7833bb79becSeschrock  */
784f3861e1aSahl extern int zpool_enable_datasets(zpool_handle_t *, const char *, int);
785f3861e1aSahl extern int zpool_disable_datasets(zpool_handle_t *, boolean_t);
7863bb79becSeschrock 
787069f55e2SEric Schrock /*
788069f55e2SEric Schrock  * Mappings between vdev and FRU.
789069f55e2SEric Schrock  */
790069f55e2SEric Schrock extern void libzfs_fru_refresh(libzfs_handle_t *);
791069f55e2SEric Schrock extern const char *libzfs_fru_lookup(libzfs_handle_t *, const char *);
792069f55e2SEric Schrock extern const char *libzfs_fru_devpath(libzfs_handle_t *, const char *);
793069f55e2SEric Schrock extern boolean_t libzfs_fru_compare(libzfs_handle_t *, const char *,
794069f55e2SEric Schrock     const char *);
795069f55e2SEric Schrock extern boolean_t libzfs_fru_notself(libzfs_handle_t *, const char *);
796069f55e2SEric Schrock extern int zpool_fru_set(zpool_handle_t *, uint64_t, const char *);
797069f55e2SEric Schrock 
7982bcf0248SMax Grossman extern int zfs_get_hole_count(const char *, uint64_t *, uint64_t *);
7992bcf0248SMax Grossman 
8008a981c33SDaniel Hoffman /* Allow consumers to initialize libshare externally for optimal performance */
8018a981c33SDaniel Hoffman extern int zfs_init_libshare_arg(libzfs_handle_t *, int, void *);
8028a981c33SDaniel Hoffman /*
8038a981c33SDaniel Hoffman  * For most consumers, zfs_init_libshare_arg is sufficient on its own, and
8048a981c33SDaniel Hoffman  * zfs_uninit_libshare is unnecessary. zfs_uninit_libshare should only be called
8058a981c33SDaniel Hoffman  * if the caller has already initialized libshare for one set of zfs handles,
8068a981c33SDaniel Hoffman  * and wishes to share or unshare filesystems outside of that set. In that case,
8078a981c33SDaniel Hoffman  * the caller should uninitialize libshare, and then re-initialize it with the
8088a981c33SDaniel Hoffman  * new handles being shared or unshared.
8098a981c33SDaniel Hoffman  */
8108a981c33SDaniel Hoffman extern void zfs_uninit_libshare(libzfs_handle_t *);
811fa9e4066Sahrens #ifdef	__cplusplus
812fa9e4066Sahrens }
813fa9e4066Sahrens #endif
814fa9e4066Sahrens 
815fa9e4066Sahrens #endif	/* _LIBZFS_H */
816