xref: /freebsd/sys/contrib/openzfs/include/libzfs_core.h (revision 3332f1b444d4a73238e9f59cca27bfc95fe936bd)
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 /*
23  * Copyright (c) 2012, 2020 by Delphix. All rights reserved.
24  * Copyright (c) 2017 Datto Inc.
25  * Copyright 2017 RackTop Systems.
26  * Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
27  */
28 
29 #ifndef	_LIBZFS_CORE_H
30 #define	_LIBZFS_CORE_H extern __attribute__((visibility("default")))
31 
32 #include <libnvpair.h>
33 #include <sys/param.h>
34 #include <sys/types.h>
35 #include <sys/fs/zfs.h>
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 _LIBZFS_CORE_H int libzfs_core_init(void);
42 _LIBZFS_CORE_H void libzfs_core_fini(void);
43 
44 struct zfs_cmd;
45 _LIBZFS_CORE_H int lzc_ioctl_fd(int, unsigned long, struct zfs_cmd *);
46 
47 /*
48  * NB: this type should be kept binary-compatible with dmu_objset_type_t.
49  */
50 enum lzc_dataset_type {
51 	LZC_DATSET_TYPE_ZFS = 2,
52 	LZC_DATSET_TYPE_ZVOL
53 };
54 
55 _LIBZFS_CORE_H int lzc_snapshot(nvlist_t *, nvlist_t *, nvlist_t **);
56 _LIBZFS_CORE_H int lzc_create(const char *, enum lzc_dataset_type, nvlist_t *,
57     uint8_t *, uint_t);
58 _LIBZFS_CORE_H int lzc_clone(const char *, const char *, nvlist_t *);
59 _LIBZFS_CORE_H int lzc_promote(const char *, char *, int);
60 _LIBZFS_CORE_H int lzc_destroy_snaps(nvlist_t *, boolean_t, nvlist_t **);
61 _LIBZFS_CORE_H int lzc_bookmark(nvlist_t *, nvlist_t **);
62 _LIBZFS_CORE_H int lzc_get_bookmarks(const char *, nvlist_t *, nvlist_t **);
63 _LIBZFS_CORE_H int lzc_get_bookmark_props(const char *, nvlist_t **);
64 _LIBZFS_CORE_H int lzc_destroy_bookmarks(nvlist_t *, nvlist_t **);
65 _LIBZFS_CORE_H int lzc_load_key(const char *, boolean_t, uint8_t *, uint_t);
66 _LIBZFS_CORE_H int lzc_unload_key(const char *);
67 _LIBZFS_CORE_H int lzc_change_key(const char *, uint64_t, nvlist_t *, uint8_t *,
68     uint_t);
69 _LIBZFS_CORE_H int lzc_initialize(const char *, pool_initialize_func_t,
70     nvlist_t *, nvlist_t **);
71 _LIBZFS_CORE_H int lzc_trim(const char *, pool_trim_func_t, uint64_t, boolean_t,
72     nvlist_t *, nvlist_t **);
73 _LIBZFS_CORE_H int lzc_redact(const char *, const char *, nvlist_t *);
74 
75 _LIBZFS_CORE_H int lzc_snaprange_space(const char *, const char *, uint64_t *);
76 
77 _LIBZFS_CORE_H int lzc_hold(nvlist_t *, int, nvlist_t **);
78 _LIBZFS_CORE_H int lzc_release(nvlist_t *, nvlist_t **);
79 _LIBZFS_CORE_H int lzc_get_holds(const char *, nvlist_t **);
80 
81 enum lzc_send_flags {
82 	LZC_SEND_FLAG_EMBED_DATA = 1 << 0,
83 	LZC_SEND_FLAG_LARGE_BLOCK = 1 << 1,
84 	LZC_SEND_FLAG_COMPRESS = 1 << 2,
85 	LZC_SEND_FLAG_RAW = 1 << 3,
86 	LZC_SEND_FLAG_SAVED = 1 << 4,
87 };
88 
89 _LIBZFS_CORE_H int lzc_send(const char *, const char *, int,
90     enum lzc_send_flags);
91 _LIBZFS_CORE_H int lzc_send_resume(const char *, const char *, int,
92     enum lzc_send_flags, uint64_t, uint64_t);
93 _LIBZFS_CORE_H int lzc_send_space(const char *, const char *,
94     enum lzc_send_flags, uint64_t *);
95 
96 struct dmu_replay_record;
97 
98 _LIBZFS_CORE_H int lzc_send_redacted(const char *, const char *, int,
99     enum lzc_send_flags, const char *);
100 _LIBZFS_CORE_H int lzc_send_resume_redacted(const char *, const char *, int,
101     enum lzc_send_flags, uint64_t, uint64_t, const char *);
102 _LIBZFS_CORE_H int lzc_receive(const char *, nvlist_t *, const char *,
103     boolean_t, boolean_t, int);
104 _LIBZFS_CORE_H int lzc_receive_resumable(const char *, nvlist_t *, const char *,
105     boolean_t, boolean_t, int);
106 _LIBZFS_CORE_H int lzc_receive_with_header(const char *, nvlist_t *,
107     const char *, boolean_t, boolean_t, boolean_t, int,
108     const struct dmu_replay_record *);
109 _LIBZFS_CORE_H int lzc_receive_one(const char *, nvlist_t *, const char *,
110     boolean_t, boolean_t, boolean_t, int, const struct dmu_replay_record *, int,
111     uint64_t *, uint64_t *, uint64_t *, nvlist_t **);
112 _LIBZFS_CORE_H int lzc_receive_with_cmdprops(const char *, nvlist_t *,
113     nvlist_t *, uint8_t *, uint_t, const char *, boolean_t, boolean_t,
114     boolean_t, int, const struct dmu_replay_record *, int, uint64_t *,
115     uint64_t *, uint64_t *, nvlist_t **);
116 _LIBZFS_CORE_H int lzc_send_space(const char *, const char *,
117     enum lzc_send_flags, uint64_t *);
118 _LIBZFS_CORE_H int lzc_send_space_resume_redacted(const char *, const char *,
119     enum lzc_send_flags, uint64_t, uint64_t, uint64_t, const char *,
120     int, uint64_t *);
121 _LIBZFS_CORE_H uint64_t lzc_send_progress(int);
122 
123 _LIBZFS_CORE_H boolean_t lzc_exists(const char *);
124 
125 _LIBZFS_CORE_H int lzc_rollback(const char *, char *, int);
126 _LIBZFS_CORE_H int lzc_rollback_to(const char *, const char *);
127 
128 _LIBZFS_CORE_H int lzc_rename(const char *, const char *);
129 _LIBZFS_CORE_H int lzc_destroy(const char *);
130 
131 _LIBZFS_CORE_H int lzc_channel_program(const char *, const char *, uint64_t,
132     uint64_t, nvlist_t *, nvlist_t **);
133 _LIBZFS_CORE_H int lzc_channel_program_nosync(const char *, const char *,
134     uint64_t, uint64_t, nvlist_t *, nvlist_t **);
135 
136 _LIBZFS_CORE_H int lzc_sync(const char *, nvlist_t *, nvlist_t **);
137 _LIBZFS_CORE_H int lzc_reopen(const char *, boolean_t);
138 
139 _LIBZFS_CORE_H int lzc_pool_checkpoint(const char *);
140 _LIBZFS_CORE_H int lzc_pool_checkpoint_discard(const char *);
141 
142 _LIBZFS_CORE_H int lzc_wait(const char *, zpool_wait_activity_t, boolean_t *);
143 _LIBZFS_CORE_H int lzc_wait_tag(const char *, zpool_wait_activity_t, uint64_t,
144     boolean_t *);
145 _LIBZFS_CORE_H int lzc_wait_fs(const char *, zfs_wait_activity_t, boolean_t *);
146 
147 _LIBZFS_CORE_H int lzc_set_bootenv(const char *, const nvlist_t *);
148 _LIBZFS_CORE_H int lzc_get_bootenv(const char *, nvlist_t **);
149 #ifdef	__cplusplus
150 }
151 #endif
152 
153 #endif	/* _LIBZFS_CORE_H */
154