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_CURRENT ZFS_IOCVER_INLANES
59 /* compatibility conversion flag */
60 #define ZFS_CMD_COMPAT_NONE 0
61 #define ZFS_CMD_COMPAT_V15 1
62 #define ZFS_CMD_COMPAT_V28 2
63 #define ZFS_CMD_COMPAT_DEADMAN 3
64 #define ZFS_CMD_COMPAT_LZC 4
65 #define ZFS_CMD_COMPAT_ZCMD 5
66 #define ZFS_CMD_COMPAT_EDBP 6
67 #define ZFS_CMD_COMPAT_RESUME 7
69 #define ZFS_IOC_COMPAT_PASS 254
70 #define ZFS_IOC_COMPAT_FAIL 255
72 #define ZFS_IOCREQ(ioreq) ((ioreq) & 0xff)
74 typedef struct zfs_iocparm {
75 uint32_t zfs_ioctl_version;
77 uint64_t zfs_cmd_size;
80 typedef struct zinject_record_v15 {
91 } zinject_record_v15_t;
93 typedef struct zfs_cmd_v15 {
94 char zc_name[MAXPATHLEN];
95 char zc_value[MAXPATHLEN];
96 char zc_string[MAXNAMELEN];
98 uint64_t zc_nvlist_conf; /* really (char *) */
99 uint64_t zc_nvlist_conf_size;
100 uint64_t zc_nvlist_src; /* really (char *) */
101 uint64_t zc_nvlist_src_size;
102 uint64_t zc_nvlist_dst; /* really (char *) */
103 uint64_t zc_nvlist_dst_size;
105 uint64_t zc_objset_type;
106 uint64_t zc_perm_action;
107 uint64_t zc_history; /* really (char *) */
108 uint64_t zc_history_len;
109 uint64_t zc_history_offset;
111 zfs_share_t zc_share;
113 dmu_objset_stats_t zc_objset_stats;
114 struct drr_begin zc_begin_record;
115 zinject_record_v15_t zc_inject_record;
118 typedef struct zinject_record_v28 {
128 uint32_t zi_failfast;
129 char zi_func[MAXNAMELEN];
133 } zinject_record_v28_t;
135 typedef struct zfs_cmd_v28 {
136 char zc_name[MAXPATHLEN];
137 char zc_value[MAXPATHLEN * 2];
138 char zc_string[MAXNAMELEN];
139 char zc_top_ds[MAXPATHLEN];
141 uint64_t zc_nvlist_conf; /* really (char *) */
142 uint64_t zc_nvlist_conf_size;
143 uint64_t zc_nvlist_src; /* really (char *) */
144 uint64_t zc_nvlist_src_size;
145 uint64_t zc_nvlist_dst; /* really (char *) */
146 uint64_t zc_nvlist_dst_size;
148 uint64_t zc_objset_type;
149 uint64_t zc_perm_action;
150 uint64_t zc_history; /* really (char *) */
151 uint64_t zc_history_len;
152 uint64_t zc_history_offset;
154 uint64_t zc_iflags; /* internal to zfs(7fs) */
155 zfs_share_t zc_share;
157 dmu_objset_stats_t zc_objset_stats;
158 struct drr_begin zc_begin_record;
159 zinject_record_v28_t zc_inject_record;
160 boolean_t zc_defer_destroy;
161 boolean_t zc_temphold;
162 uint64_t zc_action_handle;
165 uint8_t zc_pad[3]; /* alignment */
168 uint64_t zc_createtxg;
172 typedef struct zinject_record_deadman {
182 uint32_t zi_failfast;
183 char zi_func[MAXNAMELEN];
189 } zinject_record_deadman_t;
191 typedef struct zfs_cmd_deadman {
192 char zc_name[MAXPATHLEN];
193 char zc_value[MAXPATHLEN * 2];
194 char zc_string[MAXNAMELEN];
195 char zc_top_ds[MAXPATHLEN];
197 uint64_t zc_nvlist_conf; /* really (char *) */
198 uint64_t zc_nvlist_conf_size;
199 uint64_t zc_nvlist_src; /* really (char *) */
200 uint64_t zc_nvlist_src_size;
201 uint64_t zc_nvlist_dst; /* really (char *) */
202 uint64_t zc_nvlist_dst_size;
204 uint64_t zc_objset_type;
205 uint64_t zc_perm_action;
206 uint64_t zc_history; /* really (char *) */
207 uint64_t zc_history_len;
208 uint64_t zc_history_offset;
210 uint64_t zc_iflags; /* internal to zfs(7fs) */
211 zfs_share_t zc_share;
213 dmu_objset_stats_t zc_objset_stats;
214 struct drr_begin zc_begin_record;
215 /* zc_inject_record doesn't change in libzfs_core */
216 zinject_record_deadman_t zc_inject_record;
217 boolean_t zc_defer_destroy;
218 boolean_t zc_temphold;
219 uint64_t zc_action_handle;
222 uint8_t zc_pad[3]; /* alignment */
225 uint64_t zc_createtxg;
229 typedef struct zfs_cmd_zcmd {
230 char zc_name[MAXPATHLEN]; /* name of pool or dataset */
231 uint64_t zc_nvlist_src; /* really (char *) */
232 uint64_t zc_nvlist_src_size;
233 uint64_t zc_nvlist_dst; /* really (char *) */
234 uint64_t zc_nvlist_dst_size;
235 boolean_t zc_nvlist_dst_filled; /* put an nvlist in dst? */
239 * The following members are for legacy ioctls which haven't been
240 * converted to the new method.
242 uint64_t zc_history; /* really (char *) */
243 char zc_value[MAXPATHLEN * 2];
244 char zc_string[MAXNAMELEN];
246 uint64_t zc_nvlist_conf; /* really (char *) */
247 uint64_t zc_nvlist_conf_size;
249 uint64_t zc_objset_type;
250 uint64_t zc_perm_action;
251 uint64_t zc_history_len;
252 uint64_t zc_history_offset;
254 uint64_t zc_iflags; /* internal to zfs(7fs) */
255 zfs_share_t zc_share;
257 dmu_objset_stats_t zc_objset_stats;
258 struct drr_begin zc_begin_record;
259 zinject_record_deadman_t zc_inject_record;
260 boolean_t zc_defer_destroy;
261 boolean_t zc_temphold;
262 uint64_t zc_action_handle;
265 uint8_t zc_pad[3]; /* alignment */
268 uint64_t zc_createtxg;
272 typedef struct zfs_cmd_edbp {
273 char zc_name[MAXPATHLEN]; /* name of pool or dataset */
274 uint64_t zc_nvlist_src; /* really (char *) */
275 uint64_t zc_nvlist_src_size;
276 uint64_t zc_nvlist_dst; /* really (char *) */
277 uint64_t zc_nvlist_dst_size;
278 boolean_t zc_nvlist_dst_filled; /* put an nvlist in dst? */
282 * The following members are for legacy ioctls which haven't been
283 * converted to the new method.
285 uint64_t zc_history; /* really (char *) */
286 char zc_value[MAXPATHLEN * 2];
287 char zc_string[MAXNAMELEN];
289 uint64_t zc_nvlist_conf; /* really (char *) */
290 uint64_t zc_nvlist_conf_size;
292 uint64_t zc_objset_type;
293 uint64_t zc_perm_action;
294 uint64_t zc_history_len;
295 uint64_t zc_history_offset;
297 uint64_t zc_iflags; /* internal to zfs(7fs) */
298 zfs_share_t zc_share;
300 dmu_objset_stats_t zc_objset_stats;
301 struct drr_begin zc_begin_record;
302 zinject_record_deadman_t zc_inject_record;
303 uint32_t zc_defer_destroy;
305 uint64_t zc_action_handle;
308 uint8_t zc_pad[3]; /* alignment */
311 uint64_t zc_createtxg;
315 typedef struct zfs_cmd_resume {
316 char zc_name[MAXPATHLEN]; /* name of pool or dataset */
317 uint64_t zc_nvlist_src; /* really (char *) */
318 uint64_t zc_nvlist_src_size;
319 uint64_t zc_nvlist_dst; /* really (char *) */
320 uint64_t zc_nvlist_dst_size;
321 boolean_t zc_nvlist_dst_filled; /* put an nvlist in dst? */
325 * The following members are for legacy ioctls which haven't been
326 * converted to the new method.
328 uint64_t zc_history; /* really (char *) */
329 char zc_value[MAXPATHLEN * 2];
330 char zc_string[MAXNAMELEN];
332 uint64_t zc_nvlist_conf; /* really (char *) */
333 uint64_t zc_nvlist_conf_size;
335 uint64_t zc_objset_type;
336 uint64_t zc_perm_action;
337 uint64_t zc_history_len;
338 uint64_t zc_history_offset;
340 uint64_t zc_iflags; /* internal to zfs(7fs) */
341 zfs_share_t zc_share;
343 dmu_objset_stats_t zc_objset_stats;
344 dmu_replay_record_t zc_begin_record;
345 zinject_record_deadman_t zc_inject_record;
346 uint32_t zc_defer_destroy;
348 uint64_t zc_action_handle;
351 boolean_t zc_resumable;
354 uint64_t zc_createtxg;
359 unsigned static long zfs_ioctl_v15_to_v28[] = {
360 0, /* 0 ZFS_IOC_POOL_CREATE */
361 1, /* 1 ZFS_IOC_POOL_DESTROY */
362 2, /* 2 ZFS_IOC_POOL_IMPORT */
363 3, /* 3 ZFS_IOC_POOL_EXPORT */
364 4, /* 4 ZFS_IOC_POOL_CONFIGS */
365 5, /* 5 ZFS_IOC_POOL_STATS */
366 6, /* 6 ZFS_IOC_POOL_TRYIMPORT */
367 7, /* 7 ZFS_IOC_POOL_SCRUB */
368 8, /* 8 ZFS_IOC_POOL_FREEZE */
369 9, /* 9 ZFS_IOC_POOL_UPGRADE */
370 10, /* 10 ZFS_IOC_POOL_GET_HISTORY */
371 11, /* 11 ZFS_IOC_VDEV_ADD */
372 12, /* 12 ZFS_IOC_VDEV_REMOVE */
373 13, /* 13 ZFS_IOC_VDEV_SET_STATE */
374 14, /* 14 ZFS_IOC_VDEV_ATTACH */
375 15, /* 15 ZFS_IOC_VDEV_DETACH */
376 16, /* 16 ZFS_IOC_VDEV_SETPATH */
377 18, /* 17 ZFS_IOC_OBJSET_STATS */
378 19, /* 18 ZFS_IOC_OBJSET_ZPLPROPS */
379 20, /* 19 ZFS_IOC_DATASET_LIST_NEXT */
380 21, /* 20 ZFS_IOC_SNAPSHOT_LIST_NEXT */
381 22, /* 21 ZFS_IOC_SET_PROP */
382 ZFS_IOC_COMPAT_PASS, /* 22 ZFS_IOC_CREATE_MINOR */
383 ZFS_IOC_COMPAT_PASS, /* 23 ZFS_IOC_REMOVE_MINOR */
384 23, /* 24 ZFS_IOC_CREATE */
385 24, /* 25 ZFS_IOC_DESTROY */
386 25, /* 26 ZFS_IOC_ROLLBACK */
387 26, /* 27 ZFS_IOC_RENAME */
388 27, /* 28 ZFS_IOC_RECV */
389 28, /* 29 ZFS_IOC_SEND */
390 29, /* 30 ZFS_IOC_INJECT_FAULT */
391 30, /* 31 ZFS_IOC_CLEAR_FAULT */
392 31, /* 32 ZFS_IOC_INJECT_LIST_NEXT */
393 32, /* 33 ZFS_IOC_ERROR_LOG */
394 33, /* 34 ZFS_IOC_CLEAR */
395 34, /* 35 ZFS_IOC_PROMOTE */
396 35, /* 36 ZFS_IOC_DESTROY_SNAPS */
397 36, /* 37 ZFS_IOC_SNAPSHOT */
398 37, /* 38 ZFS_IOC_DSOBJ_TO_DSNAME */
399 38, /* 39 ZFS_IOC_OBJ_TO_PATH */
400 39, /* 40 ZFS_IOC_POOL_SET_PROPS */
401 40, /* 41 ZFS_IOC_POOL_GET_PROPS */
402 41, /* 42 ZFS_IOC_SET_FSACL */
403 42, /* 43 ZFS_IOC_GET_FSACL */
404 ZFS_IOC_COMPAT_PASS, /* 44 ZFS_IOC_ISCSI_PERM_CHECK */
405 43, /* 45 ZFS_IOC_SHARE */
406 44, /* 46 ZFS_IOC_IHNERIT_PROP */
407 58, /* 47 ZFS_IOC_JAIL */
408 59, /* 48 ZFS_IOC_UNJAIL */
409 45, /* 49 ZFS_IOC_SMB_ACL */
410 46, /* 50 ZFS_IOC_USERSPACE_ONE */
411 47, /* 51 ZFS_IOC_USERSPACE_MANY */
412 48, /* 52 ZFS_IOC_USERSPACE_UPGRADE */
413 17, /* 53 ZFS_IOC_SETFRU */
417 unsigned static long zfs_ioctl_v28_to_v15[] = {
418 0, /* 0 ZFS_IOC_POOL_CREATE */
419 1, /* 1 ZFS_IOC_POOL_DESTROY */
420 2, /* 2 ZFS_IOC_POOL_IMPORT */
421 3, /* 3 ZFS_IOC_POOL_EXPORT */
422 4, /* 4 ZFS_IOC_POOL_CONFIGS */
423 5, /* 5 ZFS_IOC_POOL_STATS */
424 6, /* 6 ZFS_IOC_POOL_TRYIMPORT */
425 7, /* 7 ZFS_IOC_POOL_SCAN */
426 8, /* 8 ZFS_IOC_POOL_FREEZE */
427 9, /* 9 ZFS_IOC_POOL_UPGRADE */
428 10, /* 10 ZFS_IOC_POOL_GET_HISTORY */
429 11, /* 11 ZFS_IOC_VDEV_ADD */
430 12, /* 12 ZFS_IOC_VDEV_REMOVE */
431 13, /* 13 ZFS_IOC_VDEV_SET_STATE */
432 14, /* 14 ZFS_IOC_VDEV_ATTACH */
433 15, /* 15 ZFS_IOC_VDEV_DETACH */
434 16, /* 16 ZFS_IOC_VDEV_SETPATH */
435 53, /* 17 ZFS_IOC_VDEV_SETFRU */
436 17, /* 18 ZFS_IOC_OBJSET_STATS */
437 18, /* 19 ZFS_IOC_OBJSET_ZPLPROPS */
438 19, /* 20 ZFS_IOC_DATASET_LIST_NEXT */
439 20, /* 21 ZFS_IOC_SNAPSHOT_LIST_NEXT */
440 21, /* 22 ZFS_IOC_SET_PROP */
441 24, /* 23 ZFS_IOC_CREATE */
442 25, /* 24 ZFS_IOC_DESTROY */
443 26, /* 25 ZFS_IOC_ROLLBACK */
444 27, /* 26 ZFS_IOC_RENAME */
445 28, /* 27 ZFS_IOC_RECV */
446 29, /* 28 ZFS_IOC_SEND */
447 30, /* 39 ZFS_IOC_INJECT_FAULT */
448 31, /* 30 ZFS_IOC_CLEAR_FAULT */
449 32, /* 31 ZFS_IOC_INJECT_LIST_NEXT */
450 33, /* 32 ZFS_IOC_ERROR_LOG */
451 34, /* 33 ZFS_IOC_CLEAR */
452 35, /* 34 ZFS_IOC_PROMOTE */
453 36, /* 35 ZFS_IOC_DESTROY_SNAPS */
454 37, /* 36 ZFS_IOC_SNAPSHOT */
455 38, /* 37 ZFS_IOC_DSOBJ_TO_DSNAME */
456 39, /* 38 ZFS_IOC_OBJ_TO_PATH */
457 40, /* 39 ZFS_IOC_POOL_SET_PROPS */
458 41, /* 40 ZFS_IOC_POOL_GET_PROPS */
459 42, /* 41 ZFS_IOC_SET_FSACL */
460 43, /* 42 ZFS_IOC_GET_FSACL */
461 45, /* 43 ZFS_IOC_SHARE */
462 46, /* 44 ZFS_IOC_IHNERIT_PROP */
463 49, /* 45 ZFS_IOC_SMB_ACL */
464 50, /* 46 ZFS_IOC_USERSPACE_ONE */
465 51, /* 47 ZFS_IOC_USERSPACE_MANY */
466 52, /* 48 ZFS_IOC_USERSPACE_UPGRADE */
467 ZFS_IOC_COMPAT_FAIL, /* 49 ZFS_IOC_HOLD */
468 ZFS_IOC_COMPAT_FAIL, /* 50 ZFS_IOC_RELEASE */
469 ZFS_IOC_COMPAT_FAIL, /* 51 ZFS_IOC_GET_HOLDS */
470 ZFS_IOC_COMPAT_FAIL, /* 52 ZFS_IOC_OBJSET_RECVD_PROPS */
471 ZFS_IOC_COMPAT_FAIL, /* 53 ZFS_IOC_VDEV_SPLIT */
472 ZFS_IOC_COMPAT_FAIL, /* 54 ZFS_IOC_NEXT_OBJ */
473 ZFS_IOC_COMPAT_FAIL, /* 55 ZFS_IOC_DIFF */
474 ZFS_IOC_COMPAT_FAIL, /* 56 ZFS_IOC_TMP_SNAPSHOT */
475 ZFS_IOC_COMPAT_FAIL, /* 57 ZFS_IOC_OBJ_TO_STATS */
476 47, /* 58 ZFS_IOC_JAIL */
477 48, /* 59 ZFS_IOC_UNJAIL */
479 #endif /* ! _KERNEL */
482 int zfs_ioctl_compat_pre(zfs_cmd_t *, int *, const int);
483 void zfs_ioctl_compat_post(zfs_cmd_t *, const int, const int);
484 nvlist_t *zfs_ioctl_compat_innvl(zfs_cmd_t *, nvlist_t *, const int,
486 nvlist_t *zfs_ioctl_compat_outnvl(zfs_cmd_t *, nvlist_t *, const int,
489 int zcmd_ioctl_compat(int, int, zfs_cmd_t *, const int);
491 void zfs_cmd_compat_get(zfs_cmd_t *, caddr_t, const int);
492 void zfs_cmd_compat_put(zfs_cmd_t *, caddr_t, const int, const int);
498 #endif /* _SYS_ZFS_IOCTL_COMPAT_H */