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. 24e9103aaeSGarrett D'Amore * Copyright 2011 Nexenta Systems, Inc. All rights reserved. 254263d13fSGeorge Wilson * Copyright (c) 2012 by Delphix. All rights reserved. 264e3c9f44SBill Pijewski * Copyright (c) 2012, Joyent, Inc. All rights reserved. 27fa9e4066Sahrens */ 28fa9e4066Sahrens 29fa9e4066Sahrens #ifndef _LIBZFS_H 30fa9e4066Sahrens #define _LIBZFS_H 31fa9e4066Sahrens 32fa9e4066Sahrens #include <assert.h> 33fa9e4066Sahrens #include <libnvpair.h> 34ebedde84SEric Taylor #include <sys/mnttab.h> 35fa9e4066Sahrens #include <sys/param.h> 36fa9e4066Sahrens #include <sys/types.h> 37fa9e4066Sahrens #include <sys/varargs.h> 38fa9e4066Sahrens #include <sys/fs/zfs.h> 39ecd6cf80Smarks #include <sys/avl.h> 40ecd6cf80Smarks #include <ucred.h> 41fa9e4066Sahrens 42fa9e4066Sahrens #ifdef __cplusplus 43fa9e4066Sahrens extern "C" { 44fa9e4066Sahrens #endif 45fa9e4066Sahrens 46fa9e4066Sahrens /* 47fa9e4066Sahrens * Miscellaneous ZFS constants 48fa9e4066Sahrens */ 49fa9e4066Sahrens #define ZFS_MAXNAMELEN MAXNAMELEN 50fa9e4066Sahrens #define ZPOOL_MAXNAMELEN MAXNAMELEN 51fa9e4066Sahrens #define ZFS_MAXPROPLEN MAXPATHLEN 52990b4856Slling #define ZPOOL_MAXPROPLEN MAXPATHLEN 53fa9e4066Sahrens 54fa9e4066Sahrens /* 5599653d4eSeschrock * libzfs errors 5699653d4eSeschrock */ 5799653d4eSeschrock enum { 5899653d4eSeschrock EZFS_NOMEM = 2000, /* out of memory */ 5999653d4eSeschrock EZFS_BADPROP, /* invalid property value */ 6099653d4eSeschrock EZFS_PROPREADONLY, /* cannot set readonly property */ 6199653d4eSeschrock EZFS_PROPTYPE, /* property does not apply to dataset type */ 6299653d4eSeschrock EZFS_PROPNONINHERIT, /* property is not inheritable */ 6399653d4eSeschrock EZFS_PROPSPACE, /* bad quota or reservation */ 6499653d4eSeschrock EZFS_BADTYPE, /* dataset is not of appropriate type */ 6599653d4eSeschrock EZFS_BUSY, /* pool or dataset is busy */ 6699653d4eSeschrock EZFS_EXISTS, /* pool or dataset already exists */ 6799653d4eSeschrock EZFS_NOENT, /* no such pool or dataset */ 6899653d4eSeschrock EZFS_BADSTREAM, /* bad backup stream */ 6999653d4eSeschrock EZFS_DSREADONLY, /* dataset is readonly */ 7099653d4eSeschrock EZFS_VOLTOOBIG, /* volume is too large for 32-bit system */ 7199653d4eSeschrock EZFS_INVALIDNAME, /* invalid dataset name */ 7299653d4eSeschrock EZFS_BADRESTORE, /* unable to restore to destination */ 7399653d4eSeschrock EZFS_BADBACKUP, /* backup failed */ 7499653d4eSeschrock EZFS_BADTARGET, /* bad attach/detach/replace target */ 7599653d4eSeschrock EZFS_NODEVICE, /* no such device in pool */ 7699653d4eSeschrock EZFS_BADDEV, /* invalid device to add */ 7799653d4eSeschrock EZFS_NOREPLICAS, /* no valid replicas */ 7899653d4eSeschrock EZFS_RESILVERING, /* currently resilvering */ 7999653d4eSeschrock EZFS_BADVERSION, /* unsupported version */ 8099653d4eSeschrock EZFS_POOLUNAVAIL, /* pool is currently unavailable */ 8199653d4eSeschrock EZFS_DEVOVERFLOW, /* too many devices in one vdev */ 8299653d4eSeschrock EZFS_BADPATH, /* must be an absolute path */ 8399653d4eSeschrock EZFS_CROSSTARGET, /* rename or clone across pool or dataset */ 8499653d4eSeschrock EZFS_ZONED, /* used improperly in local zone */ 8599653d4eSeschrock EZFS_MOUNTFAILED, /* failed to mount dataset */ 8699653d4eSeschrock EZFS_UMOUNTFAILED, /* failed to unmount dataset */ 87f3861e1aSahl EZFS_UNSHARENFSFAILED, /* unshare(1M) failed */ 88f3861e1aSahl EZFS_SHARENFSFAILED, /* share(1M) failed */ 8999653d4eSeschrock EZFS_PERM, /* permission denied */ 9099653d4eSeschrock EZFS_NOSPC, /* out of space */ 916e27f868SSam Falkner EZFS_FAULT, /* bad address */ 9299653d4eSeschrock EZFS_IO, /* I/O error */ 9399653d4eSeschrock EZFS_INTR, /* signal received */ 9499653d4eSeschrock EZFS_ISSPARE, /* device is a hot spare */ 9599653d4eSeschrock EZFS_INVALCONFIG, /* invalid vdev configuration */ 963bb79becSeschrock EZFS_RECURSIVE, /* recursive dependency */ 9706eeb2adSek110237 EZFS_NOHISTORY, /* no history object */ 98b1b8ab34Slling EZFS_POOLPROPS, /* couldn't retrieve pool props */ 99b1b8ab34Slling EZFS_POOL_NOTSUP, /* ops not supported for this type of pool */ 100b1b8ab34Slling EZFS_POOL_INVALARG, /* invalid argument for this pool operation */ 101b7661cccSmmusante EZFS_NAMETOOLONG, /* dataset name is too long */ 1028488aeb5Staylor EZFS_OPENFAILED, /* open of device failed */ 1038488aeb5Staylor EZFS_NOCAP, /* couldn't get capacity */ 1048488aeb5Staylor EZFS_LABELFAILED, /* write of label failed */ 105ecd6cf80Smarks EZFS_BADWHO, /* invalid permission who */ 106ecd6cf80Smarks EZFS_BADPERM, /* invalid permission */ 107ecd6cf80Smarks EZFS_BADPERMSET, /* invalid permission set name */ 108ecd6cf80Smarks EZFS_NODELEGATION, /* delegated administration is disabled */ 109da6c28aaSamw EZFS_UNSHARESMBFAILED, /* failed to unshare over smb */ 110da6c28aaSamw EZFS_SHARESMBFAILED, /* failed to share over smb */ 1112f8aaab3Seschrock EZFS_BADCACHE, /* bad cache file */ 112fa94a07fSbrendan EZFS_ISL2CACHE, /* device is for the level 2 ARC */ 113e7cbe64fSgw25295 EZFS_VDEVNOTSUP, /* unsupported vdev type */ 11415e6edf1Sgw25295 EZFS_NOTSUP, /* ops not supported on this dataset */ 11589a89ebfSlling EZFS_ACTIVE_SPARE, /* pool has active shared spare devices */ 116e6ca193dSGeorge Wilson EZFS_UNPLAYED_LOGS, /* log device has unplayed logs */ 117842727c2SChris Kirby EZFS_REFTAG_RELE, /* snapshot release: tag not found */ 118842727c2SChris Kirby EZFS_REFTAG_HOLD, /* snapshot hold: tag already exists */ 119ca45db41SChris Kirby EZFS_TAGTOOLONG, /* snapshot hold/rele: tag too long */ 1209e69d7d0SLori Alt EZFS_PIPEFAILED, /* pipe create failed */ 1219e69d7d0SLori Alt EZFS_THREADCREATEFAILED, /* thread create failed */ 1221195e687SMark J Musante EZFS_POSTSPLIT_ONLINE, /* onlining a disk after splitting it */ 1233f9d6ad7SLin Ling EZFS_SCRUBBING, /* currently scrubbing */ 1243f9d6ad7SLin Ling EZFS_NO_SCRUB, /* no active scrub */ 12599d5e173STim Haley EZFS_DIFF, /* general failure of zfs diff */ 12699d5e173STim Haley EZFS_DIFFDATA, /* bad zfs diff data */ 127f9af39baSGeorge Wilson EZFS_POOLREADONLY, /* pool is in read-only mode */ 128b1b8ab34Slling EZFS_UNKNOWN 12999653d4eSeschrock }; 13099653d4eSeschrock 13199653d4eSeschrock /* 132ecd6cf80Smarks * The following data structures are all part 133ecd6cf80Smarks * of the zfs_allow_t data structure which is 134ecd6cf80Smarks * used for printing 'allow' permissions. 135ecd6cf80Smarks * It is a linked list of zfs_allow_t's which 136ecd6cf80Smarks * then contain avl tree's for user/group/sets/... 137ecd6cf80Smarks * and each one of the entries in those trees have 138ecd6cf80Smarks * avl tree's for the permissions they belong to and 139ecd6cf80Smarks * whether they are local,descendent or local+descendent 140ecd6cf80Smarks * permissions. The AVL trees are used primarily for 141ecd6cf80Smarks * sorting purposes, but also so that we can quickly find 142ecd6cf80Smarks * a given user and or permission. 143ecd6cf80Smarks */ 144ecd6cf80Smarks typedef struct zfs_perm_node { 145ecd6cf80Smarks avl_node_t z_node; 146ecd6cf80Smarks char z_pname[MAXPATHLEN]; 147ecd6cf80Smarks } zfs_perm_node_t; 148ecd6cf80Smarks 149ecd6cf80Smarks typedef struct zfs_allow_node { 150ecd6cf80Smarks avl_node_t z_node; 151ecd6cf80Smarks char z_key[MAXPATHLEN]; /* name, such as joe */ 152ecd6cf80Smarks avl_tree_t z_localdescend; /* local+descendent perms */ 153ecd6cf80Smarks avl_tree_t z_local; /* local permissions */ 154ecd6cf80Smarks avl_tree_t z_descend; /* descendent permissions */ 155ecd6cf80Smarks } zfs_allow_node_t; 156ecd6cf80Smarks 157ecd6cf80Smarks typedef struct zfs_allow { 158ecd6cf80Smarks struct zfs_allow *z_next; 159ecd6cf80Smarks char z_setpoint[MAXPATHLEN]; 160ecd6cf80Smarks avl_tree_t z_sets; 161ecd6cf80Smarks avl_tree_t z_crperms; 162ecd6cf80Smarks avl_tree_t z_user; 163ecd6cf80Smarks avl_tree_t z_group; 164ecd6cf80Smarks avl_tree_t z_everyone; 165ecd6cf80Smarks } zfs_allow_t; 166ecd6cf80Smarks 167ecd6cf80Smarks /* 168fa9e4066Sahrens * Basic handle types 169fa9e4066Sahrens */ 170fa9e4066Sahrens typedef struct zfs_handle zfs_handle_t; 171fa9e4066Sahrens typedef struct zpool_handle zpool_handle_t; 17299653d4eSeschrock typedef struct libzfs_handle libzfs_handle_t; 17399653d4eSeschrock 17499653d4eSeschrock /* 17599653d4eSeschrock * Library initialization 17699653d4eSeschrock */ 17799653d4eSeschrock extern libzfs_handle_t *libzfs_init(void); 17899653d4eSeschrock extern void libzfs_fini(libzfs_handle_t *); 17999653d4eSeschrock 18099653d4eSeschrock extern libzfs_handle_t *zpool_get_handle(zpool_handle_t *); 18199653d4eSeschrock extern libzfs_handle_t *zfs_get_handle(zfs_handle_t *); 18299653d4eSeschrock 18399653d4eSeschrock extern void libzfs_print_on_error(libzfs_handle_t *, boolean_t); 18499653d4eSeschrock 18599653d4eSeschrock extern int libzfs_errno(libzfs_handle_t *); 18699653d4eSeschrock extern const char *libzfs_error_action(libzfs_handle_t *); 18799653d4eSeschrock extern const char *libzfs_error_description(libzfs_handle_t *); 188ebedde84SEric Taylor extern void libzfs_mnttab_init(libzfs_handle_t *); 189ebedde84SEric Taylor extern void libzfs_mnttab_fini(libzfs_handle_t *); 190b2634b9cSEric Taylor extern void libzfs_mnttab_cache(libzfs_handle_t *, boolean_t); 191ebedde84SEric Taylor extern int libzfs_mnttab_find(libzfs_handle_t *, const char *, 192ebedde84SEric Taylor struct mnttab *); 193ebedde84SEric Taylor extern void libzfs_mnttab_add(libzfs_handle_t *, const char *, 194ebedde84SEric Taylor const char *, const char *); 195ebedde84SEric Taylor extern void libzfs_mnttab_remove(libzfs_handle_t *, const char *); 196fa9e4066Sahrens 197fa9e4066Sahrens /* 198fa9e4066Sahrens * Basic handle functions 199fa9e4066Sahrens */ 20099653d4eSeschrock extern zpool_handle_t *zpool_open(libzfs_handle_t *, const char *); 20199653d4eSeschrock extern zpool_handle_t *zpool_open_canfail(libzfs_handle_t *, const char *); 202fa9e4066Sahrens extern void zpool_close(zpool_handle_t *); 203fa9e4066Sahrens extern const char *zpool_get_name(zpool_handle_t *); 204fa9e4066Sahrens extern int zpool_get_state(zpool_handle_t *); 205990b4856Slling extern char *zpool_state_to_name(vdev_state_t, vdev_aux_t); 20629ab75c9Srm160521 extern void zpool_free_handles(libzfs_handle_t *); 207fa9e4066Sahrens 208fa9e4066Sahrens /* 209fa9e4066Sahrens * Iterate over all active pools in the system. 210fa9e4066Sahrens */ 211fa9e4066Sahrens typedef int (*zpool_iter_f)(zpool_handle_t *, void *); 21299653d4eSeschrock extern int zpool_iter(libzfs_handle_t *, zpool_iter_f, void *); 213fa9e4066Sahrens 214fa9e4066Sahrens /* 215fa9e4066Sahrens * Functions to create and destroy pools 216fa9e4066Sahrens */ 21799653d4eSeschrock extern int zpool_create(libzfs_handle_t *, const char *, nvlist_t *, 2180a48a24eStimh nvlist_t *, nvlist_t *); 219fa9e4066Sahrens extern int zpool_destroy(zpool_handle_t *); 220fa9e4066Sahrens extern int zpool_add(zpool_handle_t *, nvlist_t *); 221fa9e4066Sahrens 2221195e687SMark J Musante typedef struct splitflags { 2231195e687SMark J Musante /* do not split, but return the config that would be split off */ 2241195e687SMark J Musante int dryrun : 1; 2251195e687SMark J Musante 2261195e687SMark J Musante /* after splitting, import the pool */ 2271195e687SMark J Musante int import : 1; 2281195e687SMark J Musante } splitflags_t; 2291195e687SMark J Musante 230fa9e4066Sahrens /* 231fa9e4066Sahrens * Functions to manipulate pool and vdev state 232fa9e4066Sahrens */ 2333f9d6ad7SLin Ling extern int zpool_scan(zpool_handle_t *, pool_scan_func_t); 234468c413aSTim Haley extern int zpool_clear(zpool_handle_t *, const char *, nvlist_t *); 235e9103aaeSGarrett D'Amore extern int zpool_reguid(zpool_handle_t *); 2364263d13fSGeorge Wilson extern int zpool_reopen(zpool_handle_t *); 237fa9e4066Sahrens 2383d7072f8Seschrock extern int zpool_vdev_online(zpool_handle_t *, const char *, int, 2393d7072f8Seschrock vdev_state_t *); 2403d7072f8Seschrock extern int zpool_vdev_offline(zpool_handle_t *, const char *, boolean_t); 2413d7072f8Seschrock extern int zpool_vdev_attach(zpool_handle_t *, const char *, 2423d7072f8Seschrock const char *, nvlist_t *, int); 243fa9e4066Sahrens extern int zpool_vdev_detach(zpool_handle_t *, const char *); 24499653d4eSeschrock extern int zpool_vdev_remove(zpool_handle_t *, const char *); 2451195e687SMark J Musante extern int zpool_vdev_split(zpool_handle_t *, char *, nvlist_t **, nvlist_t *, 2461195e687SMark J Musante splitflags_t); 2473d7072f8Seschrock 248069f55e2SEric Schrock extern int zpool_vdev_fault(zpool_handle_t *, uint64_t, vdev_aux_t); 249069f55e2SEric Schrock extern int zpool_vdev_degrade(zpool_handle_t *, uint64_t, vdev_aux_t); 2503d7072f8Seschrock extern int zpool_vdev_clear(zpool_handle_t *, uint64_t); 2513d7072f8Seschrock 252fa94a07fSbrendan extern nvlist_t *zpool_find_vdev(zpool_handle_t *, const char *, boolean_t *, 253ee0eb9f2SEric Schrock boolean_t *, boolean_t *); 254573ca77eSGeorge Wilson extern nvlist_t *zpool_find_vdev_by_physpath(zpool_handle_t *, const char *, 255573ca77eSGeorge Wilson boolean_t *, boolean_t *, boolean_t *); 2568488aeb5Staylor extern int zpool_label_disk(libzfs_handle_t *, zpool_handle_t *, char *); 257fa9e4066Sahrens 258fa9e4066Sahrens /* 259b1b8ab34Slling * Functions to manage pool properties 260b1b8ab34Slling */ 261b1b8ab34Slling extern int zpool_set_prop(zpool_handle_t *, const char *, const char *); 2623d7072f8Seschrock extern int zpool_get_prop(zpool_handle_t *, zpool_prop_t, char *, 263990b4856Slling size_t proplen, zprop_source_t *); 264990b4856Slling extern uint64_t zpool_get_prop_int(zpool_handle_t *, zpool_prop_t, 265990b4856Slling zprop_source_t *); 266990b4856Slling 267b1b8ab34Slling extern const char *zpool_prop_to_name(zpool_prop_t); 268b1b8ab34Slling extern const char *zpool_prop_values(zpool_prop_t); 269b1b8ab34Slling 270b1b8ab34Slling /* 271fa9e4066Sahrens * Pool health statistics. 272fa9e4066Sahrens */ 273fa9e4066Sahrens typedef enum { 274fa9e4066Sahrens /* 275fa9e4066Sahrens * The following correspond to faults as defined in the (fault.fs.zfs.*) 276b81d61a6Slling * event namespace. Each is associated with a corresponding message ID. 277fa9e4066Sahrens */ 278fa9e4066Sahrens ZPOOL_STATUS_CORRUPT_CACHE, /* corrupt /kernel/drv/zpool.cache */ 279fa9e4066Sahrens ZPOOL_STATUS_MISSING_DEV_R, /* missing device with replicas */ 280fa9e4066Sahrens ZPOOL_STATUS_MISSING_DEV_NR, /* missing device with no replicas */ 281fa9e4066Sahrens ZPOOL_STATUS_CORRUPT_LABEL_R, /* bad device label with replicas */ 282b81d61a6Slling ZPOOL_STATUS_CORRUPT_LABEL_NR, /* bad device label with no replicas */ 283fa9e4066Sahrens ZPOOL_STATUS_BAD_GUID_SUM, /* sum of device guids didn't match */ 284fa9e4066Sahrens ZPOOL_STATUS_CORRUPT_POOL, /* pool metadata is corrupted */ 285fa9e4066Sahrens ZPOOL_STATUS_CORRUPT_DATA, /* data errors in user (meta)data */ 286fa9e4066Sahrens ZPOOL_STATUS_FAILING_DEV, /* device experiencing errors */ 287eaca9bbdSeschrock ZPOOL_STATUS_VERSION_NEWER, /* newer on-disk version */ 28895173954Sek110237 ZPOOL_STATUS_HOSTID_MISMATCH, /* last accessed by another system */ 28932b87932Sek110237 ZPOOL_STATUS_IO_FAILURE_WAIT, /* failed I/O, failmode 'wait' */ 29032b87932Sek110237 ZPOOL_STATUS_IO_FAILURE_CONTINUE, /* failed I/O, failmode 'continue' */ 291f67f35c3SEric Schrock ZPOOL_STATUS_BAD_LOG, /* cannot read log chain(s) */ 292f67f35c3SEric Schrock 293f67f35c3SEric Schrock /* 294*ad135b5dSChristopher Siden * If the pool has unsupported features but can still be opened in 295*ad135b5dSChristopher Siden * read-only mode, its status is ZPOOL_STATUS_UNSUP_FEAT_WRITE. If the 296*ad135b5dSChristopher Siden * pool has unsupported features but cannot be opened at all, its 297*ad135b5dSChristopher Siden * status is ZPOOL_STATUS_UNSUP_FEAT_READ. 298*ad135b5dSChristopher Siden */ 299*ad135b5dSChristopher Siden ZPOOL_STATUS_UNSUP_FEAT_READ, /* unsupported features for read */ 300*ad135b5dSChristopher Siden ZPOOL_STATUS_UNSUP_FEAT_WRITE, /* unsupported features for write */ 301*ad135b5dSChristopher Siden 302*ad135b5dSChristopher Siden /* 303f67f35c3SEric Schrock * These faults have no corresponding message ID. At the time we are 304f67f35c3SEric Schrock * checking the status, the original reason for the FMA fault (I/O or 305f67f35c3SEric Schrock * checksum errors) has been lost. 306f67f35c3SEric Schrock */ 3073d7072f8Seschrock ZPOOL_STATUS_FAULTED_DEV_R, /* faulted device with replicas */ 3083d7072f8Seschrock ZPOOL_STATUS_FAULTED_DEV_NR, /* faulted device with no replicas */ 309fa9e4066Sahrens 310fa9e4066Sahrens /* 311fa9e4066Sahrens * The following are not faults per se, but still an error possibly 312b81d61a6Slling * requiring administrative attention. There is no corresponding 313fa9e4066Sahrens * message ID. 314fa9e4066Sahrens */ 315eaca9bbdSeschrock ZPOOL_STATUS_VERSION_OLDER, /* older on-disk version */ 316fa9e4066Sahrens ZPOOL_STATUS_RESILVERING, /* device being resilvered */ 317fa9e4066Sahrens ZPOOL_STATUS_OFFLINE_DEV, /* device online */ 318c25309d4SGeorge Wilson ZPOOL_STATUS_REMOVED_DEV, /* removed device */ 319fa9e4066Sahrens 320fa9e4066Sahrens /* 321fa9e4066Sahrens * Finally, the following indicates a healthy pool. 322fa9e4066Sahrens */ 323fa9e4066Sahrens ZPOOL_STATUS_OK 324fa9e4066Sahrens } zpool_status_t; 325fa9e4066Sahrens 326ea8dc4b6Seschrock extern zpool_status_t zpool_get_status(zpool_handle_t *, char **); 327ea8dc4b6Seschrock extern zpool_status_t zpool_import_status(nvlist_t *, char **); 3289eb19f4dSGeorge Wilson extern void zpool_dump_ddt(const ddt_stat_t *dds, const ddt_histogram_t *ddh); 329fa9e4066Sahrens 330fa9e4066Sahrens /* 331fa9e4066Sahrens * Statistics and configuration functions. 332fa9e4066Sahrens */ 333ea8dc4b6Seschrock extern nvlist_t *zpool_get_config(zpool_handle_t *, nvlist_t **); 334*ad135b5dSChristopher Siden extern nvlist_t *zpool_get_features(zpool_handle_t *); 33594de1d4cSeschrock extern int zpool_refresh_stats(zpool_handle_t *, boolean_t *); 33655434c77Sek110237 extern int zpool_get_errlog(zpool_handle_t *, nvlist_t **); 337ea8dc4b6Seschrock 338fa9e4066Sahrens /* 339fa9e4066Sahrens * Import and export functions 340fa9e4066Sahrens */ 34189a89ebfSlling extern int zpool_export(zpool_handle_t *, boolean_t); 342394ab0cbSGeorge Wilson extern int zpool_export_force(zpool_handle_t *); 34399653d4eSeschrock extern int zpool_import(libzfs_handle_t *, nvlist_t *, const char *, 344990b4856Slling char *altroot); 345990b4856Slling extern int zpool_import_props(libzfs_handle_t *, nvlist_t *, const char *, 3464b964adaSGeorge Wilson nvlist_t *, int); 347*ad135b5dSChristopher Siden extern void zpool_print_unsup_feat(nvlist_t *config); 348fa9e4066Sahrens 349fa9e4066Sahrens /* 350fa9e4066Sahrens * Search for pools to import 351fa9e4066Sahrens */ 352d41c4376SMark J Musante 353d41c4376SMark J Musante typedef struct importargs { 354d41c4376SMark J Musante char **path; /* a list of paths to search */ 355d41c4376SMark J Musante int paths; /* number of paths to search */ 356d41c4376SMark J Musante char *poolname; /* name of a pool to find */ 357d41c4376SMark J Musante uint64_t guid; /* guid of a pool to find */ 358d41c4376SMark J Musante char *cachefile; /* cachefile to use for import */ 359d41c4376SMark J Musante int can_be_active : 1; /* can the pool be active? */ 360d41c4376SMark J Musante int unique : 1; /* does 'poolname' already exist? */ 361d41c4376SMark J Musante int exists : 1; /* set on return if pool already exists */ 362d41c4376SMark J Musante } importargs_t; 363d41c4376SMark J Musante 364d41c4376SMark J Musante extern nvlist_t *zpool_search_import(libzfs_handle_t *, importargs_t *); 365d41c4376SMark J Musante 366d41c4376SMark J Musante /* legacy pool search routines */ 36724e697d4Sck153898 extern nvlist_t *zpool_find_import(libzfs_handle_t *, int, char **); 3683a57275aSck153898 extern nvlist_t *zpool_find_import_cached(libzfs_handle_t *, const char *, 369e829d913Sck153898 char *, uint64_t); 370fa9e4066Sahrens 371fa9e4066Sahrens /* 372c67d9675Seschrock * Miscellaneous pool functions 373c67d9675Seschrock */ 374ecd6cf80Smarks struct zfs_cmd; 375ecd6cf80Smarks 3763f9d6ad7SLin Ling extern const char *zfs_history_event_names[LOG_END]; 3778f18d1faSGeorge Wilson 37888ecc943SGeorge Wilson extern char *zpool_vdev_name(libzfs_handle_t *, zpool_handle_t *, nvlist_t *, 37988ecc943SGeorge Wilson boolean_t verbose); 380990b4856Slling extern int zpool_upgrade(zpool_handle_t *, uint64_t); 38106eeb2adSek110237 extern int zpool_get_history(zpool_handle_t *, nvlist_t **); 3828f18d1faSGeorge Wilson extern int zpool_history_unpack(char *, uint64_t, uint64_t *, 3838f18d1faSGeorge Wilson nvlist_t ***, uint_t *); 3842a6b87f0Sek110237 extern void zpool_set_history_str(const char *subcommand, int argc, 3852a6b87f0Sek110237 char **argv, char *history_str); 3862a6b87f0Sek110237 extern int zpool_stage_history(libzfs_handle_t *, const char *); 38755434c77Sek110237 extern void zpool_obj_to_path(zpool_handle_t *, uint64_t, uint64_t, char *, 38855434c77Sek110237 size_t len); 389ecd6cf80Smarks extern int zfs_ioctl(libzfs_handle_t *, int, struct zfs_cmd *); 390753a6d45SSherry Moore extern int zpool_get_physpath(zpool_handle_t *, char *, size_t); 391468c413aSTim Haley extern void zpool_explain_recover(libzfs_handle_t *, const char *, int, 392468c413aSTim Haley nvlist_t *); 393753a6d45SSherry Moore 394c67d9675Seschrock /* 395fa9e4066Sahrens * Basic handle manipulations. These functions do not create or destroy the 396fa9e4066Sahrens * underlying datasets, only the references to them. 397fa9e4066Sahrens */ 39899653d4eSeschrock extern zfs_handle_t *zfs_open(libzfs_handle_t *, const char *, int); 39919b94df9SMatthew Ahrens extern zfs_handle_t *zfs_handle_dup(zfs_handle_t *); 400fa9e4066Sahrens extern void zfs_close(zfs_handle_t *); 401fa9e4066Sahrens extern zfs_type_t zfs_get_type(const zfs_handle_t *); 402fa9e4066Sahrens extern const char *zfs_get_name(const zfs_handle_t *); 403d5b5bb25SRich Morris extern zpool_handle_t *zfs_get_pool_handle(const zfs_handle_t *); 404fa9e4066Sahrens 405fa9e4066Sahrens /* 406fa9e4066Sahrens * Property management functions. Some functions are shared with the kernel, 407b81d61a6Slling * and are found in sys/fs/zfs.h. 408fa9e4066Sahrens */ 409990b4856Slling 410990b4856Slling /* 411990b4856Slling * zfs dataset property management 412990b4856Slling */ 413990b4856Slling extern const char *zfs_prop_default_string(zfs_prop_t); 414e9dbad6fSeschrock extern uint64_t zfs_prop_default_numeric(zfs_prop_t); 415e9dbad6fSeschrock extern const char *zfs_prop_column_name(zfs_prop_t); 416e9dbad6fSeschrock extern boolean_t zfs_prop_align_right(zfs_prop_t); 417e9dbad6fSeschrock 4180a48a24eStimh extern nvlist_t *zfs_valid_proplist(libzfs_handle_t *, zfs_type_t, 4190a48a24eStimh nvlist_t *, uint64_t, zfs_handle_t *, const char *); 4200a48a24eStimh 421990b4856Slling extern const char *zfs_prop_to_name(zfs_prop_t); 422990b4856Slling extern int zfs_prop_set(zfs_handle_t *, const char *, const char *); 423990b4856Slling extern int zfs_prop_get(zfs_handle_t *, zfs_prop_t, char *, size_t, 424990b4856Slling zprop_source_t *, char *, size_t, boolean_t); 42592241e0bSTom Erickson extern int zfs_prop_get_recvd(zfs_handle_t *, const char *, char *, size_t, 42692241e0bSTom Erickson boolean_t); 427990b4856Slling extern int zfs_prop_get_numeric(zfs_handle_t *, zfs_prop_t, uint64_t *, 428990b4856Slling zprop_source_t *, char *, size_t); 429edea4b55SLin Ling extern int zfs_prop_get_userquota_int(zfs_handle_t *zhp, const char *propname, 430edea4b55SLin Ling uint64_t *propvalue); 43114843421SMatthew Ahrens extern int zfs_prop_get_userquota(zfs_handle_t *zhp, const char *propname, 43214843421SMatthew Ahrens char *propbuf, int proplen, boolean_t literal); 43319b94df9SMatthew Ahrens extern int zfs_prop_get_written_int(zfs_handle_t *zhp, const char *propname, 43419b94df9SMatthew Ahrens uint64_t *propvalue); 43519b94df9SMatthew Ahrens extern int zfs_prop_get_written(zfs_handle_t *zhp, const char *propname, 43619b94df9SMatthew Ahrens char *propbuf, int proplen, boolean_t literal); 437*ad135b5dSChristopher Siden extern int zfs_prop_get_feature(zfs_handle_t *zhp, const char *propname, 438*ad135b5dSChristopher Siden char *buf, size_t len); 43919b94df9SMatthew Ahrens extern int zfs_get_snapused_int(zfs_handle_t *firstsnap, zfs_handle_t *lastsnap, 44019b94df9SMatthew Ahrens uint64_t *usedp); 441990b4856Slling extern uint64_t zfs_prop_get_int(zfs_handle_t *, zfs_prop_t); 44292241e0bSTom Erickson extern int zfs_prop_inherit(zfs_handle_t *, const char *, boolean_t); 443990b4856Slling extern const char *zfs_prop_values(zfs_prop_t); 444990b4856Slling extern int zfs_prop_is_string(zfs_prop_t prop); 445990b4856Slling extern nvlist_t *zfs_get_user_props(zfs_handle_t *); 44692241e0bSTom Erickson extern nvlist_t *zfs_get_recvd_props(zfs_handle_t *); 44719b94df9SMatthew Ahrens extern nvlist_t *zfs_get_clones_nvl(zfs_handle_t *); 44819b94df9SMatthew Ahrens 449990b4856Slling 450990b4856Slling typedef struct zprop_list { 451990b4856Slling int pl_prop; 452e9dbad6fSeschrock char *pl_user_prop; 453990b4856Slling struct zprop_list *pl_next; 454e9dbad6fSeschrock boolean_t pl_all; 455e9dbad6fSeschrock size_t pl_width; 45692241e0bSTom Erickson size_t pl_recvd_width; 457e9dbad6fSeschrock boolean_t pl_fixed; 458990b4856Slling } zprop_list_t; 459e9dbad6fSeschrock 46092241e0bSTom Erickson extern int zfs_expand_proplist(zfs_handle_t *, zprop_list_t **, boolean_t); 4612e5e9e19SSanjeev Bagewadi extern void zfs_prune_proplist(zfs_handle_t *, uint8_t *); 462fa9e4066Sahrens 463fa9e4066Sahrens #define ZFS_MOUNTPOINT_NONE "none" 464fa9e4066Sahrens #define ZFS_MOUNTPOINT_LEGACY "legacy" 465fa9e4066Sahrens 466*ad135b5dSChristopher Siden #define ZFS_FEATURE_DISABLED "disabled" 467*ad135b5dSChristopher Siden #define ZFS_FEATURE_ENABLED "enabled" 468*ad135b5dSChristopher Siden #define ZFS_FEATURE_ACTIVE "active" 469*ad135b5dSChristopher Siden 470*ad135b5dSChristopher Siden #define ZFS_UNSUPPORTED_INACTIVE "inactive" 471*ad135b5dSChristopher Siden #define ZFS_UNSUPPORTED_READONLY "readonly" 472*ad135b5dSChristopher Siden 473fa9e4066Sahrens /* 474990b4856Slling * zpool property management 475b1b8ab34Slling */ 476990b4856Slling extern int zpool_expand_proplist(zpool_handle_t *, zprop_list_t **); 477*ad135b5dSChristopher Siden extern int zpool_prop_get_feature(zpool_handle_t *, const char *, char *, 478*ad135b5dSChristopher Siden size_t); 479990b4856Slling extern const char *zpool_prop_default_string(zpool_prop_t); 480990b4856Slling extern uint64_t zpool_prop_default_numeric(zpool_prop_t); 481990b4856Slling extern const char *zpool_prop_column_name(zpool_prop_t); 482990b4856Slling extern boolean_t zpool_prop_align_right(zpool_prop_t); 483990b4856Slling 484990b4856Slling /* 485990b4856Slling * Functions shared by zfs and zpool property management. 486990b4856Slling */ 487990b4856Slling extern int zprop_iter(zprop_func func, void *cb, boolean_t show_all, 488990b4856Slling boolean_t ordered, zfs_type_t type); 489990b4856Slling extern int zprop_get_list(libzfs_handle_t *, char *, zprop_list_t **, 490990b4856Slling zfs_type_t); 491990b4856Slling extern void zprop_free_list(zprop_list_t *); 492990b4856Slling 49392241e0bSTom Erickson #define ZFS_GET_NCOLS 5 49492241e0bSTom Erickson 49592241e0bSTom Erickson typedef enum { 49692241e0bSTom Erickson GET_COL_NONE, 49792241e0bSTom Erickson GET_COL_NAME, 49892241e0bSTom Erickson GET_COL_PROPERTY, 49992241e0bSTom Erickson GET_COL_VALUE, 50092241e0bSTom Erickson GET_COL_RECVD, 50192241e0bSTom Erickson GET_COL_SOURCE 50292241e0bSTom Erickson } zfs_get_column_t; 50392241e0bSTom Erickson 504990b4856Slling /* 505990b4856Slling * Functions for printing zfs or zpool properties 506990b4856Slling */ 507990b4856Slling typedef struct zprop_get_cbdata { 508b1b8ab34Slling int cb_sources; 50992241e0bSTom Erickson zfs_get_column_t cb_columns[ZFS_GET_NCOLS]; 51092241e0bSTom Erickson int cb_colwidths[ZFS_GET_NCOLS + 1]; 511b1b8ab34Slling boolean_t cb_scripted; 512b1b8ab34Slling boolean_t cb_literal; 513b1b8ab34Slling boolean_t cb_first; 514990b4856Slling zprop_list_t *cb_proplist; 515990b4856Slling zfs_type_t cb_type; 516990b4856Slling } zprop_get_cbdata_t; 517b1b8ab34Slling 518990b4856Slling void zprop_print_one_property(const char *, zprop_get_cbdata_t *, 51992241e0bSTom Erickson const char *, const char *, zprop_source_t, const char *, 52092241e0bSTom Erickson const char *); 521b1b8ab34Slling 522b1b8ab34Slling /* 523fa9e4066Sahrens * Iterator functions. 524fa9e4066Sahrens */ 525fa9e4066Sahrens typedef int (*zfs_iter_f)(zfs_handle_t *, void *); 52699653d4eSeschrock extern int zfs_iter_root(libzfs_handle_t *, zfs_iter_f, void *); 527fa9e4066Sahrens extern int zfs_iter_children(zfs_handle_t *, zfs_iter_f, void *); 5283bb79becSeschrock extern int zfs_iter_dependents(zfs_handle_t *, boolean_t, zfs_iter_f, void *); 5297f7322feSeschrock extern int zfs_iter_filesystems(zfs_handle_t *, zfs_iter_f, void *); 5307f7322feSeschrock extern int zfs_iter_snapshots(zfs_handle_t *, zfs_iter_f, void *); 531ca45db41SChris Kirby extern int zfs_iter_snapshots_sorted(zfs_handle_t *, zfs_iter_f, void *); 53219b94df9SMatthew Ahrens extern int zfs_iter_snapspec(zfs_handle_t *, const char *, zfs_iter_f, void *); 533fa9e4066Sahrens 5349d9a58e3SEric Taylor typedef struct get_all_cb { 5359d9a58e3SEric Taylor zfs_handle_t **cb_handles; 5369d9a58e3SEric Taylor size_t cb_alloc; 5379d9a58e3SEric Taylor size_t cb_used; 5389d9a58e3SEric Taylor boolean_t cb_verbose; 5399d9a58e3SEric Taylor int (*cb_getone)(zfs_handle_t *, void *); 5409d9a58e3SEric Taylor } get_all_cb_t; 5419d9a58e3SEric Taylor 5429d9a58e3SEric Taylor void libzfs_add_handle(get_all_cb_t *, zfs_handle_t *); 5439d9a58e3SEric Taylor int libzfs_dataset_cmp(const void *, const void *); 5449d9a58e3SEric Taylor 545fa9e4066Sahrens /* 546fa9e4066Sahrens * Functions to create and destroy datasets. 547fa9e4066Sahrens */ 54899653d4eSeschrock extern int zfs_create(libzfs_handle_t *, const char *, zfs_type_t, 549e9dbad6fSeschrock nvlist_t *); 5507f1f55eaSvb160487 extern int zfs_create_ancestors(libzfs_handle_t *, const char *); 551842727c2SChris Kirby extern int zfs_destroy(zfs_handle_t *, boolean_t); 552842727c2SChris Kirby extern int zfs_destroy_snaps(zfs_handle_t *, char *, boolean_t); 55319b94df9SMatthew Ahrens extern int zfs_destroy_snaps_nvl(zfs_handle_t *, nvlist_t *, boolean_t); 554e9dbad6fSeschrock extern int zfs_clone(zfs_handle_t *, const char *, nvlist_t *); 555bb0ade09Sahrens extern int zfs_snapshot(libzfs_handle_t *, const char *, boolean_t, nvlist_t *); 556c391e322Sahrens extern int zfs_rollback(zfs_handle_t *, zfs_handle_t *, boolean_t); 5576a9cb0eaSEric Schrock extern int zfs_rename(zfs_handle_t *, const char *, boolean_t, boolean_t); 5589e69d7d0SLori Alt 5599e69d7d0SLori Alt typedef struct sendflags { 5609e69d7d0SLori Alt /* print informational messages (ie, -v was specified) */ 56119b94df9SMatthew Ahrens boolean_t verbose; 5629e69d7d0SLori Alt 56392241e0bSTom Erickson /* recursive send (ie, -R) */ 56419b94df9SMatthew Ahrens boolean_t replicate; 5659e69d7d0SLori Alt 5669e69d7d0SLori Alt /* for incrementals, do all intermediate snapshots */ 56719b94df9SMatthew Ahrens boolean_t doall; 5689e69d7d0SLori Alt 5699e69d7d0SLori Alt /* if dataset is a clone, do incremental from its origin */ 57019b94df9SMatthew Ahrens boolean_t fromorigin; 5719e69d7d0SLori Alt 5729e69d7d0SLori Alt /* do deduplication */ 57319b94df9SMatthew Ahrens boolean_t dedup; 57492241e0bSTom Erickson 57592241e0bSTom Erickson /* send properties (ie, -p) */ 57619b94df9SMatthew Ahrens boolean_t props; 57719b94df9SMatthew Ahrens 57819b94df9SMatthew Ahrens /* do not send (no-op, ie. -n) */ 57919b94df9SMatthew Ahrens boolean_t dryrun; 58019b94df9SMatthew Ahrens 58119b94df9SMatthew Ahrens /* parsable verbose output (ie. -P) */ 58219b94df9SMatthew Ahrens boolean_t parsable; 5834e3c9f44SBill Pijewski 5844e3c9f44SBill Pijewski /* show progress (ie. -v) */ 5854e3c9f44SBill Pijewski boolean_t progress; 5869e69d7d0SLori Alt } sendflags_t; 5879e69d7d0SLori Alt 5889e69d7d0SLori Alt typedef boolean_t (snapfilter_cb_t)(zfs_handle_t *, void *); 5899e69d7d0SLori Alt 59019b94df9SMatthew Ahrens extern int zfs_send(zfs_handle_t *, const char *, const char *, 59119b94df9SMatthew Ahrens sendflags_t *, int, snapfilter_cb_t, void *, nvlist_t **); 5929e69d7d0SLori Alt 59399653d4eSeschrock extern int zfs_promote(zfs_handle_t *); 594ca45db41SChris Kirby extern int zfs_hold(zfs_handle_t *, const char *, const char *, boolean_t, 595a7f53a56SChris Kirby boolean_t, boolean_t, int, uint64_t, uint64_t); 596842727c2SChris Kirby extern int zfs_release(zfs_handle_t *, const char *, const char *, boolean_t); 5971af68beaSAlexander Stetsenko extern int zfs_get_holds(zfs_handle_t *, nvlist_t **); 598c1449561SEric Taylor extern uint64_t zvol_volsize_to_reservation(uint64_t, nvlist_t *); 599fa9e4066Sahrens 6000aea4b19SMatthew Ahrens typedef int (*zfs_userspace_cb_t)(void *arg, const char *domain, 60114843421SMatthew Ahrens uid_t rid, uint64_t space); 60214843421SMatthew Ahrens 6031af68beaSAlexander Stetsenko extern int zfs_userspace(zfs_handle_t *, zfs_userquota_prop_t, 6041af68beaSAlexander Stetsenko zfs_userspace_cb_t, void *); 6051af68beaSAlexander Stetsenko 6061af68beaSAlexander Stetsenko extern int zfs_get_fsacl(zfs_handle_t *, nvlist_t **); 6071af68beaSAlexander Stetsenko extern int zfs_set_fsacl(zfs_handle_t *, boolean_t, nvlist_t *); 60814843421SMatthew Ahrens 6093cb34c60Sahrens typedef struct recvflags { 6104ccbb6e7Sahrens /* print informational messages (ie, -v was specified) */ 61119b94df9SMatthew Ahrens boolean_t verbose; 6124ccbb6e7Sahrens 6134ccbb6e7Sahrens /* the destination is a prefix, not the exact fs (ie, -d) */ 61419b94df9SMatthew Ahrens boolean_t isprefix; 6154ccbb6e7Sahrens 616f64930f5STom Erickson /* 617f64930f5STom Erickson * Only the tail of the sent snapshot path is appended to the 618f64930f5STom Erickson * destination to determine the received snapshot name (ie, -e). 619f64930f5STom Erickson */ 62019b94df9SMatthew Ahrens boolean_t istail; 621f64930f5STom Erickson 6224ccbb6e7Sahrens /* do not actually do the recv, just check if it would work (ie, -n) */ 62319b94df9SMatthew Ahrens boolean_t dryrun; 6244ccbb6e7Sahrens 6254ccbb6e7Sahrens /* rollback/destroy filesystems as necessary (eg, -F) */ 62619b94df9SMatthew Ahrens boolean_t force; 6274ccbb6e7Sahrens 6284ccbb6e7Sahrens /* set "canmount=off" on all modified filesystems */ 62919b94df9SMatthew Ahrens boolean_t canmountoff; 6304ccbb6e7Sahrens 6314ccbb6e7Sahrens /* byteswap flag is used internally; callers need not specify */ 63219b94df9SMatthew Ahrens boolean_t byteswap; 63333408eefSLori Alt 63433408eefSLori Alt /* do not mount file systems as they are extracted (private) */ 63519b94df9SMatthew Ahrens boolean_t nomount; 6363cb34c60Sahrens } recvflags_t; 6373cb34c60Sahrens 63819b94df9SMatthew Ahrens extern int zfs_receive(libzfs_handle_t *, const char *, recvflags_t *, 6393cb34c60Sahrens int, avl_tree_t *); 6403cb34c60Sahrens 64199d5e173STim Haley typedef enum diff_flags { 64299d5e173STim Haley ZFS_DIFF_PARSEABLE = 0x1, 64399d5e173STim Haley ZFS_DIFF_TIMESTAMP = 0x2, 64499d5e173STim Haley ZFS_DIFF_CLASSIFY = 0x4 64599d5e173STim Haley } diff_flags_t; 64699d5e173STim Haley 64799d5e173STim Haley extern int zfs_show_diffs(zfs_handle_t *, int, const char *, const char *, 64899d5e173STim Haley int); 64999d5e173STim Haley 650fa9e4066Sahrens /* 651fa9e4066Sahrens * Miscellaneous functions. 652fa9e4066Sahrens */ 653fa9e4066Sahrens extern const char *zfs_type_to_name(zfs_type_t); 654fa9e4066Sahrens extern void zfs_refresh_properties(zfs_handle_t *); 655fa9e4066Sahrens extern int zfs_name_valid(const char *, zfs_type_t); 6565aba80dbSck153898 extern zfs_handle_t *zfs_path_to_zhandle(libzfs_handle_t *, char *, zfs_type_t); 6577f1f55eaSvb160487 extern boolean_t zfs_dataset_exists(libzfs_handle_t *, const char *, 6587f1f55eaSvb160487 zfs_type_t); 6597b97dc1aSrm160521 extern int zfs_spa_version(zfs_handle_t *, int *); 660fa9e4066Sahrens 661fa9e4066Sahrens /* 662fa9e4066Sahrens * Mount support functions. 663fa9e4066Sahrens */ 66455434c77Sek110237 extern boolean_t is_mounted(libzfs_handle_t *, const char *special, char **); 66599653d4eSeschrock extern boolean_t zfs_is_mounted(zfs_handle_t *, char **); 666fa9e4066Sahrens extern int zfs_mount(zfs_handle_t *, const char *, int); 667fa9e4066Sahrens extern int zfs_unmount(zfs_handle_t *, const char *, int); 668fa9e4066Sahrens extern int zfs_unmountall(zfs_handle_t *, int); 669fa9e4066Sahrens 670fa9e4066Sahrens /* 671fa9e4066Sahrens * Share support functions. 672fa9e4066Sahrens */ 673f3861e1aSahl extern boolean_t zfs_is_shared(zfs_handle_t *); 674fa9e4066Sahrens extern int zfs_share(zfs_handle_t *); 675f3861e1aSahl extern int zfs_unshare(zfs_handle_t *); 676f3861e1aSahl 677f3861e1aSahl /* 6783d7072f8Seschrock * Protocol-specific share support functions. 679f3861e1aSahl */ 680f3861e1aSahl extern boolean_t zfs_is_shared_nfs(zfs_handle_t *, char **); 681da6c28aaSamw extern boolean_t zfs_is_shared_smb(zfs_handle_t *, char **); 682f3861e1aSahl extern int zfs_share_nfs(zfs_handle_t *); 683da6c28aaSamw extern int zfs_share_smb(zfs_handle_t *); 684da6c28aaSamw extern int zfs_shareall(zfs_handle_t *); 685f3861e1aSahl extern int zfs_unshare_nfs(zfs_handle_t *, const char *); 686da6c28aaSamw extern int zfs_unshare_smb(zfs_handle_t *, const char *); 687f3861e1aSahl extern int zfs_unshareall_nfs(zfs_handle_t *); 688da6c28aaSamw extern int zfs_unshareall_smb(zfs_handle_t *); 689da6c28aaSamw extern int zfs_unshareall_bypath(zfs_handle_t *, const char *); 690da6c28aaSamw extern int zfs_unshareall(zfs_handle_t *); 691743a77edSAlan Wright extern int zfs_deleg_share_nfs(libzfs_handle_t *, char *, char *, char *, 692da6c28aaSamw void *, void *, int, zfs_share_op_t); 693fa9e4066Sahrens 694fa9e4066Sahrens /* 695fa9e4066Sahrens * When dealing with nvlists, verify() is extremely useful 696fa9e4066Sahrens */ 697fa9e4066Sahrens #ifdef NDEBUG 698fa9e4066Sahrens #define verify(EX) ((void)(EX)) 699fa9e4066Sahrens #else 700fa9e4066Sahrens #define verify(EX) assert(EX) 701fa9e4066Sahrens #endif 702fa9e4066Sahrens 703fa9e4066Sahrens /* 704fa9e4066Sahrens * Utility function to convert a number to a human-readable form. 705fa9e4066Sahrens */ 706fa9e4066Sahrens extern void zfs_nicenum(uint64_t, char *, size_t); 707e9dbad6fSeschrock extern int zfs_nicestrtonum(libzfs_handle_t *, const char *, uint64_t *); 708fa9e4066Sahrens 709fa9e4066Sahrens /* 710fa9e4066Sahrens * Given a device or file, determine if it is part of a pool. 711fa9e4066Sahrens */ 71299653d4eSeschrock extern int zpool_in_use(libzfs_handle_t *, int, pool_state_t *, char **, 71399653d4eSeschrock boolean_t *); 714fa9e4066Sahrens 715fa9e4066Sahrens /* 716096d22d4SEric Schrock * Label manipulation. 717fa9e4066Sahrens */ 71899653d4eSeschrock extern int zpool_read_label(int, nvlist_t **); 719096d22d4SEric Schrock extern int zpool_clear_label(int); 720fa9e4066Sahrens 721e7cbe64fSgw25295 /* is this zvol valid for use as a dump device? */ 722e7cbe64fSgw25295 extern int zvol_check_dump_config(char *); 723e7cbe64fSgw25295 7243bb79becSeschrock /* 725743a77edSAlan Wright * Management interfaces for SMB ACL files 726743a77edSAlan Wright */ 727743a77edSAlan Wright 728743a77edSAlan Wright int zfs_smb_acl_add(libzfs_handle_t *, char *, char *, char *); 729743a77edSAlan Wright int zfs_smb_acl_remove(libzfs_handle_t *, char *, char *, char *); 730743a77edSAlan Wright int zfs_smb_acl_purge(libzfs_handle_t *, char *, char *); 731743a77edSAlan Wright int zfs_smb_acl_rename(libzfs_handle_t *, char *, char *, char *, char *); 732743a77edSAlan Wright 733743a77edSAlan Wright /* 734f3861e1aSahl * Enable and disable datasets within a pool by mounting/unmounting and 735f3861e1aSahl * sharing/unsharing them. 7363bb79becSeschrock */ 737f3861e1aSahl extern int zpool_enable_datasets(zpool_handle_t *, const char *, int); 738f3861e1aSahl extern int zpool_disable_datasets(zpool_handle_t *, boolean_t); 7393bb79becSeschrock 740069f55e2SEric Schrock /* 741069f55e2SEric Schrock * Mappings between vdev and FRU. 742069f55e2SEric Schrock */ 743069f55e2SEric Schrock extern void libzfs_fru_refresh(libzfs_handle_t *); 744069f55e2SEric Schrock extern const char *libzfs_fru_lookup(libzfs_handle_t *, const char *); 745069f55e2SEric Schrock extern const char *libzfs_fru_devpath(libzfs_handle_t *, const char *); 746069f55e2SEric Schrock extern boolean_t libzfs_fru_compare(libzfs_handle_t *, const char *, 747069f55e2SEric Schrock const char *); 748069f55e2SEric Schrock extern boolean_t libzfs_fru_notself(libzfs_handle_t *, const char *); 749069f55e2SEric Schrock extern int zpool_fru_set(zpool_handle_t *, uint64_t, const char *); 750069f55e2SEric Schrock 751fa9e4066Sahrens #ifdef __cplusplus 752fa9e4066Sahrens } 753fa9e4066Sahrens #endif 754fa9e4066Sahrens 755fa9e4066Sahrens #endif /* _LIBZFS_H */ 756