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.
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.
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]
22 * Copyright 2014 Xin Li <delphij@FreeBSD.org>. All rights reserved.
23 * Copyright 2013 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_ZFS_IOCTL_COMPAT_H
28 #define _SYS_ZFS_IOCTL_COMPAT_H
33 #include <sys/dsl_deleg.h>
34 #include <sys/zfs_ioctl.h>
37 #include <sys/nvpair.h>
45 * Backwards ioctl compatibility
48 /* ioctl versions for vfs.zfs.version.ioctl */
49 #define ZFS_IOCVER_UNDEF -1
50 #define ZFS_IOCVER_NONE 0
51 #define ZFS_IOCVER_DEADMAN 1
52 #define ZFS_IOCVER_LZC 2
53 #define ZFS_IOCVER_ZCMD 3
54 #define ZFS_IOCVER_EDBP 4
55 #define ZFS_IOCVER_RESUME 5
56 #define ZFS_IOCVER_INLANES 6
57 #define ZFS_IOCVER_PAD 7
58 #define ZFS_IOCVER_CURRENT ZFS_IOCVER_PAD
60 /* compatibility conversion flag */
61 #define ZFS_CMD_COMPAT_NONE 0
62 #define ZFS_CMD_COMPAT_V15 1
63 #define ZFS_CMD_COMPAT_V28 2
64 #define ZFS_CMD_COMPAT_DEADMAN 3
65 #define ZFS_CMD_COMPAT_LZC 4
66 #define ZFS_CMD_COMPAT_ZCMD 5
67 #define ZFS_CMD_COMPAT_EDBP 6
68 #define ZFS_CMD_COMPAT_RESUME 7
69 #define ZFS_CMD_COMPAT_INLANES 8
71 #define ZFS_IOC_COMPAT_PASS 254
72 #define ZFS_IOC_COMPAT_FAIL 255
74 #define ZFS_IOCREQ(ioreq) ((ioreq) & 0xff)
76 typedef struct zfs_iocparm {
77 uint32_t zfs_ioctl_version;
79 uint64_t zfs_cmd_size;
82 typedef struct zinject_record_v15 {
93 } zinject_record_v15_t;
95 typedef struct zfs_cmd_v15 {
96 char zc_name[MAXPATHLEN];
97 char zc_value[MAXPATHLEN];
98 char zc_string[MAXNAMELEN];
100 uint64_t zc_nvlist_conf; /* really (char *) */
101 uint64_t zc_nvlist_conf_size;
102 uint64_t zc_nvlist_src; /* really (char *) */
103 uint64_t zc_nvlist_src_size;
104 uint64_t zc_nvlist_dst; /* really (char *) */
105 uint64_t zc_nvlist_dst_size;
107 uint64_t zc_objset_type;
108 uint64_t zc_perm_action;
109 uint64_t zc_history; /* really (char *) */
110 uint64_t zc_history_len;
111 uint64_t zc_history_offset;
113 zfs_share_t zc_share;
115 dmu_objset_stats_t zc_objset_stats;
116 struct drr_begin zc_begin_record;
117 zinject_record_v15_t zc_inject_record;
120 typedef struct zinject_record_v28 {
130 uint32_t zi_failfast;
131 char zi_func[MAXNAMELEN];
135 } zinject_record_v28_t;
137 typedef struct zfs_cmd_v28 {
138 char zc_name[MAXPATHLEN];
139 char zc_value[MAXPATHLEN * 2];
140 char zc_string[MAXNAMELEN];
141 char zc_top_ds[MAXPATHLEN];
143 uint64_t zc_nvlist_conf; /* really (char *) */
144 uint64_t zc_nvlist_conf_size;
145 uint64_t zc_nvlist_src; /* really (char *) */
146 uint64_t zc_nvlist_src_size;
147 uint64_t zc_nvlist_dst; /* really (char *) */
148 uint64_t zc_nvlist_dst_size;
150 uint64_t zc_objset_type;
151 uint64_t zc_perm_action;
152 uint64_t zc_history; /* really (char *) */
153 uint64_t zc_history_len;
154 uint64_t zc_history_offset;
156 uint64_t zc_iflags; /* internal to zfs(7fs) */
157 zfs_share_t zc_share;
159 dmu_objset_stats_t zc_objset_stats;
160 struct drr_begin zc_begin_record;
161 zinject_record_v28_t zc_inject_record;
162 boolean_t zc_defer_destroy;
163 boolean_t zc_temphold;
164 uint64_t zc_action_handle;
167 uint8_t zc_pad[3]; /* alignment */
170 uint64_t zc_createtxg;
174 typedef struct zinject_record_deadman {
184 uint32_t zi_failfast;
185 char zi_func[MAXNAMELEN];
191 } zinject_record_deadman_t;
193 typedef struct zfs_cmd_deadman {
194 char zc_name[MAXPATHLEN];
195 char zc_value[MAXPATHLEN * 2];
196 char zc_string[MAXNAMELEN];
197 char zc_top_ds[MAXPATHLEN];
199 uint64_t zc_nvlist_conf; /* really (char *) */
200 uint64_t zc_nvlist_conf_size;
201 uint64_t zc_nvlist_src; /* really (char *) */
202 uint64_t zc_nvlist_src_size;
203 uint64_t zc_nvlist_dst; /* really (char *) */
204 uint64_t zc_nvlist_dst_size;
206 uint64_t zc_objset_type;
207 uint64_t zc_perm_action;
208 uint64_t zc_history; /* really (char *) */
209 uint64_t zc_history_len;
210 uint64_t zc_history_offset;
212 uint64_t zc_iflags; /* internal to zfs(7fs) */
213 zfs_share_t zc_share;
215 dmu_objset_stats_t zc_objset_stats;
216 struct drr_begin zc_begin_record;
217 /* zc_inject_record doesn't change in libzfs_core */
218 zinject_record_deadman_t zc_inject_record;
219 boolean_t zc_defer_destroy;
220 boolean_t zc_temphold;
221 uint64_t zc_action_handle;
224 uint8_t zc_pad[3]; /* alignment */
227 uint64_t zc_createtxg;
231 typedef struct zfs_cmd_zcmd {
232 char zc_name[MAXPATHLEN]; /* name of pool or dataset */
233 uint64_t zc_nvlist_src; /* really (char *) */
234 uint64_t zc_nvlist_src_size;
235 uint64_t zc_nvlist_dst; /* really (char *) */
236 uint64_t zc_nvlist_dst_size;
237 boolean_t zc_nvlist_dst_filled; /* put an nvlist in dst? */
241 * The following members are for legacy ioctls which haven't been
242 * converted to the new method.
244 uint64_t zc_history; /* really (char *) */
245 char zc_value[MAXPATHLEN * 2];
246 char zc_string[MAXNAMELEN];
248 uint64_t zc_nvlist_conf; /* really (char *) */
249 uint64_t zc_nvlist_conf_size;
251 uint64_t zc_objset_type;
252 uint64_t zc_perm_action;
253 uint64_t zc_history_len;
254 uint64_t zc_history_offset;
256 uint64_t zc_iflags; /* internal to zfs(7fs) */
257 zfs_share_t zc_share;
259 dmu_objset_stats_t zc_objset_stats;
260 struct drr_begin zc_begin_record;
261 zinject_record_deadman_t zc_inject_record;
262 boolean_t zc_defer_destroy;
263 boolean_t zc_temphold;
264 uint64_t zc_action_handle;
267 uint8_t zc_pad[3]; /* alignment */
270 uint64_t zc_createtxg;
274 typedef struct zfs_cmd_edbp {
275 char zc_name[MAXPATHLEN]; /* name of pool or dataset */
276 uint64_t zc_nvlist_src; /* really (char *) */
277 uint64_t zc_nvlist_src_size;
278 uint64_t zc_nvlist_dst; /* really (char *) */
279 uint64_t zc_nvlist_dst_size;
280 boolean_t zc_nvlist_dst_filled; /* put an nvlist in dst? */
284 * The following members are for legacy ioctls which haven't been
285 * converted to the new method.
287 uint64_t zc_history; /* really (char *) */
288 char zc_value[MAXPATHLEN * 2];
289 char zc_string[MAXNAMELEN];
291 uint64_t zc_nvlist_conf; /* really (char *) */
292 uint64_t zc_nvlist_conf_size;
294 uint64_t zc_objset_type;
295 uint64_t zc_perm_action;
296 uint64_t zc_history_len;
297 uint64_t zc_history_offset;
299 uint64_t zc_iflags; /* internal to zfs(7fs) */
300 zfs_share_t zc_share;
302 dmu_objset_stats_t zc_objset_stats;
303 struct drr_begin zc_begin_record;
304 zinject_record_deadman_t zc_inject_record;
305 uint32_t zc_defer_destroy;
307 uint64_t zc_action_handle;
310 uint8_t zc_pad[3]; /* alignment */
313 uint64_t zc_createtxg;
317 typedef struct zfs_cmd_resume {
318 char zc_name[MAXPATHLEN]; /* name of pool or dataset */
319 uint64_t zc_nvlist_src; /* really (char *) */
320 uint64_t zc_nvlist_src_size;
321 uint64_t zc_nvlist_dst; /* really (char *) */
322 uint64_t zc_nvlist_dst_size;
323 boolean_t zc_nvlist_dst_filled; /* put an nvlist in dst? */
327 * The following members are for legacy ioctls which haven't been
328 * converted to the new method.
330 uint64_t zc_history; /* really (char *) */
331 char zc_value[MAXPATHLEN * 2];
332 char zc_string[MAXNAMELEN];
334 uint64_t zc_nvlist_conf; /* really (char *) */
335 uint64_t zc_nvlist_conf_size;
337 uint64_t zc_objset_type;
338 uint64_t zc_perm_action;
339 uint64_t zc_history_len;
340 uint64_t zc_history_offset;
342 uint64_t zc_iflags; /* internal to zfs(7fs) */
343 zfs_share_t zc_share;
345 dmu_objset_stats_t zc_objset_stats;
346 dmu_replay_record_t zc_begin_record;
347 zinject_record_deadman_t zc_inject_record;
348 uint32_t zc_defer_destroy;
350 uint64_t zc_action_handle;
353 boolean_t zc_resumable;
356 uint64_t zc_createtxg;
360 typedef struct zfs_cmd_inlanes {
361 char zc_name[MAXPATHLEN]; /* name of pool or dataset */
362 uint64_t zc_nvlist_src; /* really (char *) */
363 uint64_t zc_nvlist_src_size;
364 uint64_t zc_nvlist_dst; /* really (char *) */
365 uint64_t zc_nvlist_dst_size;
366 boolean_t zc_nvlist_dst_filled; /* put an nvlist in dst? */
370 * The following members are for legacy ioctls which haven't been
371 * converted to the new method.
373 uint64_t zc_history; /* really (char *) */
374 char zc_value[MAXPATHLEN * 2];
375 char zc_string[MAXNAMELEN];
377 uint64_t zc_nvlist_conf; /* really (char *) */
378 uint64_t zc_nvlist_conf_size;
380 uint64_t zc_objset_type;
381 uint64_t zc_perm_action;
382 uint64_t zc_history_len;
383 uint64_t zc_history_offset;
385 uint64_t zc_iflags; /* internal to zfs(7fs) */
386 zfs_share_t zc_share;
388 dmu_objset_stats_t zc_objset_stats;
389 dmu_replay_record_t zc_begin_record;
390 zinject_record_t zc_inject_record;
391 uint32_t zc_defer_destroy;
393 uint64_t zc_action_handle;
396 boolean_t zc_resumable;
399 uint64_t zc_createtxg;
404 unsigned static long zfs_ioctl_v15_to_v28[] = {
405 0, /* 0 ZFS_IOC_POOL_CREATE */
406 1, /* 1 ZFS_IOC_POOL_DESTROY */
407 2, /* 2 ZFS_IOC_POOL_IMPORT */
408 3, /* 3 ZFS_IOC_POOL_EXPORT */
409 4, /* 4 ZFS_IOC_POOL_CONFIGS */
410 5, /* 5 ZFS_IOC_POOL_STATS */
411 6, /* 6 ZFS_IOC_POOL_TRYIMPORT */
412 7, /* 7 ZFS_IOC_POOL_SCRUB */
413 8, /* 8 ZFS_IOC_POOL_FREEZE */
414 9, /* 9 ZFS_IOC_POOL_UPGRADE */
415 10, /* 10 ZFS_IOC_POOL_GET_HISTORY */
416 11, /* 11 ZFS_IOC_VDEV_ADD */
417 12, /* 12 ZFS_IOC_VDEV_REMOVE */
418 13, /* 13 ZFS_IOC_VDEV_SET_STATE */
419 14, /* 14 ZFS_IOC_VDEV_ATTACH */
420 15, /* 15 ZFS_IOC_VDEV_DETACH */
421 16, /* 16 ZFS_IOC_VDEV_SETPATH */
422 18, /* 17 ZFS_IOC_OBJSET_STATS */
423 19, /* 18 ZFS_IOC_OBJSET_ZPLPROPS */
424 20, /* 19 ZFS_IOC_DATASET_LIST_NEXT */
425 21, /* 20 ZFS_IOC_SNAPSHOT_LIST_NEXT */
426 22, /* 21 ZFS_IOC_SET_PROP */
427 ZFS_IOC_COMPAT_PASS, /* 22 ZFS_IOC_CREATE_MINOR */
428 ZFS_IOC_COMPAT_PASS, /* 23 ZFS_IOC_REMOVE_MINOR */
429 23, /* 24 ZFS_IOC_CREATE */
430 24, /* 25 ZFS_IOC_DESTROY */
431 25, /* 26 ZFS_IOC_ROLLBACK */
432 26, /* 27 ZFS_IOC_RENAME */
433 27, /* 28 ZFS_IOC_RECV */
434 28, /* 29 ZFS_IOC_SEND */
435 29, /* 30 ZFS_IOC_INJECT_FAULT */
436 30, /* 31 ZFS_IOC_CLEAR_FAULT */
437 31, /* 32 ZFS_IOC_INJECT_LIST_NEXT */
438 32, /* 33 ZFS_IOC_ERROR_LOG */
439 33, /* 34 ZFS_IOC_CLEAR */
440 34, /* 35 ZFS_IOC_PROMOTE */
441 35, /* 36 ZFS_IOC_DESTROY_SNAPS */
442 36, /* 37 ZFS_IOC_SNAPSHOT */
443 37, /* 38 ZFS_IOC_DSOBJ_TO_DSNAME */
444 38, /* 39 ZFS_IOC_OBJ_TO_PATH */
445 39, /* 40 ZFS_IOC_POOL_SET_PROPS */
446 40, /* 41 ZFS_IOC_POOL_GET_PROPS */
447 41, /* 42 ZFS_IOC_SET_FSACL */
448 42, /* 43 ZFS_IOC_GET_FSACL */
449 ZFS_IOC_COMPAT_PASS, /* 44 ZFS_IOC_ISCSI_PERM_CHECK */
450 43, /* 45 ZFS_IOC_SHARE */
451 44, /* 46 ZFS_IOC_IHNERIT_PROP */
452 58, /* 47 ZFS_IOC_JAIL */
453 59, /* 48 ZFS_IOC_UNJAIL */
454 45, /* 49 ZFS_IOC_SMB_ACL */
455 46, /* 50 ZFS_IOC_USERSPACE_ONE */
456 47, /* 51 ZFS_IOC_USERSPACE_MANY */
457 48, /* 52 ZFS_IOC_USERSPACE_UPGRADE */
458 17, /* 53 ZFS_IOC_SETFRU */
462 unsigned static long zfs_ioctl_v28_to_v15[] = {
463 0, /* 0 ZFS_IOC_POOL_CREATE */
464 1, /* 1 ZFS_IOC_POOL_DESTROY */
465 2, /* 2 ZFS_IOC_POOL_IMPORT */
466 3, /* 3 ZFS_IOC_POOL_EXPORT */
467 4, /* 4 ZFS_IOC_POOL_CONFIGS */
468 5, /* 5 ZFS_IOC_POOL_STATS */
469 6, /* 6 ZFS_IOC_POOL_TRYIMPORT */
470 7, /* 7 ZFS_IOC_POOL_SCAN */
471 8, /* 8 ZFS_IOC_POOL_FREEZE */
472 9, /* 9 ZFS_IOC_POOL_UPGRADE */
473 10, /* 10 ZFS_IOC_POOL_GET_HISTORY */
474 11, /* 11 ZFS_IOC_VDEV_ADD */
475 12, /* 12 ZFS_IOC_VDEV_REMOVE */
476 13, /* 13 ZFS_IOC_VDEV_SET_STATE */
477 14, /* 14 ZFS_IOC_VDEV_ATTACH */
478 15, /* 15 ZFS_IOC_VDEV_DETACH */
479 16, /* 16 ZFS_IOC_VDEV_SETPATH */
480 53, /* 17 ZFS_IOC_VDEV_SETFRU */
481 17, /* 18 ZFS_IOC_OBJSET_STATS */
482 18, /* 19 ZFS_IOC_OBJSET_ZPLPROPS */
483 19, /* 20 ZFS_IOC_DATASET_LIST_NEXT */
484 20, /* 21 ZFS_IOC_SNAPSHOT_LIST_NEXT */
485 21, /* 22 ZFS_IOC_SET_PROP */
486 24, /* 23 ZFS_IOC_CREATE */
487 25, /* 24 ZFS_IOC_DESTROY */
488 26, /* 25 ZFS_IOC_ROLLBACK */
489 27, /* 26 ZFS_IOC_RENAME */
490 28, /* 27 ZFS_IOC_RECV */
491 29, /* 28 ZFS_IOC_SEND */
492 30, /* 39 ZFS_IOC_INJECT_FAULT */
493 31, /* 30 ZFS_IOC_CLEAR_FAULT */
494 32, /* 31 ZFS_IOC_INJECT_LIST_NEXT */
495 33, /* 32 ZFS_IOC_ERROR_LOG */
496 34, /* 33 ZFS_IOC_CLEAR */
497 35, /* 34 ZFS_IOC_PROMOTE */
498 36, /* 35 ZFS_IOC_DESTROY_SNAPS */
499 37, /* 36 ZFS_IOC_SNAPSHOT */
500 38, /* 37 ZFS_IOC_DSOBJ_TO_DSNAME */
501 39, /* 38 ZFS_IOC_OBJ_TO_PATH */
502 40, /* 39 ZFS_IOC_POOL_SET_PROPS */
503 41, /* 40 ZFS_IOC_POOL_GET_PROPS */
504 42, /* 41 ZFS_IOC_SET_FSACL */
505 43, /* 42 ZFS_IOC_GET_FSACL */
506 45, /* 43 ZFS_IOC_SHARE */
507 46, /* 44 ZFS_IOC_IHNERIT_PROP */
508 49, /* 45 ZFS_IOC_SMB_ACL */
509 50, /* 46 ZFS_IOC_USERSPACE_ONE */
510 51, /* 47 ZFS_IOC_USERSPACE_MANY */
511 52, /* 48 ZFS_IOC_USERSPACE_UPGRADE */
512 ZFS_IOC_COMPAT_FAIL, /* 49 ZFS_IOC_HOLD */
513 ZFS_IOC_COMPAT_FAIL, /* 50 ZFS_IOC_RELEASE */
514 ZFS_IOC_COMPAT_FAIL, /* 51 ZFS_IOC_GET_HOLDS */
515 ZFS_IOC_COMPAT_FAIL, /* 52 ZFS_IOC_OBJSET_RECVD_PROPS */
516 ZFS_IOC_COMPAT_FAIL, /* 53 ZFS_IOC_VDEV_SPLIT */
517 ZFS_IOC_COMPAT_FAIL, /* 54 ZFS_IOC_NEXT_OBJ */
518 ZFS_IOC_COMPAT_FAIL, /* 55 ZFS_IOC_DIFF */
519 ZFS_IOC_COMPAT_FAIL, /* 56 ZFS_IOC_TMP_SNAPSHOT */
520 ZFS_IOC_COMPAT_FAIL, /* 57 ZFS_IOC_OBJ_TO_STATS */
521 47, /* 58 ZFS_IOC_JAIL */
522 48, /* 59 ZFS_IOC_UNJAIL */
524 #endif /* ! _KERNEL */
527 int zfs_ioctl_compat_pre(zfs_cmd_t *, int *, const int);
528 void zfs_ioctl_compat_post(zfs_cmd_t *, const int, const int);
529 nvlist_t *zfs_ioctl_compat_innvl(zfs_cmd_t *, nvlist_t *, const int,
531 nvlist_t *zfs_ioctl_compat_outnvl(zfs_cmd_t *, nvlist_t *, const int,
534 int zcmd_ioctl_compat(int, int, zfs_cmd_t *, const int);
536 void zfs_cmd_compat_get(zfs_cmd_t *, caddr_t, const int);
537 void zfs_cmd_compat_put(zfs_cmd_t *, caddr_t, const int, const int);
543 #endif /* _SYS_ZFS_IOCTL_COMPAT_H */