]>
Commit | Line | Data |
---|---|---|
34dc7c2f BB |
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 | /* | |
572e2857 | 22 | * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
6f1ffb06 | 23 | * Copyright (c) 2012 by Delphix. All rights reserved. |
34dc7c2f BB |
24 | */ |
25 | ||
26 | #ifndef _SYS_ZFS_IOCTL_H | |
27 | #define _SYS_ZFS_IOCTL_H | |
28 | ||
34dc7c2f BB |
29 | #include <sys/cred.h> |
30 | #include <sys/dmu.h> | |
31 | #include <sys/zio.h> | |
32 | #include <sys/dsl_deleg.h> | |
428870ff | 33 | #include <sys/spa.h> |
572e2857 | 34 | #include <sys/zfs_stat.h> |
34dc7c2f BB |
35 | |
36 | #ifdef _KERNEL | |
37 | #include <sys/nvpair.h> | |
38 | #endif /* _KERNEL */ | |
39 | ||
40 | #ifdef __cplusplus | |
41 | extern "C" { | |
42 | #endif | |
43 | ||
6f1ffb06 MA |
44 | /* |
45 | * The structures in this file are passed between userland and the | |
46 | * kernel. Userland may be running a 32-bit process, while the kernel | |
47 | * is 64-bit. Therefore, these structures need to compile the same in | |
48 | * 32-bit and 64-bit. This means not using type "long", and adding | |
49 | * explicit padding so that the 32-bit structure will not be packed more | |
50 | * tightly than the 64-bit structure (which requires 64-bit alignment). | |
51 | */ | |
52 | ||
34dc7c2f BB |
53 | /* |
54 | * Property values for snapdir | |
55 | */ | |
56 | #define ZFS_SNAPDIR_HIDDEN 0 | |
57 | #define ZFS_SNAPDIR_VISIBLE 1 | |
58 | ||
0b4d1b58 ED |
59 | /* |
60 | * Property values for snapdev | |
61 | */ | |
62 | #define ZFS_SNAPDEV_HIDDEN 0 | |
63 | #define ZFS_SNAPDEV_VISIBLE 1 | |
64 | ||
428870ff BB |
65 | /* |
66 | * Field manipulation macros for the drr_versioninfo field of the | |
67 | * send stream header. | |
68 | */ | |
69 | ||
70 | /* | |
71 | * Header types for zfs send streams. | |
72 | */ | |
73 | typedef enum drr_headertype { | |
74 | DMU_SUBSTREAM = 0x1, | |
75 | DMU_COMPOUNDSTREAM = 0x2 | |
76 | } drr_headertype_t; | |
77 | ||
78 | #define DMU_GET_STREAM_HDRTYPE(vi) BF64_GET((vi), 0, 2) | |
79 | #define DMU_SET_STREAM_HDRTYPE(vi, x) BF64_SET((vi), 0, 2, x) | |
80 | ||
81 | #define DMU_GET_FEATUREFLAGS(vi) BF64_GET((vi), 2, 30) | |
82 | #define DMU_SET_FEATUREFLAGS(vi, x) BF64_SET((vi), 2, 30, x) | |
83 | ||
84 | /* | |
85 | * Feature flags for zfs send streams (flags in drr_versioninfo) | |
86 | */ | |
87 | ||
88 | #define DMU_BACKUP_FEATURE_DEDUP (0x1) | |
89 | #define DMU_BACKUP_FEATURE_DEDUPPROPS (0x2) | |
90 | #define DMU_BACKUP_FEATURE_SA_SPILL (0x4) | |
91 | ||
92 | /* | |
93 | * Mask of all supported backup features | |
94 | */ | |
95 | #define DMU_BACKUP_FEATURE_MASK (DMU_BACKUP_FEATURE_DEDUP | \ | |
96 | DMU_BACKUP_FEATURE_DEDUPPROPS | DMU_BACKUP_FEATURE_SA_SPILL) | |
97 | ||
98 | /* Are all features in the given flag word currently supported? */ | |
99 | #define DMU_STREAM_SUPPORTED(x) (!((x) & ~DMU_BACKUP_FEATURE_MASK)) | |
100 | ||
101 | /* | |
102 | * The drr_versioninfo field of the dmu_replay_record has the | |
103 | * following layout: | |
104 | * | |
105 | * 64 56 48 40 32 24 16 8 0 | |
106 | * +-------+-------+-------+-------+-------+-------+-------+-------+ | |
107 | * | reserved | feature-flags |C|S| | |
108 | * +-------+-------+-------+-------+-------+-------+-------+-------+ | |
109 | * | |
110 | * The low order two bits indicate the header type: SUBSTREAM (0x1) | |
111 | * or COMPOUNDSTREAM (0x2). Using two bits for this is historical: | |
112 | * this field used to be a version number, where the two version types | |
113 | * were 1 and 2. Using two bits for this allows earlier versions of | |
114 | * the code to be able to recognize send streams that don't use any | |
115 | * of the features indicated by feature flags. | |
116 | */ | |
117 | ||
34dc7c2f BB |
118 | #define DMU_BACKUP_MAGIC 0x2F5bacbacULL |
119 | ||
120 | #define DRR_FLAG_CLONE (1<<0) | |
121 | #define DRR_FLAG_CI_DATA (1<<1) | |
122 | ||
428870ff BB |
123 | /* |
124 | * flags in the drr_checksumflags field in the DRR_WRITE and | |
125 | * DRR_WRITE_BYREF blocks | |
126 | */ | |
127 | #define DRR_CHECKSUM_DEDUP (1<<0) | |
128 | ||
129 | #define DRR_IS_DEDUP_CAPABLE(flags) ((flags) & DRR_CHECKSUM_DEDUP) | |
130 | ||
34dc7c2f BB |
131 | /* |
132 | * zfs ioctl command structure | |
133 | */ | |
134 | typedef struct dmu_replay_record { | |
135 | enum { | |
136 | DRR_BEGIN, DRR_OBJECT, DRR_FREEOBJECTS, | |
428870ff BB |
137 | DRR_WRITE, DRR_FREE, DRR_END, DRR_WRITE_BYREF, |
138 | DRR_SPILL, DRR_NUMTYPES | |
34dc7c2f BB |
139 | } drr_type; |
140 | uint32_t drr_payloadlen; | |
141 | union { | |
142 | struct drr_begin { | |
143 | uint64_t drr_magic; | |
428870ff | 144 | uint64_t drr_versioninfo; /* was drr_version */ |
34dc7c2f BB |
145 | uint64_t drr_creation_time; |
146 | dmu_objset_type_t drr_type; | |
147 | uint32_t drr_flags; | |
148 | uint64_t drr_toguid; | |
149 | uint64_t drr_fromguid; | |
150 | char drr_toname[MAXNAMELEN]; | |
151 | } drr_begin; | |
152 | struct drr_end { | |
153 | zio_cksum_t drr_checksum; | |
428870ff | 154 | uint64_t drr_toguid; |
34dc7c2f BB |
155 | } drr_end; |
156 | struct drr_object { | |
157 | uint64_t drr_object; | |
158 | dmu_object_type_t drr_type; | |
159 | dmu_object_type_t drr_bonustype; | |
160 | uint32_t drr_blksz; | |
161 | uint32_t drr_bonuslen; | |
428870ff | 162 | uint8_t drr_checksumtype; |
34dc7c2f BB |
163 | uint8_t drr_compress; |
164 | uint8_t drr_pad[6]; | |
428870ff | 165 | uint64_t drr_toguid; |
34dc7c2f BB |
166 | /* bonus content follows */ |
167 | } drr_object; | |
168 | struct drr_freeobjects { | |
169 | uint64_t drr_firstobj; | |
170 | uint64_t drr_numobjs; | |
428870ff | 171 | uint64_t drr_toguid; |
34dc7c2f BB |
172 | } drr_freeobjects; |
173 | struct drr_write { | |
174 | uint64_t drr_object; | |
175 | dmu_object_type_t drr_type; | |
176 | uint32_t drr_pad; | |
177 | uint64_t drr_offset; | |
178 | uint64_t drr_length; | |
428870ff BB |
179 | uint64_t drr_toguid; |
180 | uint8_t drr_checksumtype; | |
181 | uint8_t drr_checksumflags; | |
182 | uint8_t drr_pad2[6]; | |
183 | ddt_key_t drr_key; /* deduplication key */ | |
34dc7c2f BB |
184 | /* content follows */ |
185 | } drr_write; | |
186 | struct drr_free { | |
187 | uint64_t drr_object; | |
188 | uint64_t drr_offset; | |
189 | uint64_t drr_length; | |
428870ff | 190 | uint64_t drr_toguid; |
34dc7c2f | 191 | } drr_free; |
428870ff BB |
192 | struct drr_write_byref { |
193 | /* where to put the data */ | |
194 | uint64_t drr_object; | |
195 | uint64_t drr_offset; | |
196 | uint64_t drr_length; | |
197 | uint64_t drr_toguid; | |
198 | /* where to find the prior copy of the data */ | |
199 | uint64_t drr_refguid; | |
200 | uint64_t drr_refobject; | |
201 | uint64_t drr_refoffset; | |
202 | /* properties of the data */ | |
203 | uint8_t drr_checksumtype; | |
204 | uint8_t drr_checksumflags; | |
205 | uint8_t drr_pad2[6]; | |
206 | ddt_key_t drr_key; /* deduplication key */ | |
207 | } drr_write_byref; | |
208 | struct drr_spill { | |
209 | uint64_t drr_object; | |
210 | uint64_t drr_length; | |
211 | uint64_t drr_toguid; | |
212 | uint64_t drr_pad[4]; /* needed for crypto */ | |
213 | /* spill data follows */ | |
214 | } drr_spill; | |
34dc7c2f BB |
215 | } drr_u; |
216 | } dmu_replay_record_t; | |
217 | ||
572e2857 BB |
218 | /* diff record range types */ |
219 | typedef enum diff_type { | |
220 | DDR_NONE = 0x1, | |
221 | DDR_INUSE = 0x2, | |
222 | DDR_FREE = 0x4 | |
223 | } diff_type_t; | |
224 | ||
225 | /* | |
226 | * The diff reports back ranges of free or in-use objects. | |
227 | */ | |
228 | typedef struct dmu_diff_record { | |
229 | uint64_t ddr_type; | |
230 | uint64_t ddr_first; | |
231 | uint64_t ddr_last; | |
232 | } dmu_diff_record_t; | |
233 | ||
34dc7c2f BB |
234 | typedef struct zinject_record { |
235 | uint64_t zi_objset; | |
236 | uint64_t zi_object; | |
237 | uint64_t zi_start; | |
238 | uint64_t zi_end; | |
239 | uint64_t zi_guid; | |
240 | uint32_t zi_level; | |
241 | uint32_t zi_error; | |
242 | uint64_t zi_type; | |
243 | uint32_t zi_freq; | |
9babb374 | 244 | uint32_t zi_failfast; |
428870ff BB |
245 | char zi_func[MAXNAMELEN]; |
246 | uint32_t zi_iotype; | |
247 | int32_t zi_duration; | |
248 | uint64_t zi_timer; | |
cc92e9d0 GW |
249 | uint32_t zi_cmd; |
250 | uint32_t zi_pad; | |
34dc7c2f BB |
251 | } zinject_record_t; |
252 | ||
253 | #define ZINJECT_NULL 0x1 | |
254 | #define ZINJECT_FLUSH_ARC 0x2 | |
255 | #define ZINJECT_UNLOAD_SPA 0x4 | |
256 | ||
26685276 BB |
257 | #define ZEVENT_NONBLOCK 0x1 |
258 | #define ZEVENT_SIZE 1024 | |
259 | ||
cc92e9d0 GW |
260 | typedef enum zinject_type { |
261 | ZINJECT_UNINITIALIZED, | |
262 | ZINJECT_DATA_FAULT, | |
263 | ZINJECT_DEVICE_FAULT, | |
264 | ZINJECT_LABEL_FAULT, | |
265 | ZINJECT_IGNORED_WRITES, | |
266 | ZINJECT_PANIC, | |
267 | ZINJECT_DELAY_IO, | |
268 | } zinject_type_t; | |
269 | ||
34dc7c2f BB |
270 | typedef struct zfs_share { |
271 | uint64_t z_exportdata; | |
272 | uint64_t z_sharedata; | |
273 | uint64_t z_sharetype; /* 0 = share, 1 = unshare */ | |
274 | uint64_t z_sharemax; /* max length of share string */ | |
275 | } zfs_share_t; | |
276 | ||
277 | /* | |
278 | * ZFS file systems may behave the usual, POSIX-compliant way, where | |
279 | * name lookups are case-sensitive. They may also be set up so that | |
280 | * all the name lookups are case-insensitive, or so that only some | |
281 | * lookups, the ones that set an FIGNORECASE flag, are case-insensitive. | |
282 | */ | |
283 | typedef enum zfs_case { | |
284 | ZFS_CASE_SENSITIVE, | |
285 | ZFS_CASE_INSENSITIVE, | |
286 | ZFS_CASE_MIXED | |
287 | } zfs_case_t; | |
288 | ||
289 | typedef struct zfs_cmd { | |
6f1ffb06 MA |
290 | char zc_name[MAXPATHLEN]; /* name of pool or dataset */ |
291 | uint64_t zc_nvlist_src; /* really (char *) */ | |
292 | uint64_t zc_nvlist_src_size; | |
293 | uint64_t zc_nvlist_dst; /* really (char *) */ | |
294 | uint64_t zc_nvlist_dst_size; | |
295 | boolean_t zc_nvlist_dst_filled; /* put an nvlist in dst? */ | |
296 | int zc_pad2; | |
297 | ||
298 | /* | |
299 | * The following members are for legacy ioctls which haven't been | |
300 | * converted to the new method. | |
301 | */ | |
302 | uint64_t zc_history; /* really (char *) */ | |
34dc7c2f BB |
303 | char zc_value[MAXPATHLEN * 2]; |
304 | char zc_string[MAXNAMELEN]; | |
428870ff | 305 | char zc_top_ds[MAXPATHLEN]; |
34dc7c2f BB |
306 | uint64_t zc_guid; |
307 | uint64_t zc_nvlist_conf; /* really (char *) */ | |
308 | uint64_t zc_nvlist_conf_size; | |
34dc7c2f BB |
309 | uint64_t zc_cookie; |
310 | uint64_t zc_objset_type; | |
311 | uint64_t zc_perm_action; | |
6f1ffb06 | 312 | uint64_t zc_history_len; |
34dc7c2f BB |
313 | uint64_t zc_history_offset; |
314 | uint64_t zc_obj; | |
9babb374 | 315 | uint64_t zc_iflags; /* internal to zfs(7fs) */ |
34dc7c2f BB |
316 | zfs_share_t zc_share; |
317 | dmu_objset_stats_t zc_objset_stats; | |
318 | struct drr_begin zc_begin_record; | |
319 | zinject_record_t zc_inject_record; | |
45d1cae3 | 320 | boolean_t zc_defer_destroy; |
428870ff | 321 | boolean_t zc_temphold; |
572e2857 BB |
322 | uint64_t zc_action_handle; |
323 | int zc_cleanup_fd; | |
0cee2406 PJD |
324 | uint8_t zc_simple; |
325 | uint8_t zc_pad[3]; /* alignment */ | |
572e2857 BB |
326 | uint64_t zc_sendobj; |
327 | uint64_t zc_fromobj; | |
328 | uint64_t zc_createtxg; | |
329 | zfs_stat_t zc_stat; | |
34dc7c2f BB |
330 | } zfs_cmd_t; |
331 | ||
9babb374 BB |
332 | typedef struct zfs_useracct { |
333 | char zu_domain[256]; | |
334 | uid_t zu_rid; | |
335 | uint32_t zu_pad; | |
336 | uint64_t zu_space; | |
337 | } zfs_useracct_t; | |
338 | ||
572e2857 BB |
339 | #define ZFSDEV_MAX_MINOR (1 << 16) |
340 | #define ZFS_MIN_MINOR (ZFSDEV_MAX_MINOR + 1) | |
34dc7c2f | 341 | |
428870ff BB |
342 | #define ZPOOL_EXPORT_AFTER_SPLIT 0x1 |
343 | ||
34dc7c2f BB |
344 | #ifdef _KERNEL |
345 | ||
346 | typedef struct zfs_creat { | |
347 | nvlist_t *zct_zplprops; | |
348 | nvlist_t *zct_props; | |
349 | } zfs_creat_t; | |
350 | ||
34dc7c2f BB |
351 | extern int zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr); |
352 | extern int zfs_secpolicy_rename_perms(const char *from, | |
353 | const char *to, cred_t *cr); | |
354 | extern int zfs_secpolicy_destroy_perms(const char *name, cred_t *cr); | |
428870ff | 355 | extern int zfs_unmount_snap(const char *, void *); |
34dc7c2f | 356 | |
325f0235 BB |
357 | enum zfsdev_state_type { |
358 | ZST_ONEXIT, | |
359 | ZST_ZEVENT, | |
360 | ZST_ALL, | |
572e2857 BB |
361 | }; |
362 | ||
325f0235 BB |
363 | typedef struct zfsdev_state { |
364 | list_node_t zs_next; /* next zfsdev_state_t link */ | |
365 | struct file *zs_file; /* associated file struct */ | |
366 | minor_t zs_minor; /* made up minor number */ | |
367 | void *zs_onexit; /* onexit data */ | |
368 | void *zs_zevent; /* zevent data */ | |
369 | } zfsdev_state_t; | |
572e2857 | 370 | |
325f0235 BB |
371 | extern void *zfsdev_get_state(minor_t minor, enum zfsdev_state_type which); |
372 | extern minor_t zfsdev_getminor(struct file *filp); | |
572e2857 BB |
373 | extern minor_t zfsdev_minor_alloc(void); |
374 | ||
34dc7c2f BB |
375 | #endif /* _KERNEL */ |
376 | ||
377 | #ifdef __cplusplus | |
378 | } | |
379 | #endif | |
380 | ||
381 | #endif /* _SYS_ZFS_IOCTL_H */ |