1789Sahrens /* 2789Sahrens * CDDL HEADER START 3789Sahrens * 4789Sahrens * The contents of this file are subject to the terms of the 51485Slling * Common Development and Distribution License (the "License"). 61485Slling * You may not use this file except in compliance with the License. 7789Sahrens * 8789Sahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9789Sahrens * or http://www.opensolaris.org/os/licensing. 10789Sahrens * See the License for the specific language governing permissions 11789Sahrens * and limitations under the License. 12789Sahrens * 13789Sahrens * When distributing Covered Code, include this CDDL HEADER in each 14789Sahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15789Sahrens * If applicable, add the following below this CDDL HEADER, with the 16789Sahrens * fields enclosed by brackets "[]" replaced with your own identifying 17789Sahrens * information: Portions Copyright [yyyy] [name of copyright owner] 18789Sahrens * 19789Sahrens * CDDL HEADER END 20789Sahrens */ 213126Sahl 22789Sahrens /* 233444Sek110237 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24789Sahrens * Use is subject to license terms. 25789Sahrens */ 26789Sahrens 27789Sahrens #ifndef _LIBZFS_H 28789Sahrens #define _LIBZFS_H 29789Sahrens 30789Sahrens #pragma ident "%Z%%M% %I% %E% SMI" 31789Sahrens 32789Sahrens #include <assert.h> 33789Sahrens #include <libnvpair.h> 34789Sahrens #include <sys/param.h> 35789Sahrens #include <sys/types.h> 36789Sahrens #include <sys/varargs.h> 37789Sahrens #include <sys/fs/zfs.h> 384543Smarks #include <sys/avl.h> 394543Smarks #include <ucred.h> 40789Sahrens 41789Sahrens #ifdef __cplusplus 42789Sahrens extern "C" { 43789Sahrens #endif 44789Sahrens 45789Sahrens /* 46789Sahrens * Miscellaneous ZFS constants 47789Sahrens */ 48789Sahrens #define ZFS_MAXNAMELEN MAXNAMELEN 49789Sahrens #define ZPOOL_MAXNAMELEN MAXNAMELEN 50789Sahrens #define ZFS_MAXPROPLEN MAXPATHLEN 51*5094Slling #define ZPOOL_MAXPROPLEN MAXPATHLEN 52789Sahrens 53789Sahrens /* 542082Seschrock * libzfs errors 552082Seschrock */ 562082Seschrock enum { 572082Seschrock EZFS_NOMEM = 2000, /* out of memory */ 582082Seschrock EZFS_BADPROP, /* invalid property value */ 592082Seschrock EZFS_PROPREADONLY, /* cannot set readonly property */ 602082Seschrock EZFS_PROPTYPE, /* property does not apply to dataset type */ 612082Seschrock EZFS_PROPNONINHERIT, /* property is not inheritable */ 622082Seschrock EZFS_PROPSPACE, /* bad quota or reservation */ 632082Seschrock EZFS_BADTYPE, /* dataset is not of appropriate type */ 642082Seschrock EZFS_BUSY, /* pool or dataset is busy */ 652082Seschrock EZFS_EXISTS, /* pool or dataset already exists */ 662082Seschrock EZFS_NOENT, /* no such pool or dataset */ 672082Seschrock EZFS_BADSTREAM, /* bad backup stream */ 682082Seschrock EZFS_DSREADONLY, /* dataset is readonly */ 692082Seschrock EZFS_VOLTOOBIG, /* volume is too large for 32-bit system */ 702082Seschrock EZFS_VOLHASDATA, /* volume already contains data */ 712082Seschrock EZFS_INVALIDNAME, /* invalid dataset name */ 722082Seschrock EZFS_BADRESTORE, /* unable to restore to destination */ 732082Seschrock EZFS_BADBACKUP, /* backup failed */ 742082Seschrock EZFS_BADTARGET, /* bad attach/detach/replace target */ 752082Seschrock EZFS_NODEVICE, /* no such device in pool */ 762082Seschrock EZFS_BADDEV, /* invalid device to add */ 772082Seschrock EZFS_NOREPLICAS, /* no valid replicas */ 782082Seschrock EZFS_RESILVERING, /* currently resilvering */ 792082Seschrock EZFS_BADVERSION, /* unsupported version */ 802082Seschrock EZFS_POOLUNAVAIL, /* pool is currently unavailable */ 812082Seschrock EZFS_DEVOVERFLOW, /* too many devices in one vdev */ 822082Seschrock EZFS_BADPATH, /* must be an absolute path */ 832082Seschrock EZFS_CROSSTARGET, /* rename or clone across pool or dataset */ 842082Seschrock EZFS_ZONED, /* used improperly in local zone */ 852082Seschrock EZFS_MOUNTFAILED, /* failed to mount dataset */ 862082Seschrock EZFS_UMOUNTFAILED, /* failed to unmount dataset */ 873126Sahl EZFS_UNSHARENFSFAILED, /* unshare(1M) failed */ 883126Sahl EZFS_SHARENFSFAILED, /* share(1M) failed */ 892082Seschrock EZFS_DEVLINKS, /* failed to create zvol links */ 902082Seschrock EZFS_PERM, /* permission denied */ 912082Seschrock EZFS_NOSPC, /* out of space */ 922082Seschrock EZFS_IO, /* I/O error */ 932082Seschrock EZFS_INTR, /* signal received */ 942082Seschrock EZFS_ISSPARE, /* device is a hot spare */ 952082Seschrock EZFS_INVALCONFIG, /* invalid vdev configuration */ 962474Seschrock EZFS_RECURSIVE, /* recursive dependency */ 972926Sek110237 EZFS_NOHISTORY, /* no history object */ 983126Sahl EZFS_UNSHAREISCSIFAILED, /* iscsitgtd failed request to unshare */ 993126Sahl EZFS_SHAREISCSIFAILED, /* iscsitgtd failed request to share */ 1003912Slling EZFS_POOLPROPS, /* couldn't retrieve pool props */ 1013912Slling EZFS_POOL_NOTSUP, /* ops not supported for this type of pool */ 1023912Slling EZFS_POOL_INVALARG, /* invalid argument for this pool operation */ 1033978Smmusante EZFS_NAMETOOLONG, /* dataset name is too long */ 1044276Staylor EZFS_OPENFAILED, /* open of device failed */ 1054276Staylor EZFS_NOCAP, /* couldn't get capacity */ 1064276Staylor EZFS_LABELFAILED, /* write of label failed */ 1074543Smarks EZFS_ISCSISVCUNAVAIL, /* iscsi service unavailable */ 1084543Smarks EZFS_BADWHO, /* invalid permission who */ 1094543Smarks EZFS_BADPERM, /* invalid permission */ 1104543Smarks EZFS_BADPERMSET, /* invalid permission set name */ 1114543Smarks EZFS_NODELEGATION, /* delegated administration is disabled */ 1124543Smarks EZFS_PERMRDONLY, /* pemissions are readonly */ 1133912Slling EZFS_UNKNOWN 1142082Seschrock }; 1152082Seschrock 1162082Seschrock /* 1174543Smarks * The following data structures are all part 1184543Smarks * of the zfs_allow_t data structure which is 1194543Smarks * used for printing 'allow' permissions. 1204543Smarks * It is a linked list of zfs_allow_t's which 1214543Smarks * then contain avl tree's for user/group/sets/... 1224543Smarks * and each one of the entries in those trees have 1234543Smarks * avl tree's for the permissions they belong to and 1244543Smarks * whether they are local,descendent or local+descendent 1254543Smarks * permissions. The AVL trees are used primarily for 1264543Smarks * sorting purposes, but also so that we can quickly find 1274543Smarks * a given user and or permission. 1284543Smarks */ 1294543Smarks typedef struct zfs_perm_node { 1304543Smarks avl_node_t z_node; 1314543Smarks char z_pname[MAXPATHLEN]; 1324543Smarks } zfs_perm_node_t; 1334543Smarks 1344543Smarks typedef struct zfs_allow_node { 1354543Smarks avl_node_t z_node; 1364543Smarks char z_key[MAXPATHLEN]; /* name, such as joe */ 1374543Smarks avl_tree_t z_localdescend; /* local+descendent perms */ 1384543Smarks avl_tree_t z_local; /* local permissions */ 1394543Smarks avl_tree_t z_descend; /* descendent permissions */ 1404543Smarks } zfs_allow_node_t; 1414543Smarks 1424543Smarks typedef struct zfs_allow { 1434543Smarks struct zfs_allow *z_next; 1444543Smarks char z_setpoint[MAXPATHLEN]; 1454543Smarks avl_tree_t z_sets; 1464543Smarks avl_tree_t z_crperms; 1474543Smarks avl_tree_t z_user; 1484543Smarks avl_tree_t z_group; 1494543Smarks avl_tree_t z_everyone; 1504543Smarks } zfs_allow_t; 1514543Smarks 1524543Smarks /* 153789Sahrens * Basic handle types 154789Sahrens */ 155789Sahrens typedef struct zfs_handle zfs_handle_t; 156789Sahrens typedef struct zpool_handle zpool_handle_t; 1572082Seschrock typedef struct libzfs_handle libzfs_handle_t; 1582082Seschrock 1592082Seschrock /* 1602082Seschrock * Library initialization 1612082Seschrock */ 1622082Seschrock extern libzfs_handle_t *libzfs_init(void); 1632082Seschrock extern void libzfs_fini(libzfs_handle_t *); 1642082Seschrock 1652082Seschrock extern libzfs_handle_t *zpool_get_handle(zpool_handle_t *); 1662082Seschrock extern libzfs_handle_t *zfs_get_handle(zfs_handle_t *); 1672082Seschrock 1682082Seschrock extern void libzfs_print_on_error(libzfs_handle_t *, boolean_t); 1692082Seschrock 1702082Seschrock extern int libzfs_errno(libzfs_handle_t *); 1712082Seschrock extern const char *libzfs_error_action(libzfs_handle_t *); 1722082Seschrock extern const char *libzfs_error_description(libzfs_handle_t *); 173789Sahrens 174789Sahrens /* 175789Sahrens * Basic handle functions 176789Sahrens */ 1772082Seschrock extern zpool_handle_t *zpool_open(libzfs_handle_t *, const char *); 1782082Seschrock extern zpool_handle_t *zpool_open_canfail(libzfs_handle_t *, const char *); 179789Sahrens extern void zpool_close(zpool_handle_t *); 180789Sahrens extern const char *zpool_get_name(zpool_handle_t *); 181789Sahrens extern int zpool_get_state(zpool_handle_t *); 182*5094Slling extern char *zpool_state_to_name(vdev_state_t, vdev_aux_t); 183789Sahrens 184789Sahrens /* 185789Sahrens * Iterate over all active pools in the system. 186789Sahrens */ 187789Sahrens typedef int (*zpool_iter_f)(zpool_handle_t *, void *); 1882082Seschrock extern int zpool_iter(libzfs_handle_t *, zpool_iter_f, void *); 189789Sahrens 190789Sahrens /* 191789Sahrens * Functions to create and destroy pools 192789Sahrens */ 1932082Seschrock extern int zpool_create(libzfs_handle_t *, const char *, nvlist_t *, 194*5094Slling nvlist_t *); 195789Sahrens extern int zpool_destroy(zpool_handle_t *); 196789Sahrens extern int zpool_add(zpool_handle_t *, nvlist_t *); 197789Sahrens 198789Sahrens /* 199789Sahrens * Functions to manipulate pool and vdev state 200789Sahrens */ 201789Sahrens extern int zpool_scrub(zpool_handle_t *, pool_scrub_type_t); 2024451Seschrock extern int zpool_clear(zpool_handle_t *, const char *); 203789Sahrens 2044451Seschrock extern int zpool_vdev_online(zpool_handle_t *, const char *, int, 2054451Seschrock vdev_state_t *); 2064451Seschrock extern int zpool_vdev_offline(zpool_handle_t *, const char *, boolean_t); 2074451Seschrock extern int zpool_vdev_attach(zpool_handle_t *, const char *, 2084451Seschrock const char *, nvlist_t *, int); 209789Sahrens extern int zpool_vdev_detach(zpool_handle_t *, const char *); 2102082Seschrock extern int zpool_vdev_remove(zpool_handle_t *, const char *); 2114451Seschrock 2124451Seschrock extern int zpool_vdev_fault(zpool_handle_t *, uint64_t); 2134451Seschrock extern int zpool_vdev_degrade(zpool_handle_t *, uint64_t); 2144451Seschrock extern int zpool_vdev_clear(zpool_handle_t *, uint64_t); 2154451Seschrock 2162082Seschrock extern nvlist_t *zpool_find_vdev(zpool_handle_t *, const char *, boolean_t *); 2174276Staylor extern int zpool_label_disk(libzfs_handle_t *, zpool_handle_t *, char *); 218789Sahrens 219789Sahrens /* 2203912Slling * Functions to manage pool properties 2213912Slling */ 2223912Slling extern int zpool_set_prop(zpool_handle_t *, const char *, const char *); 2234451Seschrock extern int zpool_get_prop(zpool_handle_t *, zpool_prop_t, char *, 224*5094Slling size_t proplen, zprop_source_t *); 225*5094Slling extern uint64_t zpool_get_prop_int(zpool_handle_t *, zpool_prop_t, 226*5094Slling zprop_source_t *); 227*5094Slling 2283912Slling extern const char *zpool_prop_to_name(zpool_prop_t); 2293912Slling extern const char *zpool_prop_values(zpool_prop_t); 2303912Slling 2313912Slling /* 232789Sahrens * Pool health statistics. 233789Sahrens */ 234789Sahrens typedef enum { 235789Sahrens /* 236789Sahrens * The following correspond to faults as defined in the (fault.fs.zfs.*) 2371003Slling * event namespace. Each is associated with a corresponding message ID. 238789Sahrens */ 239789Sahrens ZPOOL_STATUS_CORRUPT_CACHE, /* corrupt /kernel/drv/zpool.cache */ 240789Sahrens ZPOOL_STATUS_MISSING_DEV_R, /* missing device with replicas */ 241789Sahrens ZPOOL_STATUS_MISSING_DEV_NR, /* missing device with no replicas */ 242789Sahrens ZPOOL_STATUS_CORRUPT_LABEL_R, /* bad device label with replicas */ 2431003Slling ZPOOL_STATUS_CORRUPT_LABEL_NR, /* bad device label with no replicas */ 244789Sahrens ZPOOL_STATUS_BAD_GUID_SUM, /* sum of device guids didn't match */ 245789Sahrens ZPOOL_STATUS_CORRUPT_POOL, /* pool metadata is corrupted */ 246789Sahrens ZPOOL_STATUS_CORRUPT_DATA, /* data errors in user (meta)data */ 247789Sahrens ZPOOL_STATUS_FAILING_DEV, /* device experiencing errors */ 2481760Seschrock ZPOOL_STATUS_VERSION_NEWER, /* newer on-disk version */ 2493975Sek110237 ZPOOL_STATUS_HOSTID_MISMATCH, /* last accessed by another system */ 2504451Seschrock ZPOOL_STATUS_FAULTED_DEV_R, /* faulted device with replicas */ 2514451Seschrock ZPOOL_STATUS_FAULTED_DEV_NR, /* faulted device with no replicas */ 252789Sahrens 253789Sahrens /* 254789Sahrens * The following are not faults per se, but still an error possibly 2551003Slling * requiring administrative attention. There is no corresponding 256789Sahrens * message ID. 257789Sahrens */ 2581760Seschrock ZPOOL_STATUS_VERSION_OLDER, /* older on-disk version */ 259789Sahrens ZPOOL_STATUS_RESILVERING, /* device being resilvered */ 260789Sahrens ZPOOL_STATUS_OFFLINE_DEV, /* device online */ 261789Sahrens 262789Sahrens /* 263789Sahrens * Finally, the following indicates a healthy pool. 264789Sahrens */ 265789Sahrens ZPOOL_STATUS_OK 266789Sahrens } zpool_status_t; 267789Sahrens 2681544Seschrock extern zpool_status_t zpool_get_status(zpool_handle_t *, char **); 2691544Seschrock extern zpool_status_t zpool_import_status(nvlist_t *, char **); 270789Sahrens 271789Sahrens /* 272789Sahrens * Statistics and configuration functions. 273789Sahrens */ 2741544Seschrock extern nvlist_t *zpool_get_config(zpool_handle_t *, nvlist_t **); 2752142Seschrock extern int zpool_refresh_stats(zpool_handle_t *, boolean_t *); 2763444Sek110237 extern int zpool_get_errlog(zpool_handle_t *, nvlist_t **); 2771544Seschrock 278789Sahrens /* 279789Sahrens * Import and export functions 280789Sahrens */ 281789Sahrens extern int zpool_export(zpool_handle_t *); 2822082Seschrock extern int zpool_import(libzfs_handle_t *, nvlist_t *, const char *, 283*5094Slling char *altroot); 284*5094Slling extern int zpool_import_props(libzfs_handle_t *, nvlist_t *, const char *, 285*5094Slling nvlist_t *); 286789Sahrens 287789Sahrens /* 288789Sahrens * Search for pools to import 289789Sahrens */ 2902082Seschrock extern nvlist_t *zpool_find_import(libzfs_handle_t *, int, char **); 291789Sahrens 292789Sahrens /* 2931354Seschrock * Miscellaneous pool functions 2941354Seschrock */ 2954543Smarks struct zfs_cmd; 2964543Smarks 2972082Seschrock extern char *zpool_vdev_name(libzfs_handle_t *, zpool_handle_t *, nvlist_t *); 298*5094Slling extern int zpool_upgrade(zpool_handle_t *, uint64_t); 2992926Sek110237 extern int zpool_get_history(zpool_handle_t *, nvlist_t **); 3004988Sek110237 extern void zpool_set_history_str(const char *subcommand, int argc, 3014988Sek110237 char **argv, char *history_str); 3024988Sek110237 extern int zpool_stage_history(libzfs_handle_t *, const char *); 3033444Sek110237 extern void zpool_obj_to_path(zpool_handle_t *, uint64_t, uint64_t, char *, 3043444Sek110237 size_t len); 3054543Smarks extern int zfs_ioctl(libzfs_handle_t *, int, struct zfs_cmd *); 3061354Seschrock /* 307789Sahrens * Basic handle manipulations. These functions do not create or destroy the 308789Sahrens * underlying datasets, only the references to them. 309789Sahrens */ 3102082Seschrock extern zfs_handle_t *zfs_open(libzfs_handle_t *, const char *, int); 311789Sahrens extern void zfs_close(zfs_handle_t *); 312789Sahrens extern zfs_type_t zfs_get_type(const zfs_handle_t *); 313789Sahrens extern const char *zfs_get_name(const zfs_handle_t *); 314789Sahrens 315789Sahrens /* 316789Sahrens * Property management functions. Some functions are shared with the kernel, 3171003Slling * and are found in sys/fs/zfs.h. 318789Sahrens */ 319*5094Slling 320*5094Slling /* 321*5094Slling * zfs dataset property management 322*5094Slling */ 3232676Seschrock extern int zfs_prop_valid_for_type(zfs_prop_t, int); 324*5094Slling extern const char *zfs_prop_default_string(zfs_prop_t); 3252676Seschrock extern uint64_t zfs_prop_default_numeric(zfs_prop_t); 3262676Seschrock extern const char *zfs_prop_column_name(zfs_prop_t); 3272676Seschrock extern boolean_t zfs_prop_align_right(zfs_prop_t); 3282676Seschrock 329*5094Slling extern const char *zfs_prop_to_name(zfs_prop_t); 330*5094Slling extern int zfs_prop_set(zfs_handle_t *, const char *, const char *); 331*5094Slling extern int zfs_prop_get(zfs_handle_t *, zfs_prop_t, char *, size_t, 332*5094Slling zprop_source_t *, char *, size_t, boolean_t); 333*5094Slling extern int zfs_prop_get_numeric(zfs_handle_t *, zfs_prop_t, uint64_t *, 334*5094Slling zprop_source_t *, char *, size_t); 335*5094Slling extern uint64_t zfs_prop_get_int(zfs_handle_t *, zfs_prop_t); 336*5094Slling extern int zfs_prop_inherit(zfs_handle_t *, const char *); 337*5094Slling extern const char *zfs_prop_values(zfs_prop_t); 338*5094Slling extern int zfs_prop_is_string(zfs_prop_t prop); 339*5094Slling extern nvlist_t *zfs_get_user_props(zfs_handle_t *); 340*5094Slling 341*5094Slling typedef struct zprop_list { 342*5094Slling int pl_prop; 3432676Seschrock char *pl_user_prop; 344*5094Slling struct zprop_list *pl_next; 3452676Seschrock boolean_t pl_all; 3462676Seschrock size_t pl_width; 3472676Seschrock boolean_t pl_fixed; 348*5094Slling } zprop_list_t; 3493912Slling 350*5094Slling extern int zfs_expand_proplist(zfs_handle_t *, zprop_list_t **); 351789Sahrens 352789Sahrens #define ZFS_MOUNTPOINT_NONE "none" 353789Sahrens #define ZFS_MOUNTPOINT_LEGACY "legacy" 354789Sahrens 355789Sahrens /* 356*5094Slling * zpool property management 357*5094Slling */ 358*5094Slling extern int zpool_expand_proplist(zpool_handle_t *, zprop_list_t **); 359*5094Slling extern const char *zpool_prop_default_string(zpool_prop_t); 360*5094Slling extern uint64_t zpool_prop_default_numeric(zpool_prop_t); 361*5094Slling extern const char *zpool_prop_column_name(zpool_prop_t); 362*5094Slling extern boolean_t zpool_prop_align_right(zpool_prop_t); 363*5094Slling 364*5094Slling /* 365*5094Slling * Functions shared by zfs and zpool property management. 3663912Slling */ 367*5094Slling extern int zprop_iter(zprop_func func, void *cb, boolean_t show_all, 368*5094Slling boolean_t ordered, zfs_type_t type); 369*5094Slling extern int zprop_get_list(libzfs_handle_t *, char *, zprop_list_t **, 370*5094Slling zfs_type_t); 371*5094Slling extern void zprop_free_list(zprop_list_t *); 372*5094Slling 373*5094Slling /* 374*5094Slling * Functions for printing zfs or zpool properties 375*5094Slling */ 376*5094Slling typedef struct zprop_get_cbdata { 3773912Slling int cb_sources; 3783912Slling int cb_columns[4]; 3793912Slling int cb_colwidths[5]; 3803912Slling boolean_t cb_scripted; 3813912Slling boolean_t cb_literal; 3823912Slling boolean_t cb_first; 383*5094Slling zprop_list_t *cb_proplist; 384*5094Slling zfs_type_t cb_type; 385*5094Slling } zprop_get_cbdata_t; 3863912Slling 387*5094Slling void zprop_print_one_property(const char *, zprop_get_cbdata_t *, 388*5094Slling const char *, const char *, zprop_source_t, const char *); 3893912Slling 3903912Slling #define GET_COL_NAME 1 3913912Slling #define GET_COL_PROPERTY 2 3923912Slling #define GET_COL_VALUE 3 3933912Slling #define GET_COL_SOURCE 4 3943912Slling 3953912Slling /* 396789Sahrens * Iterator functions. 397789Sahrens */ 398789Sahrens typedef int (*zfs_iter_f)(zfs_handle_t *, void *); 3992082Seschrock extern int zfs_iter_root(libzfs_handle_t *, zfs_iter_f, void *); 400789Sahrens extern int zfs_iter_children(zfs_handle_t *, zfs_iter_f, void *); 4012474Seschrock extern int zfs_iter_dependents(zfs_handle_t *, boolean_t, zfs_iter_f, void *); 4021356Seschrock extern int zfs_iter_filesystems(zfs_handle_t *, zfs_iter_f, void *); 4031356Seschrock extern int zfs_iter_snapshots(zfs_handle_t *, zfs_iter_f, void *); 404789Sahrens 405789Sahrens /* 406789Sahrens * Functions to create and destroy datasets. 407789Sahrens */ 4082082Seschrock extern int zfs_create(libzfs_handle_t *, const char *, zfs_type_t, 4092676Seschrock nvlist_t *); 4104490Svb160487 extern int zfs_create_ancestors(libzfs_handle_t *, const char *); 411789Sahrens extern int zfs_destroy(zfs_handle_t *); 4122199Sahrens extern int zfs_destroy_snaps(zfs_handle_t *, char *); 4132676Seschrock extern int zfs_clone(zfs_handle_t *, const char *, nvlist_t *); 4142199Sahrens extern int zfs_snapshot(libzfs_handle_t *, const char *, boolean_t); 4151294Slling extern int zfs_rollback(zfs_handle_t *, zfs_handle_t *, int); 4164490Svb160487 extern int zfs_rename(zfs_handle_t *, const char *, boolean_t); 4173504Sahl extern int zfs_send(zfs_handle_t *, const char *, int); 4182665Snd150628 extern int zfs_receive(libzfs_handle_t *, const char *, int, int, int, 4193504Sahl boolean_t, int); 4202082Seschrock extern int zfs_promote(zfs_handle_t *); 421789Sahrens 422789Sahrens /* 423789Sahrens * Miscellaneous functions. 424789Sahrens */ 425789Sahrens extern const char *zfs_type_to_name(zfs_type_t); 426789Sahrens extern void zfs_refresh_properties(zfs_handle_t *); 427789Sahrens extern int zfs_name_valid(const char *, zfs_type_t); 4283635Sck153898 extern zfs_handle_t *zfs_path_to_zhandle(libzfs_handle_t *, char *, zfs_type_t); 4294490Svb160487 extern boolean_t zfs_dataset_exists(libzfs_handle_t *, const char *, 4304490Svb160487 zfs_type_t); 431789Sahrens 432789Sahrens /* 4334543Smarks * dataset permission functions. 4344543Smarks */ 4354543Smarks extern int zfs_perm_set(zfs_handle_t *, nvlist_t *); 4364543Smarks extern int zfs_perm_remove(zfs_handle_t *, nvlist_t *); 4374543Smarks extern int zfs_build_perms(zfs_handle_t *, char *, char *, 4384543Smarks zfs_deleg_who_type_t, zfs_deleg_inherit_t, nvlist_t **nvlist_t); 4394543Smarks extern int zfs_perm_get(zfs_handle_t *, zfs_allow_t **); 4404543Smarks extern void zfs_free_allows(zfs_allow_t *); 4414543Smarks 4424543Smarks /* 443789Sahrens * Mount support functions. 444789Sahrens */ 4453444Sek110237 extern boolean_t is_mounted(libzfs_handle_t *, const char *special, char **); 4462082Seschrock extern boolean_t zfs_is_mounted(zfs_handle_t *, char **); 447789Sahrens extern int zfs_mount(zfs_handle_t *, const char *, int); 448789Sahrens extern int zfs_unmount(zfs_handle_t *, const char *, int); 449789Sahrens extern int zfs_unmountall(zfs_handle_t *, int); 450789Sahrens 451789Sahrens /* 452789Sahrens * Share support functions. 453789Sahrens */ 4543126Sahl extern boolean_t zfs_is_shared(zfs_handle_t *); 455789Sahrens extern int zfs_share(zfs_handle_t *); 4563126Sahl extern int zfs_unshare(zfs_handle_t *); 4573126Sahl 4583126Sahl /* 4594451Seschrock * Protocol-specific share support functions. 4603126Sahl */ 4613126Sahl extern boolean_t zfs_is_shared_nfs(zfs_handle_t *, char **); 4623126Sahl extern int zfs_share_nfs(zfs_handle_t *); 4633126Sahl extern int zfs_unshare_nfs(zfs_handle_t *, const char *); 4643126Sahl extern int zfs_unshareall_nfs(zfs_handle_t *); 4653126Sahl extern boolean_t zfs_is_shared_iscsi(zfs_handle_t *); 4663126Sahl extern int zfs_share_iscsi(zfs_handle_t *); 4673126Sahl extern int zfs_unshare_iscsi(zfs_handle_t *); 4684543Smarks extern int zfs_iscsi_perm_check(libzfs_handle_t *, char *, ucred_t *); 4694543Smarks extern int zfs_deleg_share_nfs(libzfs_handle_t *, char *, char *, 4704543Smarks void *, void *, int, boolean_t); 471789Sahrens 472789Sahrens /* 473789Sahrens * When dealing with nvlists, verify() is extremely useful 474789Sahrens */ 475789Sahrens #ifdef NDEBUG 476789Sahrens #define verify(EX) ((void)(EX)) 477789Sahrens #else 478789Sahrens #define verify(EX) assert(EX) 479789Sahrens #endif 480789Sahrens 481789Sahrens /* 482789Sahrens * Utility function to convert a number to a human-readable form. 483789Sahrens */ 484789Sahrens extern void zfs_nicenum(uint64_t, char *, size_t); 4852676Seschrock extern int zfs_nicestrtonum(libzfs_handle_t *, const char *, uint64_t *); 486789Sahrens 487789Sahrens /* 488789Sahrens * Given a device or file, determine if it is part of a pool. 489789Sahrens */ 4902082Seschrock extern int zpool_in_use(libzfs_handle_t *, int, pool_state_t *, char **, 4912082Seschrock boolean_t *); 492789Sahrens 493789Sahrens /* 494789Sahrens * ftyp special. Read the label from a given device. 495789Sahrens */ 4962082Seschrock extern int zpool_read_label(int, nvlist_t **); 497789Sahrens 498789Sahrens /* 4993126Sahl * Create and remove zvol /dev links. 500789Sahrens */ 501789Sahrens extern int zpool_create_zvol_links(zpool_handle_t *); 502789Sahrens extern int zpool_remove_zvol_links(zpool_handle_t *); 503789Sahrens 5042474Seschrock /* 5053126Sahl * Enable and disable datasets within a pool by mounting/unmounting and 5063126Sahl * sharing/unsharing them. 5072474Seschrock */ 5083126Sahl extern int zpool_enable_datasets(zpool_handle_t *, const char *, int); 5093126Sahl extern int zpool_disable_datasets(zpool_handle_t *, boolean_t); 5102474Seschrock 511789Sahrens #ifdef __cplusplus 512789Sahrens } 513789Sahrens #endif 514789Sahrens 515789Sahrens #endif /* _LIBZFS_H */ 516