xref: /freebsd/sys/contrib/openzfs/include/libzfs_core.h (revision 61145dc2b94f12f6a47344fb9aac702321880e43)
1 // SPDX-License-Identifier: CDDL-1.0
2 /*
3  * CDDL HEADER START
4  *
5  * The contents of this file are subject to the terms of the
6  * Common Development and Distribution License (the "License").
7  * You may not use this file except in compliance with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or https://opensource.org/licenses/CDDL-1.0.
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 /*
24  * Copyright (c) 2012, 2020 by Delphix. All rights reserved.
25  * Copyright 2017 RackTop Systems.
26  * Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
27  * Copyright (c) 2019 Datto Inc.
28  */
29 
30 #ifndef	_LIBZFS_CORE_H
31 #define	_LIBZFS_CORE_H extern __attribute__((visibility("default")))
32 
33 #include <libnvpair.h>
34 #include <sys/param.h>
35 #include <sys/types.h>
36 #include <sys/fs/zfs.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 _LIBZFS_CORE_H int libzfs_core_init(void);
43 _LIBZFS_CORE_H void libzfs_core_fini(void);
44 
45 struct zfs_cmd;
46 _LIBZFS_CORE_H int lzc_ioctl_fd(int, unsigned long, struct zfs_cmd *);
47 
48 /*
49  * NB: this type should be kept binary-compatible with dmu_objset_type_t.
50  */
51 enum lzc_dataset_type {
52 	LZC_DATSET_TYPE_ZFS = 2,
53 	LZC_DATSET_TYPE_ZVOL
54 };
55 
56 _LIBZFS_CORE_H int lzc_snapshot(nvlist_t *, nvlist_t *, nvlist_t **);
57 _LIBZFS_CORE_H int lzc_create(const char *, enum lzc_dataset_type, nvlist_t *,
58     uint8_t *, uint_t);
59 _LIBZFS_CORE_H int lzc_clone(const char *, const char *, nvlist_t *);
60 _LIBZFS_CORE_H int lzc_promote(const char *, char *, int);
61 _LIBZFS_CORE_H int lzc_destroy_snaps(nvlist_t *, boolean_t, nvlist_t **);
62 _LIBZFS_CORE_H int lzc_bookmark(nvlist_t *, nvlist_t **);
63 _LIBZFS_CORE_H int lzc_get_bookmarks(const char *, nvlist_t *, nvlist_t **);
64 _LIBZFS_CORE_H int lzc_get_bookmark_props(const char *, nvlist_t **);
65 _LIBZFS_CORE_H int lzc_destroy_bookmarks(nvlist_t *, nvlist_t **);
66 _LIBZFS_CORE_H int lzc_load_key(const char *, boolean_t, uint8_t *, uint_t);
67 _LIBZFS_CORE_H int lzc_unload_key(const char *);
68 _LIBZFS_CORE_H int lzc_change_key(const char *, uint64_t, nvlist_t *, uint8_t *,
69     uint_t);
70 _LIBZFS_CORE_H int lzc_initialize(const char *, pool_initialize_func_t,
71     nvlist_t *, nvlist_t **);
72 _LIBZFS_CORE_H int lzc_trim(const char *, pool_trim_func_t, uint64_t, boolean_t,
73     nvlist_t *, nvlist_t **);
74 _LIBZFS_CORE_H int lzc_redact(const char *, const char *, nvlist_t *);
75 
76 _LIBZFS_CORE_H int lzc_snaprange_space(const char *, const char *, uint64_t *);
77 
78 _LIBZFS_CORE_H int lzc_hold(nvlist_t *, int, nvlist_t **);
79 _LIBZFS_CORE_H int lzc_release(nvlist_t *, nvlist_t **);
80 _LIBZFS_CORE_H int lzc_get_holds(const char *, nvlist_t **);
81 _LIBZFS_CORE_H int lzc_get_props(const char *, nvlist_t **);
82 
83 enum lzc_send_flags {
84 	LZC_SEND_FLAG_EMBED_DATA = 1 << 0,
85 	LZC_SEND_FLAG_LARGE_BLOCK = 1 << 1,
86 	LZC_SEND_FLAG_COMPRESS = 1 << 2,
87 	LZC_SEND_FLAG_RAW = 1 << 3,
88 	LZC_SEND_FLAG_SAVED = 1 << 4,
89 };
90 
91 _LIBZFS_CORE_H int lzc_send_wrapper(int (*)(int, void *), int, void *);
92 _LIBZFS_CORE_H int lzc_send(const char *, const char *, int,
93     enum lzc_send_flags);
94 _LIBZFS_CORE_H int lzc_send_resume(const char *, const char *, int,
95     enum lzc_send_flags, uint64_t, uint64_t);
96 _LIBZFS_CORE_H int lzc_send_space(const char *, const char *,
97     enum lzc_send_flags, uint64_t *);
98 
99 struct dmu_replay_record;
100 
101 _LIBZFS_CORE_H int lzc_send_redacted(const char *, const char *, int,
102     enum lzc_send_flags, const char *);
103 _LIBZFS_CORE_H int lzc_send_resume_redacted(const char *, const char *, int,
104     enum lzc_send_flags, uint64_t, uint64_t, const char *);
105 _LIBZFS_CORE_H int lzc_receive(const char *, nvlist_t *, const char *,
106     boolean_t, boolean_t, int);
107 _LIBZFS_CORE_H int lzc_receive_resumable(const char *, nvlist_t *, const char *,
108     boolean_t, boolean_t, int);
109 _LIBZFS_CORE_H int lzc_receive_with_header(const char *, nvlist_t *,
110     const char *, boolean_t, boolean_t, boolean_t, int,
111     const struct dmu_replay_record *);
112 _LIBZFS_CORE_H int lzc_receive_one(const char *, nvlist_t *, const char *,
113     boolean_t, boolean_t, boolean_t, int, const struct dmu_replay_record *, int,
114     uint64_t *, uint64_t *, uint64_t *, nvlist_t **);
115 _LIBZFS_CORE_H int lzc_receive_with_cmdprops(const char *, nvlist_t *,
116     nvlist_t *, uint8_t *, uint_t, const char *, boolean_t, boolean_t,
117     boolean_t, int, const struct dmu_replay_record *, int, uint64_t *,
118     uint64_t *, uint64_t *, nvlist_t **);
119 _LIBZFS_CORE_H int lzc_receive_with_heal(const char *, nvlist_t *, nvlist_t *,
120     uint8_t *, uint_t, const char *, boolean_t, boolean_t, boolean_t, boolean_t,
121     int, const struct dmu_replay_record *, int, uint64_t *, uint64_t *,
122     uint64_t *, nvlist_t **);
123 _LIBZFS_CORE_H int lzc_send_space(const char *, const char *,
124     enum lzc_send_flags, uint64_t *);
125 _LIBZFS_CORE_H int lzc_send_space_resume_redacted(const char *, const char *,
126     enum lzc_send_flags, uint64_t, uint64_t, uint64_t, const char *,
127     int, uint64_t *);
128 _LIBZFS_CORE_H uint64_t lzc_send_progress(int);
129 
130 _LIBZFS_CORE_H boolean_t lzc_exists(const char *);
131 
132 _LIBZFS_CORE_H int lzc_rollback(const char *, char *, int);
133 _LIBZFS_CORE_H int lzc_rollback_to(const char *, const char *);
134 
135 _LIBZFS_CORE_H int lzc_rename(const char *, const char *);
136 _LIBZFS_CORE_H int lzc_destroy(const char *);
137 
138 _LIBZFS_CORE_H int lzc_channel_program(const char *, const char *, uint64_t,
139     uint64_t, nvlist_t *, nvlist_t **);
140 _LIBZFS_CORE_H int lzc_channel_program_nosync(const char *, const char *,
141     uint64_t, uint64_t, nvlist_t *, nvlist_t **);
142 
143 _LIBZFS_CORE_H int lzc_sync(const char *, nvlist_t *, nvlist_t **);
144 _LIBZFS_CORE_H int lzc_reopen(const char *, boolean_t);
145 
146 _LIBZFS_CORE_H int lzc_pool_checkpoint(const char *);
147 _LIBZFS_CORE_H int lzc_pool_checkpoint_discard(const char *);
148 
149 _LIBZFS_CORE_H int lzc_wait(const char *, zpool_wait_activity_t, boolean_t *);
150 _LIBZFS_CORE_H int lzc_wait_tag(const char *, zpool_wait_activity_t, uint64_t,
151     boolean_t *);
152 
153 _LIBZFS_CORE_H int lzc_pool_prefetch(const char *, zpool_prefetch_type_t);
154 
155 _LIBZFS_CORE_H int lzc_wait_fs(const char *, zfs_wait_activity_t, boolean_t *);
156 
157 _LIBZFS_CORE_H int lzc_set_bootenv(const char *, const nvlist_t *);
158 _LIBZFS_CORE_H int lzc_get_bootenv(const char *, nvlist_t **);
159 
160 _LIBZFS_CORE_H int lzc_get_vdev_prop(const char *, nvlist_t *, nvlist_t **);
161 _LIBZFS_CORE_H int lzc_set_vdev_prop(const char *, nvlist_t *, nvlist_t **);
162 
163 _LIBZFS_CORE_H int lzc_scrub(zfs_ioc_t, const char *, nvlist_t *, nvlist_t **);
164 
165 _LIBZFS_CORE_H int lzc_ddt_prune(const char *, zpool_ddt_prune_unit_t,
166     uint64_t);
167 
168 #ifdef	__cplusplus
169 }
170 #endif
171 
172 #endif	/* _LIBZFS_CORE_H */
173