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_CURRENT ZFS_IOCVER_EDBP
57 /* compatibility conversion flag */
58 #define ZFS_CMD_COMPAT_NONE 0
59 #define ZFS_CMD_COMPAT_V15 1
60 #define ZFS_CMD_COMPAT_V28 2
61 #define ZFS_CMD_COMPAT_DEADMAN 3
62 #define ZFS_CMD_COMPAT_LZC 4
63 #define ZFS_CMD_COMPAT_ZCMD 5
65 #define ZFS_IOC_COMPAT_PASS 254
66 #define ZFS_IOC_COMPAT_FAIL 255
68 #define ZFS_IOCREQ(ioreq) ((ioreq) & 0xff)
70 typedef struct zfs_iocparm {
71 uint32_t zfs_ioctl_version;
73 uint64_t zfs_cmd_size;
76 typedef struct zinject_record_v15 {
87 } zinject_record_v15_t;
89 typedef struct zfs_cmd_v15 {
90 char zc_name[MAXPATHLEN];
91 char zc_value[MAXPATHLEN];
92 char zc_string[MAXNAMELEN];
94 uint64_t zc_nvlist_conf; /* really (char *) */
95 uint64_t zc_nvlist_conf_size;
96 uint64_t zc_nvlist_src; /* really (char *) */
97 uint64_t zc_nvlist_src_size;
98 uint64_t zc_nvlist_dst; /* really (char *) */
99 uint64_t zc_nvlist_dst_size;
101 uint64_t zc_objset_type;
102 uint64_t zc_perm_action;
103 uint64_t zc_history; /* really (char *) */
104 uint64_t zc_history_len;
105 uint64_t zc_history_offset;
107 zfs_share_t zc_share;
109 dmu_objset_stats_t zc_objset_stats;
110 struct drr_begin zc_begin_record;
111 zinject_record_v15_t zc_inject_record;
114 typedef struct zinject_record_v28 {
124 uint32_t zi_failfast;
125 char zi_func[MAXNAMELEN];
129 } zinject_record_v28_t;
131 typedef struct zfs_cmd_v28 {
132 char zc_name[MAXPATHLEN];
133 char zc_value[MAXPATHLEN * 2];
134 char zc_string[MAXNAMELEN];
135 char zc_top_ds[MAXPATHLEN];
137 uint64_t zc_nvlist_conf; /* really (char *) */
138 uint64_t zc_nvlist_conf_size;
139 uint64_t zc_nvlist_src; /* really (char *) */
140 uint64_t zc_nvlist_src_size;
141 uint64_t zc_nvlist_dst; /* really (char *) */
142 uint64_t zc_nvlist_dst_size;
144 uint64_t zc_objset_type;
145 uint64_t zc_perm_action;
146 uint64_t zc_history; /* really (char *) */
147 uint64_t zc_history_len;
148 uint64_t zc_history_offset;
150 uint64_t zc_iflags; /* internal to zfs(7fs) */
151 zfs_share_t zc_share;
153 dmu_objset_stats_t zc_objset_stats;
154 struct drr_begin zc_begin_record;
155 zinject_record_v28_t zc_inject_record;
156 boolean_t zc_defer_destroy;
157 boolean_t zc_temphold;
158 uint64_t zc_action_handle;
161 uint8_t zc_pad[3]; /* alignment */
164 uint64_t zc_createtxg;
168 typedef struct zfs_cmd_deadman {
169 char zc_name[MAXPATHLEN];
170 char zc_value[MAXPATHLEN * 2];
171 char zc_string[MAXNAMELEN];
172 char zc_top_ds[MAXPATHLEN];
174 uint64_t zc_nvlist_conf; /* really (char *) */
175 uint64_t zc_nvlist_conf_size;
176 uint64_t zc_nvlist_src; /* really (char *) */
177 uint64_t zc_nvlist_src_size;
178 uint64_t zc_nvlist_dst; /* really (char *) */
179 uint64_t zc_nvlist_dst_size;
181 uint64_t zc_objset_type;
182 uint64_t zc_perm_action;
183 uint64_t zc_history; /* really (char *) */
184 uint64_t zc_history_len;
185 uint64_t zc_history_offset;
187 uint64_t zc_iflags; /* internal to zfs(7fs) */
188 zfs_share_t zc_share;
190 dmu_objset_stats_t zc_objset_stats;
191 struct drr_begin zc_begin_record;
192 /* zc_inject_record doesn't change in libzfs_core */
193 zinject_record_t zc_inject_record;
194 boolean_t zc_defer_destroy;
195 boolean_t zc_temphold;
196 uint64_t zc_action_handle;
199 uint8_t zc_pad[3]; /* alignment */
202 uint64_t zc_createtxg;
206 typedef struct zfs_cmd_zcmd {
207 char zc_name[MAXPATHLEN]; /* name of pool or dataset */
208 uint64_t zc_nvlist_src; /* really (char *) */
209 uint64_t zc_nvlist_src_size;
210 uint64_t zc_nvlist_dst; /* really (char *) */
211 uint64_t zc_nvlist_dst_size;
212 boolean_t zc_nvlist_dst_filled; /* put an nvlist in dst? */
216 * The following members are for legacy ioctls which haven't been
217 * converted to the new method.
219 uint64_t zc_history; /* really (char *) */
220 char zc_value[MAXPATHLEN * 2];
221 char zc_string[MAXNAMELEN];
223 uint64_t zc_nvlist_conf; /* really (char *) */
224 uint64_t zc_nvlist_conf_size;
226 uint64_t zc_objset_type;
227 uint64_t zc_perm_action;
228 uint64_t zc_history_len;
229 uint64_t zc_history_offset;
231 uint64_t zc_iflags; /* internal to zfs(7fs) */
232 zfs_share_t zc_share;
234 dmu_objset_stats_t zc_objset_stats;
235 struct drr_begin zc_begin_record;
236 zinject_record_t zc_inject_record;
237 boolean_t zc_defer_destroy;
238 boolean_t zc_temphold;
239 uint64_t zc_action_handle;
242 uint8_t zc_pad[3]; /* alignment */
245 uint64_t zc_createtxg;
250 unsigned static long zfs_ioctl_v15_to_v28[] = {
251 0, /* 0 ZFS_IOC_POOL_CREATE */
252 1, /* 1 ZFS_IOC_POOL_DESTROY */
253 2, /* 2 ZFS_IOC_POOL_IMPORT */
254 3, /* 3 ZFS_IOC_POOL_EXPORT */
255 4, /* 4 ZFS_IOC_POOL_CONFIGS */
256 5, /* 5 ZFS_IOC_POOL_STATS */
257 6, /* 6 ZFS_IOC_POOL_TRYIMPORT */
258 7, /* 7 ZFS_IOC_POOL_SCRUB */
259 8, /* 8 ZFS_IOC_POOL_FREEZE */
260 9, /* 9 ZFS_IOC_POOL_UPGRADE */
261 10, /* 10 ZFS_IOC_POOL_GET_HISTORY */
262 11, /* 11 ZFS_IOC_VDEV_ADD */
263 12, /* 12 ZFS_IOC_VDEV_REMOVE */
264 13, /* 13 ZFS_IOC_VDEV_SET_STATE */
265 14, /* 14 ZFS_IOC_VDEV_ATTACH */
266 15, /* 15 ZFS_IOC_VDEV_DETACH */
267 16, /* 16 ZFS_IOC_VDEV_SETPATH */
268 18, /* 17 ZFS_IOC_OBJSET_STATS */
269 19, /* 18 ZFS_IOC_OBJSET_ZPLPROPS */
270 20, /* 19 ZFS_IOC_DATASET_LIST_NEXT */
271 21, /* 20 ZFS_IOC_SNAPSHOT_LIST_NEXT */
272 22, /* 21 ZFS_IOC_SET_PROP */
273 ZFS_IOC_COMPAT_PASS, /* 22 ZFS_IOC_CREATE_MINOR */
274 ZFS_IOC_COMPAT_PASS, /* 23 ZFS_IOC_REMOVE_MINOR */
275 23, /* 24 ZFS_IOC_CREATE */
276 24, /* 25 ZFS_IOC_DESTROY */
277 25, /* 26 ZFS_IOC_ROLLBACK */
278 26, /* 27 ZFS_IOC_RENAME */
279 27, /* 28 ZFS_IOC_RECV */
280 28, /* 29 ZFS_IOC_SEND */
281 29, /* 30 ZFS_IOC_INJECT_FAULT */
282 30, /* 31 ZFS_IOC_CLEAR_FAULT */
283 31, /* 32 ZFS_IOC_INJECT_LIST_NEXT */
284 32, /* 33 ZFS_IOC_ERROR_LOG */
285 33, /* 34 ZFS_IOC_CLEAR */
286 34, /* 35 ZFS_IOC_PROMOTE */
287 35, /* 36 ZFS_IOC_DESTROY_SNAPS */
288 36, /* 37 ZFS_IOC_SNAPSHOT */
289 37, /* 38 ZFS_IOC_DSOBJ_TO_DSNAME */
290 38, /* 39 ZFS_IOC_OBJ_TO_PATH */
291 39, /* 40 ZFS_IOC_POOL_SET_PROPS */
292 40, /* 41 ZFS_IOC_POOL_GET_PROPS */
293 41, /* 42 ZFS_IOC_SET_FSACL */
294 42, /* 43 ZFS_IOC_GET_FSACL */
295 ZFS_IOC_COMPAT_PASS, /* 44 ZFS_IOC_ISCSI_PERM_CHECK */
296 43, /* 45 ZFS_IOC_SHARE */
297 44, /* 46 ZFS_IOC_IHNERIT_PROP */
298 58, /* 47 ZFS_IOC_JAIL */
299 59, /* 48 ZFS_IOC_UNJAIL */
300 45, /* 49 ZFS_IOC_SMB_ACL */
301 46, /* 50 ZFS_IOC_USERSPACE_ONE */
302 47, /* 51 ZFS_IOC_USERSPACE_MANY */
303 48, /* 52 ZFS_IOC_USERSPACE_UPGRADE */
304 17, /* 53 ZFS_IOC_SETFRU */
308 unsigned static long zfs_ioctl_v28_to_v15[] = {
309 0, /* 0 ZFS_IOC_POOL_CREATE */
310 1, /* 1 ZFS_IOC_POOL_DESTROY */
311 2, /* 2 ZFS_IOC_POOL_IMPORT */
312 3, /* 3 ZFS_IOC_POOL_EXPORT */
313 4, /* 4 ZFS_IOC_POOL_CONFIGS */
314 5, /* 5 ZFS_IOC_POOL_STATS */
315 6, /* 6 ZFS_IOC_POOL_TRYIMPORT */
316 7, /* 7 ZFS_IOC_POOL_SCAN */
317 8, /* 8 ZFS_IOC_POOL_FREEZE */
318 9, /* 9 ZFS_IOC_POOL_UPGRADE */
319 10, /* 10 ZFS_IOC_POOL_GET_HISTORY */
320 11, /* 11 ZFS_IOC_VDEV_ADD */
321 12, /* 12 ZFS_IOC_VDEV_REMOVE */
322 13, /* 13 ZFS_IOC_VDEV_SET_STATE */
323 14, /* 14 ZFS_IOC_VDEV_ATTACH */
324 15, /* 15 ZFS_IOC_VDEV_DETACH */
325 16, /* 16 ZFS_IOC_VDEV_SETPATH */
326 53, /* 17 ZFS_IOC_VDEV_SETFRU */
327 17, /* 18 ZFS_IOC_OBJSET_STATS */
328 18, /* 19 ZFS_IOC_OBJSET_ZPLPROPS */
329 19, /* 20 ZFS_IOC_DATASET_LIST_NEXT */
330 20, /* 21 ZFS_IOC_SNAPSHOT_LIST_NEXT */
331 21, /* 22 ZFS_IOC_SET_PROP */
332 24, /* 23 ZFS_IOC_CREATE */
333 25, /* 24 ZFS_IOC_DESTROY */
334 26, /* 25 ZFS_IOC_ROLLBACK */
335 27, /* 26 ZFS_IOC_RENAME */
336 28, /* 27 ZFS_IOC_RECV */
337 29, /* 28 ZFS_IOC_SEND */
338 30, /* 39 ZFS_IOC_INJECT_FAULT */
339 31, /* 30 ZFS_IOC_CLEAR_FAULT */
340 32, /* 31 ZFS_IOC_INJECT_LIST_NEXT */
341 33, /* 32 ZFS_IOC_ERROR_LOG */
342 34, /* 33 ZFS_IOC_CLEAR */
343 35, /* 34 ZFS_IOC_PROMOTE */
344 36, /* 35 ZFS_IOC_DESTROY_SNAPS */
345 37, /* 36 ZFS_IOC_SNAPSHOT */
346 38, /* 37 ZFS_IOC_DSOBJ_TO_DSNAME */
347 39, /* 38 ZFS_IOC_OBJ_TO_PATH */
348 40, /* 39 ZFS_IOC_POOL_SET_PROPS */
349 41, /* 40 ZFS_IOC_POOL_GET_PROPS */
350 42, /* 41 ZFS_IOC_SET_FSACL */
351 43, /* 42 ZFS_IOC_GET_FSACL */
352 45, /* 43 ZFS_IOC_SHARE */
353 46, /* 44 ZFS_IOC_IHNERIT_PROP */
354 49, /* 45 ZFS_IOC_SMB_ACL */
355 50, /* 46 ZFS_IOC_USERSPACE_ONE */
356 51, /* 47 ZFS_IOC_USERSPACE_MANY */
357 52, /* 48 ZFS_IOC_USERSPACE_UPGRADE */
358 ZFS_IOC_COMPAT_FAIL, /* 49 ZFS_IOC_HOLD */
359 ZFS_IOC_COMPAT_FAIL, /* 50 ZFS_IOC_RELEASE */
360 ZFS_IOC_COMPAT_FAIL, /* 51 ZFS_IOC_GET_HOLDS */
361 ZFS_IOC_COMPAT_FAIL, /* 52 ZFS_IOC_OBJSET_RECVD_PROPS */
362 ZFS_IOC_COMPAT_FAIL, /* 53 ZFS_IOC_VDEV_SPLIT */
363 ZFS_IOC_COMPAT_FAIL, /* 54 ZFS_IOC_NEXT_OBJ */
364 ZFS_IOC_COMPAT_FAIL, /* 55 ZFS_IOC_DIFF */
365 ZFS_IOC_COMPAT_FAIL, /* 56 ZFS_IOC_TMP_SNAPSHOT */
366 ZFS_IOC_COMPAT_FAIL, /* 57 ZFS_IOC_OBJ_TO_STATS */
367 47, /* 58 ZFS_IOC_JAIL */
368 48, /* 59 ZFS_IOC_UNJAIL */
370 #endif /* ! _KERNEL */
373 int zfs_ioctl_compat_pre(zfs_cmd_t *, int *, const int);
374 void zfs_ioctl_compat_post(zfs_cmd_t *, const int, const int);
375 nvlist_t *zfs_ioctl_compat_innvl(zfs_cmd_t *, nvlist_t *, const int,
377 nvlist_t *zfs_ioctl_compat_outnvl(zfs_cmd_t *, nvlist_t *, const int,
380 int zcmd_ioctl_compat(int, int, zfs_cmd_t *, const int);
382 void zfs_cmd_compat_get(zfs_cmd_t *, caddr_t, const int);
383 void zfs_cmd_compat_put(zfs_cmd_t *, caddr_t, const int, const int);
389 #endif /* _SYS_ZFS_IOCTL_COMPAT_H */