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