/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2011 Pawel Jakub Dawidek. All rights reserved.
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
* Copyright (c) 2014 Integros [integros.com]
* Copyright 2016 Nexenta Systems, Inc.
*/
#ifndef _LIBZFS_H
#define _LIBZFS_H
#include <assert.h>
#include <libnvpair.h>
#include <ucred.h>
#include <libzfs_core.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Miscellaneous ZFS constants
*/
/*
* libzfs errors
*/
typedef enum zfs_error {
} zfs_error_t;
/*
* The following data structures are all part
* of the zfs_allow_t data structure which is
* used for printing 'allow' permissions.
* It is a linked list of zfs_allow_t's which
* and each one of the entries in those trees have
* avl tree's for the permissions they belong to and
* whether they are local,descendent or local+descendent
* permissions. The AVL trees are used primarily for
* sorting purposes, but also so that we can quickly find
* a given user and or permission.
*/
typedef struct zfs_perm_node {
typedef struct zfs_allow_node {
typedef struct zfs_allow {
} zfs_allow_t;
/*
* Basic handle types
*/
/*
* Library initialization
*/
extern libzfs_handle_t *libzfs_init(void);
extern void libzfs_fini(libzfs_handle_t *);
extern void zfs_save_arguments(int argc, char **, char *, int);
extern int zpool_log_history(libzfs_handle_t *, const char *);
extern int libzfs_errno(libzfs_handle_t *);
extern const char *libzfs_error_action(libzfs_handle_t *);
extern const char *libzfs_error_description(libzfs_handle_t *);
extern int zfs_standard_error(libzfs_handle_t *, int, const char *);
extern void libzfs_mnttab_init(libzfs_handle_t *);
extern void libzfs_mnttab_fini(libzfs_handle_t *);
extern int libzfs_mnttab_find(libzfs_handle_t *, const char *,
struct mnttab *);
extern void libzfs_mnttab_add(libzfs_handle_t *, const char *,
const char *, const char *);
extern void libzfs_mnttab_remove(libzfs_handle_t *, const char *);
/*
* Basic handle functions
*/
extern void zpool_close(zpool_handle_t *);
extern const char *zpool_get_name(zpool_handle_t *);
extern int zpool_get_state(zpool_handle_t *);
extern const char *zpool_pool_state_to_name(pool_state_t);
extern void zpool_free_handles(libzfs_handle_t *);
/*
* Iterate over all active pools in the system.
*/
extern boolean_t zpool_skip_pool(const char *);
/*
* Functions to create and destroy pools
*/
extern int zpool_destroy(zpool_handle_t *, const char *);
typedef struct splitflags {
/* do not split, but return the config that would be split off */
/* after splitting, import the pool */
} splitflags_t;
/*
* Functions to manipulate pool and vdev state
*/
extern int zpool_reguid(zpool_handle_t *);
extern int zpool_reopen(zpool_handle_t *);
extern int zpool_vdev_online(zpool_handle_t *, const char *, int,
vdev_state_t *);
extern int zpool_vdev_attach(zpool_handle_t *, const char *,
const char *, nvlist_t *, int);
extern int zpool_vdev_detach(zpool_handle_t *, const char *);
extern int zpool_vdev_remove(zpool_handle_t *, const char *);
/*
* Functions to manage pool properties
*/
extern int zpool_set_prop(zpool_handle_t *, const char *, const char *);
zprop_source_t *);
extern const char *zpool_prop_to_name(zpool_prop_t);
extern const char *zpool_prop_values(zpool_prop_t);
/*
* Pool health statistics.
*/
typedef enum {
/*
* The following correspond to faults as defined in the (fault.fs.zfs.*)
* event namespace. Each is associated with a corresponding message ID.
*/
/*
* If the pool has unsupported features but can still be opened in
* read-only mode, its status is ZPOOL_STATUS_UNSUP_FEAT_WRITE. If the
* pool has unsupported features but cannot be opened at all, its
* status is ZPOOL_STATUS_UNSUP_FEAT_READ.
*/
/*
* These faults have no corresponding message ID. At the time we are
* checking the status, the original reason for the FMA fault (I/O or
* checksum errors) has been lost.
*/
/*
* The following are not faults per se, but still an error possibly
* requiring administrative attention. There is no corresponding
* message ID.
*/
/*
* Finally, the following indicates a healthy pool.
*/
/*
* Statistics and configuration functions.
*/
/*
* Import and export functions
*/
extern int zpool_export_force(zpool_handle_t *, const char *);
char *altroot);
nvlist_t *, int);
/*
* Search for pools to import
*/
typedef struct importargs {
} importargs_t;
/* legacy pool search routines */
char *, uint64_t);
/*
* Miscellaneous pool functions
*/
struct zfs_cmd;
extern const char *zfs_history_event_names[];
extern void zpool_explain_recover(libzfs_handle_t *, const char *, int,
nvlist_t *);
/*
* Basic handle manipulations. These functions do not create or destroy the
* underlying datasets, only the references to them.
*/
extern void zfs_close(zfs_handle_t *);
extern const char *zfs_get_name(const zfs_handle_t *);
extern const char *zfs_get_pool_name(const zfs_handle_t *);
/*
* Property management functions. Some functions are shared with the kernel,
*/
/*
* zfs dataset property management
*/
extern const char *zfs_prop_default_string(zfs_prop_t);
extern const char *zfs_prop_column_name(zfs_prop_t);
extern const char *zfs_prop_to_name(zfs_prop_t);
extern int zfs_prop_set(zfs_handle_t *, const char *, const char *);
zprop_source_t *, char *, size_t);
extern const char *zfs_prop_values(zfs_prop_t);
typedef struct zprop_list {
int pl_prop;
char *pl_user_prop;
} zprop_list_t;
/*
* zpool property management
*/
extern int zpool_prop_get_feature(zpool_handle_t *, const char *, char *,
size_t);
extern const char *zpool_prop_default_string(zpool_prop_t);
extern const char *zpool_prop_column_name(zpool_prop_t);
/*
* Functions shared by zfs and zpool property management.
*/
extern void zprop_free_list(zprop_list_t *);
typedef enum {
/*
* Functions for printing zfs or zpool properties
*/
typedef struct zprop_get_cbdata {
int cb_sources;
void zprop_print_one_property(const char *, zprop_get_cbdata_t *,
const char *, const char *, zprop_source_t, const char *,
const char *);
/*
* Iterator functions.
*/
typedef struct get_all_cb {
} get_all_cb_t;
int libzfs_dataset_cmp(const void *, const void *);
/*
* Functions to create and destroy datasets.
*/
nvlist_t *);
extern int zfs_create_ancestors(libzfs_handle_t *, const char *);
typedef struct sendflags {
/* print informational messages (ie, -v was specified) */
/* recursive send (ie, -R) */
/* for incrementals, do all intermediate snapshots */
/* if dataset is a clone, do incremental from its origin */
/* do deduplication */
/* send properties (ie, -p) */
/* do not send (no-op, ie. -n) */
/* parsable verbose output (ie. -P) */
/* show progress (ie. -v) */
/* large blocks (>128K) are permitted */
/* WRITE_EMBEDDED records of type DATA are permitted */
/* compressed WRITE records are permitted */
} sendflags_t;
extern int zfs_send(zfs_handle_t *, const char *, const char *,
const char *);
const char *token);
extern int zfs_promote(zfs_handle_t *);
extern int zfs_hold(zfs_handle_t *, const char *, const char *,
boolean_t, int);
zfs_userspace_cb_t, void *);
typedef struct recvflags {
/* print informational messages (ie, -v was specified) */
/* the destination is a prefix, not the exact fs (ie, -d) */
/*
* Only the tail of the sent snapshot path is appended to the
* destination to determine the received snapshot name (ie, -e).
*/
/* do not actually do the recv, just check if it would work (ie, -n) */
/* set "canmount=off" on all modified filesystems */
/*
* Mark the file systems as "resumable" and do not destroy them if the
* receive is interrupted
*/
/* byteswap flag is used internally; callers need not specify */
/* do not mount file systems as they are extracted (private) */
} recvflags_t;
recvflags_t *, int, avl_tree_t *);
typedef enum diff_flags {
} diff_flags_t;
extern int zfs_show_diffs(zfs_handle_t *, int, const char *, const char *,
int);
/*
* Miscellaneous functions.
*/
extern const char *zfs_type_to_name(zfs_type_t);
extern void zfs_refresh_properties(zfs_handle_t *);
extern int zfs_name_valid(const char *, zfs_type_t);
extern int zfs_spa_version(zfs_handle_t *, int *);
/*
* Mount support functions.
*/
extern int zfs_mount(zfs_handle_t *, const char *, int);
extern int zfs_unmount(zfs_handle_t *, const char *, int);
extern int zfs_unmountall(zfs_handle_t *, int);
/*
* Share support functions.
*/
extern int zfs_share(zfs_handle_t *);
extern int zfs_unshare(zfs_handle_t *);
/*
* Protocol-specific share support functions.
*/
extern int zfs_share_nfs(zfs_handle_t *);
extern int zfs_share_smb(zfs_handle_t *);
extern int zfs_shareall(zfs_handle_t *);
extern int zfs_unshare_nfs(zfs_handle_t *, const char *);
extern int zfs_unshare_smb(zfs_handle_t *, const char *);
extern int zfs_unshareall_nfs(zfs_handle_t *);
extern int zfs_unshareall_smb(zfs_handle_t *);
extern int zfs_unshareall_bypath(zfs_handle_t *, const char *);
extern int zfs_unshareall(zfs_handle_t *);
extern int zfs_deleg_share_nfs(libzfs_handle_t *, char *, char *, char *,
void *, void *, int, zfs_share_op_t);
/*
* When dealing with nvlists, verify() is extremely useful
*/
#ifdef NDEBUG
#else
#endif
/*
* Utility function to convert a number to a human-readable form.
*/
/*
* Given a device or file, determine if it is part of a pool.
*/
boolean_t *);
/*
* Label manipulation.
*/
extern int zpool_read_label(int, nvlist_t **);
extern int zpool_clear_label(int);
/* is this zvol valid for use as a dump device? */
extern int zvol_check_dump_config(char *);
/*
* Management interfaces for SMB ACL files
*/
int zfs_smb_acl_add(libzfs_handle_t *, char *, char *, char *);
int zfs_smb_acl_remove(libzfs_handle_t *, char *, char *, char *);
int zfs_smb_acl_purge(libzfs_handle_t *, char *, char *);
int zfs_smb_acl_rename(libzfs_handle_t *, char *, char *, char *, char *);
/*
* Enable and disable datasets within a pool by mounting/unmounting and
*/
extern int zpool_enable_datasets(zpool_handle_t *, const char *, int);
/*
* Mappings between vdev and FRU.
*/
extern void libzfs_fru_refresh(libzfs_handle_t *);
extern const char *libzfs_fru_lookup(libzfs_handle_t *, const char *);
extern const char *libzfs_fru_devpath(libzfs_handle_t *, const char *);
const char *);
#ifdef __cplusplus
}
#endif
#endif /* _LIBZFS_H */