libzfs_impl.h revision b1b8ab34de515a5e83206da22c3d7e563241b021
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER START
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The contents of this file are subject to the terms of the
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * Common Development and Distribution License (the "License").
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * You may not use this file except in compliance with the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fa9e4066f08beec538e775443c5be79dd423fcabahrens * or http://www.opensolaris.org/os/licensing.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * See the License for the specific language governing permissions
fa9e4066f08beec538e775443c5be79dd423fcabahrens * and limitations under the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * When distributing Covered Code, include this CDDL HEADER in each
fa9e4066f08beec538e775443c5be79dd423fcabahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If applicable, add the following below this CDDL HEADER, with the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * fields enclosed by brackets "[]" replaced with your own identifying
fa9e4066f08beec538e775443c5be79dd423fcabahrens * information: Portions Copyright [yyyy] [name of copyright owner]
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER END
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
f3861e1a2ceec23a5b699c24d814b7775a9e0b52ahl
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
55434c770c89aa1b84474f2559a106803511aba0ek * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Use is subject to license terms.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#ifndef _LIBFS_IMPL_H
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define _LIBFS_IMPL_H
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#pragma ident "%Z%%M% %I% %E% SMI"
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include <sys/dmu.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include <sys/fs/zfs.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include <sys/zfs_ioctl.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include <sys/zfs_acl.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include <sys/nvpair.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens
99653d4ee642c6528e88224f12409a5f23060994eschrock#include <libuutil.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include <libzfs.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#ifdef __cplusplus
fa9e4066f08beec538e775443c5be79dd423fcabahrensextern "C" {
fa9e4066f08beec538e775443c5be79dd423fcabahrens#endif
fa9e4066f08beec538e775443c5be79dd423fcabahrens
99653d4ee642c6528e88224f12409a5f23060994eschrockstruct libzfs_handle {
99653d4ee642c6528e88224f12409a5f23060994eschrock int libzfs_error;
99653d4ee642c6528e88224f12409a5f23060994eschrock int libzfs_fd;
99653d4ee642c6528e88224f12409a5f23060994eschrock FILE *libzfs_mnttab;
99653d4ee642c6528e88224f12409a5f23060994eschrock FILE *libzfs_sharetab;
99653d4ee642c6528e88224f12409a5f23060994eschrock uu_avl_pool_t *libzfs_ns_avlpool;
99653d4ee642c6528e88224f12409a5f23060994eschrock uu_avl_t *libzfs_ns_avl;
99653d4ee642c6528e88224f12409a5f23060994eschrock uint64_t libzfs_ns_gen;
99653d4ee642c6528e88224f12409a5f23060994eschrock int libzfs_desc_active;
99653d4ee642c6528e88224f12409a5f23060994eschrock char libzfs_action[1024];
99653d4ee642c6528e88224f12409a5f23060994eschrock char libzfs_desc[1024];
99653d4ee642c6528e88224f12409a5f23060994eschrock int libzfs_printerr;
99653d4ee642c6528e88224f12409a5f23060994eschrock};
99653d4ee642c6528e88224f12409a5f23060994eschrock
fa9e4066f08beec538e775443c5be79dd423fcabahrensstruct zfs_handle {
99653d4ee642c6528e88224f12409a5f23060994eschrock libzfs_handle_t *zfs_hdl;
fa9e4066f08beec538e775443c5be79dd423fcabahrens char zfs_name[ZFS_MAXNAMELEN];
a2eea2e101e6a163a537dcc6d4e3c4da2a0ea5b2ahrens zfs_type_t zfs_type; /* type including snapshot */
a2eea2e101e6a163a537dcc6d4e3c4da2a0ea5b2ahrens zfs_type_t zfs_head_type; /* type excluding snapshot */
fa9e4066f08beec538e775443c5be79dd423fcabahrens dmu_objset_stats_t zfs_dmustats;
7f7322febbcfe774b7270abc3b191c094bfcc517eschrock nvlist_t *zfs_props;
e9dbad6f263d5570ed7ff5443ec5b958af8c24d7eschrock nvlist_t *zfs_user_props;
3bb79bece53191f2cf27aa61a72ea1784a7ce700eschrock boolean_t zfs_mntcheck;
fa9e4066f08beec538e775443c5be79dd423fcabahrens char *zfs_mntopts;
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock char zfs_root[MAXPATHLEN];
fa9e4066f08beec538e775443c5be79dd423fcabahrens};
fa9e4066f08beec538e775443c5be79dd423fcabahrens
e9dbad6f263d5570ed7ff5443ec5b958af8c24d7eschrock/*
e9dbad6f263d5570ed7ff5443ec5b958af8c24d7eschrock * This is different from checking zfs_type, because it will also catch
e9dbad6f263d5570ed7ff5443ec5b958af8c24d7eschrock * snapshots of volumes.
e9dbad6f263d5570ed7ff5443ec5b958af8c24d7eschrock */
a2eea2e101e6a163a537dcc6d4e3c4da2a0ea5b2ahrens#define ZFS_IS_VOLUME(zhp) ((zhp)->zfs_head_type == ZFS_TYPE_VOLUME)
e9dbad6f263d5570ed7ff5443ec5b958af8c24d7eschrock
fa9e4066f08beec538e775443c5be79dd423fcabahrensstruct zpool_handle {
99653d4ee642c6528e88224f12409a5f23060994eschrock libzfs_handle_t *zpool_hdl;
fa9e4066f08beec538e775443c5be79dd423fcabahrens char zpool_name[ZPOOL_MAXNAMELEN];
fa9e4066f08beec538e775443c5be79dd423fcabahrens int zpool_state;
fa9e4066f08beec538e775443c5be79dd423fcabahrens size_t zpool_config_size;
fa9e4066f08beec538e775443c5be79dd423fcabahrens nvlist_t *zpool_config;
088e9d477eee66081e407fbc5a33c4da25f66f6aeschrock nvlist_t *zpool_old_config;
b1b8ab34de515a5e83206da22c3d7e563241b021lling nvlist_t *zpool_props;
fa9e4066f08beec538e775443c5be79dd423fcabahrens};
fa9e4066f08beec538e775443c5be79dd423fcabahrens
ece3d9b3bacef51a5f34d993935eedbb7bb87059llingint zfs_error(libzfs_handle_t *, int, const char *);
ece3d9b3bacef51a5f34d993935eedbb7bb87059llingint zfs_error_fmt(libzfs_handle_t *, int, const char *, ...);
99653d4ee642c6528e88224f12409a5f23060994eschrockvoid zfs_error_aux(libzfs_handle_t *, const char *, ...);
99653d4ee642c6528e88224f12409a5f23060994eschrockvoid *zfs_alloc(libzfs_handle_t *, size_t);
e9dbad6f263d5570ed7ff5443ec5b958af8c24d7eschrockvoid *zfs_realloc(libzfs_handle_t *, void *, size_t, size_t);
99653d4ee642c6528e88224f12409a5f23060994eschrockchar *zfs_strdup(libzfs_handle_t *, const char *);
99653d4ee642c6528e88224f12409a5f23060994eschrockint no_memory(libzfs_handle_t *);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
ece3d9b3bacef51a5f34d993935eedbb7bb87059llingint zfs_standard_error(libzfs_handle_t *, int, const char *);
ece3d9b3bacef51a5f34d993935eedbb7bb87059llingint zfs_standard_error_fmt(libzfs_handle_t *, int, const char *, ...);
ece3d9b3bacef51a5f34d993935eedbb7bb87059llingint zpool_standard_error(libzfs_handle_t *, int, const char *);
ece3d9b3bacef51a5f34d993935eedbb7bb87059llingint zpool_standard_error_fmt(libzfs_handle_t *, int, const char *, ...);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
3bb79bece53191f2cf27aa61a72ea1784a7ce700eschrockint get_dependents(libzfs_handle_t *, boolean_t, const char *, char ***,
3bb79bece53191f2cf27aa61a72ea1784a7ce700eschrock size_t *);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
b1b8ab34de515a5e83206da22c3d7e563241b021llingint zfs_expand_proplist_common(libzfs_handle_t *, zfs_proplist_t **,
b1b8ab34de515a5e83206da22c3d7e563241b021lling zfs_type_t);
b1b8ab34de515a5e83206da22c3d7e563241b021llingint zfs_get_proplist_common(libzfs_handle_t *, char *, zfs_proplist_t **,
b1b8ab34de515a5e83206da22c3d7e563241b021lling zfs_type_t);
b1b8ab34de515a5e83206da22c3d7e563241b021llingzfs_prop_t zfs_prop_iter_common(zfs_prop_f, void *, zfs_type_t, boolean_t);
b1b8ab34de515a5e83206da22c3d7e563241b021llingzfs_prop_t zfs_name_to_prop_common(const char *, zfs_type_t);
b1b8ab34de515a5e83206da22c3d7e563241b021lling
b1b8ab34de515a5e83206da22c3d7e563241b021llingnvlist_t *zfs_validate_properties(libzfs_handle_t *, zfs_type_t, char *,
b1b8ab34de515a5e83206da22c3d7e563241b021lling nvlist_t *, uint64_t, zfs_handle_t *zhp, const char *errbuf);
b1b8ab34de515a5e83206da22c3d7e563241b021lling
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef struct prop_changelist prop_changelist_t;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
e9dbad6f263d5570ed7ff5443ec5b958af8c24d7eschrockint zcmd_alloc_dst_nvlist(libzfs_handle_t *, zfs_cmd_t *, size_t);
e9dbad6f263d5570ed7ff5443ec5b958af8c24d7eschrockint zcmd_write_src_nvlist(libzfs_handle_t *, zfs_cmd_t *, nvlist_t *, size_t *);
e9dbad6f263d5570ed7ff5443ec5b958af8c24d7eschrockint zcmd_expand_dst_nvlist(libzfs_handle_t *, zfs_cmd_t *);
e9dbad6f263d5570ed7ff5443ec5b958af8c24d7eschrockint zcmd_read_dst_nvlist(libzfs_handle_t *, zfs_cmd_t *, nvlist_t **);
e9dbad6f263d5570ed7ff5443ec5b958af8c24d7eschrockvoid zcmd_free_nvlists(zfs_cmd_t *);
e9dbad6f263d5570ed7ff5443ec5b958af8c24d7eschrock
fa9e4066f08beec538e775443c5be79dd423fcabahrensint changelist_prefix(prop_changelist_t *);
fa9e4066f08beec538e775443c5be79dd423fcabahrensint changelist_postfix(prop_changelist_t *);
fa9e4066f08beec538e775443c5be79dd423fcabahrensvoid changelist_rename(prop_changelist_t *, const char *, const char *);
b12a1c38fc215cc54fa6014069fd2b8dbb496646llingvoid changelist_remove(zfs_handle_t *, prop_changelist_t *);
fa9e4066f08beec538e775443c5be79dd423fcabahrensvoid changelist_free(prop_changelist_t *);
fa9e4066f08beec538e775443c5be79dd423fcabahrensprop_changelist_t *changelist_gather(zfs_handle_t *, zfs_prop_t, int);
fa9e4066f08beec538e775443c5be79dd423fcabahrensint changelist_unshare(prop_changelist_t *);
fa9e4066f08beec538e775443c5be79dd423fcabahrensint changelist_haszonedchild(prop_changelist_t *);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrensvoid remove_mountpoint(zfs_handle_t *);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
99653d4ee642c6528e88224f12409a5f23060994eschrockzfs_handle_t *make_dataset_handle(libzfs_handle_t *, const char *);
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock
94de1d4cf6ec0a3bf040dcc4b8df107c4ed36b51eschrockint zpool_open_silent(libzfs_handle_t *, const char *, zpool_handle_t **);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
99653d4ee642c6528e88224f12409a5f23060994eschrockint zvol_create_link(libzfs_handle_t *, const char *);
99653d4ee642c6528e88224f12409a5f23060994eschrockint zvol_remove_link(libzfs_handle_t *, const char *);
f3861e1a2ceec23a5b699c24d814b7775a9e0b52ahlint zpool_iter_zvol(zpool_handle_t *, int (*)(const char *, void *), void *);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
99653d4ee642c6528e88224f12409a5f23060994eschrockvoid namespace_clear(libzfs_handle_t *);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#ifdef __cplusplus
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens#endif
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#endif /* _LIBFS_IMPL_H */