xref: /titanic_44/usr/src/lib/libzfs/common/libzfs_impl.h (revision 9df12a23948bd40cbe37ce88d84e272c3894e675)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_LIBFS_IMPL_H
27 #define	_LIBFS_IMPL_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/dmu.h>
32 #include <sys/fs/zfs.h>
33 #include <sys/zfs_ioctl.h>
34 #include <sys/zfs_acl.h>
35 #include <sys/nvpair.h>
36 
37 #include <libzfs.h>
38 
39 #ifdef	__cplusplus
40 extern "C" {
41 #endif
42 
43 struct zfs_handle {
44 	char zfs_name[ZFS_MAXNAMELEN];
45 	zfs_type_t zfs_type;
46 	dmu_objset_stats_t zfs_dmustats;
47 	nvlist_t *zfs_props;
48 	uint64_t zfs_volsize;
49 	uint64_t zfs_volblocksize;
50 	char *zfs_mntopts;
51 	char zfs_root[MAXPATHLEN];
52 };
53 
54 struct zpool_handle {
55 	char zpool_name[ZPOOL_MAXNAMELEN];
56 	int zpool_state;
57 	size_t zpool_config_size;
58 	nvlist_t *zpool_config;
59 	nvlist_t *zpool_old_config;
60 	nvlist_t **zpool_error_log;
61 	size_t zpool_error_count;
62 };
63 
64 void zfs_error(const char *, ...);
65 void zfs_fatal(const char *, ...);
66 void *zfs_malloc(size_t);
67 char *zfs_strdup(const char *);
68 void no_memory(void);
69 
70 #define	zfs_baderror(err)						\
71 	(zfs_fatal(dgettext(TEXT_DOMAIN,				\
72 	"internal error: unexpected error %d at line %d of %s"),	\
73 	(err), (__LINE__), (__FILE__)))
74 
75 char **get_dependents(const char *, size_t *);
76 
77 typedef struct prop_changelist prop_changelist_t;
78 
79 int changelist_prefix(prop_changelist_t *);
80 int changelist_postfix(prop_changelist_t *);
81 void changelist_rename(prop_changelist_t *, const char *, const char *);
82 void changelist_remove(zfs_handle_t *, prop_changelist_t *);
83 void changelist_free(prop_changelist_t *);
84 prop_changelist_t *changelist_gather(zfs_handle_t *, zfs_prop_t, int);
85 int changelist_unshare(prop_changelist_t *);
86 int changelist_haszonedchild(prop_changelist_t *);
87 
88 void remove_mountpoint(zfs_handle_t *);
89 
90 zfs_handle_t *make_dataset_handle(const char *);
91 void set_pool_health(nvlist_t *);
92 
93 zpool_handle_t *zpool_open_silent(const char *);
94 
95 int zvol_create_link(const char *);
96 int zvol_remove_link(const char *);
97 
98 int zfs_ioctl(int, zfs_cmd_t *);
99 FILE *zfs_mnttab(void);
100 FILE *zfs_sharetab(void);
101 
102 #ifdef	__cplusplus
103 }
104 #endif
105 
106 #endif	/* _LIBFS_IMPL_H */
107