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 https://opensource.org/licenses/CDDL-1.0.
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>
41 * Legacy ioctl support allows compatibility with pre-OpenZFS tools on
42 * FreeBSD. The need for it will eventually pass (perhaps after FreeBSD
43 * 12 is well out of support), at which point this code can be removed.
44 * For now, downstream consumers may choose to disable this code by
45 * removing the following define.
47 #define ZFS_LEGACY_SUPPORT
54 * Backwards ioctl compatibility
57 /* ioctl versions for vfs.zfs.version.ioctl */
58 #define ZFS_IOCVER_UNDEF -1
59 #define ZFS_IOCVER_NONE 0
60 #define ZFS_IOCVER_DEADMAN 1
61 #define ZFS_IOCVER_LZC 2
62 #define ZFS_IOCVER_ZCMD 3
63 #define ZFS_IOCVER_EDBP 4
64 #define ZFS_IOCVER_RESUME 5
65 #define ZFS_IOCVER_INLANES 6
66 #define ZFS_IOCVER_PAD 7
67 #define ZFS_IOCVER_LEGACY ZFS_IOCVER_PAD
68 #define ZFS_IOCVER_OZFS 15
70 /* compatibility conversion flag */
71 #define ZFS_CMD_COMPAT_NONE 0
72 #define ZFS_CMD_COMPAT_V15 1
73 #define ZFS_CMD_COMPAT_V28 2
74 #define ZFS_CMD_COMPAT_DEADMAN 3
75 #define ZFS_CMD_COMPAT_LZC 4
76 #define ZFS_CMD_COMPAT_ZCMD 5
77 #define ZFS_CMD_COMPAT_EDBP 6
78 #define ZFS_CMD_COMPAT_RESUME 7
79 #define ZFS_CMD_COMPAT_INLANES 8
80 #define ZFS_CMD_COMPAT_LEGACY 9
82 #define ZFS_IOC_COMPAT_PASS 254
83 #define ZFS_IOC_COMPAT_FAIL 255
85 #define ZFS_IOCREQ(ioreq) ((ioreq) & 0xff)
87 typedef struct zfs_iocparm
{
88 uint32_t zfs_ioctl_version
;
90 uint64_t zfs_cmd_size
;
94 #ifdef ZFS_LEGACY_SUPPORT
95 #define LEGACY_MAXPATHLEN 1024
96 #define LEGACY_MAXNAMELEN 256
99 * Note: this struct must have the same layout in 32-bit and 64-bit, so
100 * that 32-bit processes (like /sbin/zfs) can pass it to the 64-bit
101 * kernel. Therefore, we add padding to it so that no "hidden" padding
102 * is automatically added on 64-bit (but not on 32-bit).
104 typedef struct zfs_cmd_legacy
{
105 char zc_name
[LEGACY_MAXPATHLEN
]; /* pool|dataset name */
106 uint64_t zc_nvlist_src
; /* really (char *) */
107 uint64_t zc_nvlist_src_size
;
108 uint64_t zc_nvlist_dst
; /* really (char *) */
109 uint64_t zc_nvlist_dst_size
;
110 boolean_t zc_nvlist_dst_filled
; /* put an nvlist in dst? */
114 * The following members are for legacy ioctls which haven't been
115 * converted to the new method.
117 uint64_t zc_history
; /* really (char *) */
118 char zc_value
[LEGACY_MAXPATHLEN
* 2];
119 char zc_string
[LEGACY_MAXNAMELEN
];
121 uint64_t zc_nvlist_conf
; /* really (char *) */
122 uint64_t zc_nvlist_conf_size
;
124 uint64_t zc_objset_type
;
125 uint64_t zc_perm_action
;
126 uint64_t zc_history_len
;
127 uint64_t zc_history_offset
;
129 uint64_t zc_iflags
; /* internal to zfs(7fs) */
130 zfs_share_t zc_share
;
132 dmu_objset_stats_t zc_objset_stats
;
133 dmu_replay_record_t zc_begin_record
;
134 zinject_record_t zc_inject_record
;
135 uint32_t zc_defer_destroy
;
137 uint64_t zc_action_handle
;
141 boolean_t zc_resumable
;
145 uint64_t zc_createtxg
;
152 int zfs_ioctl_compat_pre(zfs_cmd_t
*, int *, const int);
153 void zfs_ioctl_compat_post(zfs_cmd_t
*, const int, const int);
154 nvlist_t
*zfs_ioctl_compat_innvl(zfs_cmd_t
*, nvlist_t
*, const int,
156 nvlist_t
*zfs_ioctl_compat_outnvl(zfs_cmd_t
*, nvlist_t
*, const int,
159 #ifdef ZFS_LEGACY_SUPPORT
160 int zfs_ioctl_legacy_to_ozfs(int request
);
161 int zfs_ioctl_ozfs_to_legacy(int request
);
162 void zfs_cmd_legacy_to_ozfs(zfs_cmd_legacy_t
*src
, zfs_cmd_t
*dst
);
163 void zfs_cmd_ozfs_to_legacy(zfs_cmd_t
*src
, zfs_cmd_legacy_t
*dst
);
166 void zfs_cmd_compat_put(zfs_cmd_t
*, caddr_t
, const int, const int);
172 #endif /* _SYS_ZFS_IOCTL_COMPAT_H */