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_CURRENT ZFS_IOCVER_RESUME
58 /* compatibility conversion flag */
59 #define ZFS_CMD_COMPAT_NONE 0
60 #define ZFS_CMD_COMPAT_V15 1
61 #define ZFS_CMD_COMPAT_V28 2
62 #define ZFS_CMD_COMPAT_DEADMAN 3
63 #define ZFS_CMD_COMPAT_LZC 4
64 #define ZFS_CMD_COMPAT_ZCMD 5
65 #define ZFS_CMD_COMPAT_EDBP 6
67 #define ZFS_IOC_COMPAT_PASS 254
68 #define ZFS_IOC_COMPAT_FAIL 255
70 #define ZFS_IOCREQ(ioreq) ((ioreq) & 0xff)
72 typedef struct zfs_iocparm {
73 uint32_t zfs_ioctl_version;
75 uint64_t zfs_cmd_size;
78 typedef struct zinject_record_v15 {
89 } zinject_record_v15_t;
91 typedef struct zfs_cmd_v15 {
92 char zc_name[MAXPATHLEN];
93 char zc_value[MAXPATHLEN];
94 char zc_string[MAXNAMELEN];
96 uint64_t zc_nvlist_conf; /* really (char *) */
97 uint64_t zc_nvlist_conf_size;
98 uint64_t zc_nvlist_src; /* really (char *) */
99 uint64_t zc_nvlist_src_size;
100 uint64_t zc_nvlist_dst; /* really (char *) */
101 uint64_t zc_nvlist_dst_size;
103 uint64_t zc_objset_type;
104 uint64_t zc_perm_action;
105 uint64_t zc_history; /* really (char *) */
106 uint64_t zc_history_len;
107 uint64_t zc_history_offset;
109 zfs_share_t zc_share;
111 dmu_objset_stats_t zc_objset_stats;
112 struct drr_begin zc_begin_record;
113 zinject_record_v15_t zc_inject_record;
116 typedef struct zinject_record_v28 {
126 uint32_t zi_failfast;
127 char zi_func[MAXNAMELEN];
131 } zinject_record_v28_t;
133 typedef struct zfs_cmd_v28 {
134 char zc_name[MAXPATHLEN];
135 char zc_value[MAXPATHLEN * 2];
136 char zc_string[MAXNAMELEN];
137 char zc_top_ds[MAXPATHLEN];
139 uint64_t zc_nvlist_conf; /* really (char *) */
140 uint64_t zc_nvlist_conf_size;
141 uint64_t zc_nvlist_src; /* really (char *) */
142 uint64_t zc_nvlist_src_size;
143 uint64_t zc_nvlist_dst; /* really (char *) */
144 uint64_t zc_nvlist_dst_size;
146 uint64_t zc_objset_type;
147 uint64_t zc_perm_action;
148 uint64_t zc_history; /* really (char *) */
149 uint64_t zc_history_len;
150 uint64_t zc_history_offset;
152 uint64_t zc_iflags; /* internal to zfs(7fs) */
153 zfs_share_t zc_share;
155 dmu_objset_stats_t zc_objset_stats;
156 struct drr_begin zc_begin_record;
157 zinject_record_v28_t zc_inject_record;
158 boolean_t zc_defer_destroy;
159 boolean_t zc_temphold;
160 uint64_t zc_action_handle;
163 uint8_t zc_pad[3]; /* alignment */
166 uint64_t zc_createtxg;
170 typedef struct zfs_cmd_deadman {
171 char zc_name[MAXPATHLEN];
172 char zc_value[MAXPATHLEN * 2];
173 char zc_string[MAXNAMELEN];
174 char zc_top_ds[MAXPATHLEN];
176 uint64_t zc_nvlist_conf; /* really (char *) */
177 uint64_t zc_nvlist_conf_size;
178 uint64_t zc_nvlist_src; /* really (char *) */
179 uint64_t zc_nvlist_src_size;
180 uint64_t zc_nvlist_dst; /* really (char *) */
181 uint64_t zc_nvlist_dst_size;
183 uint64_t zc_objset_type;
184 uint64_t zc_perm_action;
185 uint64_t zc_history; /* really (char *) */
186 uint64_t zc_history_len;
187 uint64_t zc_history_offset;
189 uint64_t zc_iflags; /* internal to zfs(7fs) */
190 zfs_share_t zc_share;
192 dmu_objset_stats_t zc_objset_stats;
193 struct drr_begin zc_begin_record;
194 /* zc_inject_record doesn't change in libzfs_core */
195 zinject_record_t zc_inject_record;
196 boolean_t zc_defer_destroy;
197 boolean_t zc_temphold;
198 uint64_t zc_action_handle;
201 uint8_t zc_pad[3]; /* alignment */
204 uint64_t zc_createtxg;
208 typedef struct zfs_cmd_zcmd {
209 char zc_name[MAXPATHLEN]; /* name of pool or dataset */
210 uint64_t zc_nvlist_src; /* really (char *) */
211 uint64_t zc_nvlist_src_size;
212 uint64_t zc_nvlist_dst; /* really (char *) */
213 uint64_t zc_nvlist_dst_size;
214 boolean_t zc_nvlist_dst_filled; /* put an nvlist in dst? */
218 * The following members are for legacy ioctls which haven't been
219 * converted to the new method.
221 uint64_t zc_history; /* really (char *) */
222 char zc_value[MAXPATHLEN * 2];
223 char zc_string[MAXNAMELEN];
225 uint64_t zc_nvlist_conf; /* really (char *) */
226 uint64_t zc_nvlist_conf_size;
228 uint64_t zc_objset_type;
229 uint64_t zc_perm_action;
230 uint64_t zc_history_len;
231 uint64_t zc_history_offset;
233 uint64_t zc_iflags; /* internal to zfs(7fs) */
234 zfs_share_t zc_share;
236 dmu_objset_stats_t zc_objset_stats;
237 struct drr_begin zc_begin_record;
238 zinject_record_t zc_inject_record;
239 boolean_t zc_defer_destroy;
240 boolean_t zc_temphold;
241 uint64_t zc_action_handle;
244 uint8_t zc_pad[3]; /* alignment */
247 uint64_t zc_createtxg;
251 typedef struct zfs_cmd_edbp {
252 char zc_name[MAXPATHLEN]; /* name of pool or dataset */
253 uint64_t zc_nvlist_src; /* really (char *) */
254 uint64_t zc_nvlist_src_size;
255 uint64_t zc_nvlist_dst; /* really (char *) */
256 uint64_t zc_nvlist_dst_size;
257 boolean_t zc_nvlist_dst_filled; /* put an nvlist in dst? */
261 * The following members are for legacy ioctls which haven't been
262 * converted to the new method.
264 uint64_t zc_history; /* really (char *) */
265 char zc_value[MAXPATHLEN * 2];
266 char zc_string[MAXNAMELEN];
268 uint64_t zc_nvlist_conf; /* really (char *) */
269 uint64_t zc_nvlist_conf_size;
271 uint64_t zc_objset_type;
272 uint64_t zc_perm_action;
273 uint64_t zc_history_len;
274 uint64_t zc_history_offset;
276 uint64_t zc_iflags; /* internal to zfs(7fs) */
277 zfs_share_t zc_share;
279 dmu_objset_stats_t zc_objset_stats;
280 struct drr_begin zc_begin_record;
281 zinject_record_t zc_inject_record;
282 uint32_t zc_defer_destroy;
284 uint64_t zc_action_handle;
287 uint8_t zc_pad[3]; /* alignment */
290 uint64_t zc_createtxg;
295 unsigned static long zfs_ioctl_v15_to_v28[] = {
296 0, /* 0 ZFS_IOC_POOL_CREATE */
297 1, /* 1 ZFS_IOC_POOL_DESTROY */
298 2, /* 2 ZFS_IOC_POOL_IMPORT */
299 3, /* 3 ZFS_IOC_POOL_EXPORT */
300 4, /* 4 ZFS_IOC_POOL_CONFIGS */
301 5, /* 5 ZFS_IOC_POOL_STATS */
302 6, /* 6 ZFS_IOC_POOL_TRYIMPORT */
303 7, /* 7 ZFS_IOC_POOL_SCRUB */
304 8, /* 8 ZFS_IOC_POOL_FREEZE */
305 9, /* 9 ZFS_IOC_POOL_UPGRADE */
306 10, /* 10 ZFS_IOC_POOL_GET_HISTORY */
307 11, /* 11 ZFS_IOC_VDEV_ADD */
308 12, /* 12 ZFS_IOC_VDEV_REMOVE */
309 13, /* 13 ZFS_IOC_VDEV_SET_STATE */
310 14, /* 14 ZFS_IOC_VDEV_ATTACH */
311 15, /* 15 ZFS_IOC_VDEV_DETACH */
312 16, /* 16 ZFS_IOC_VDEV_SETPATH */
313 18, /* 17 ZFS_IOC_OBJSET_STATS */
314 19, /* 18 ZFS_IOC_OBJSET_ZPLPROPS */
315 20, /* 19 ZFS_IOC_DATASET_LIST_NEXT */
316 21, /* 20 ZFS_IOC_SNAPSHOT_LIST_NEXT */
317 22, /* 21 ZFS_IOC_SET_PROP */
318 ZFS_IOC_COMPAT_PASS, /* 22 ZFS_IOC_CREATE_MINOR */
319 ZFS_IOC_COMPAT_PASS, /* 23 ZFS_IOC_REMOVE_MINOR */
320 23, /* 24 ZFS_IOC_CREATE */
321 24, /* 25 ZFS_IOC_DESTROY */
322 25, /* 26 ZFS_IOC_ROLLBACK */
323 26, /* 27 ZFS_IOC_RENAME */
324 27, /* 28 ZFS_IOC_RECV */
325 28, /* 29 ZFS_IOC_SEND */
326 29, /* 30 ZFS_IOC_INJECT_FAULT */
327 30, /* 31 ZFS_IOC_CLEAR_FAULT */
328 31, /* 32 ZFS_IOC_INJECT_LIST_NEXT */
329 32, /* 33 ZFS_IOC_ERROR_LOG */
330 33, /* 34 ZFS_IOC_CLEAR */
331 34, /* 35 ZFS_IOC_PROMOTE */
332 35, /* 36 ZFS_IOC_DESTROY_SNAPS */
333 36, /* 37 ZFS_IOC_SNAPSHOT */
334 37, /* 38 ZFS_IOC_DSOBJ_TO_DSNAME */
335 38, /* 39 ZFS_IOC_OBJ_TO_PATH */
336 39, /* 40 ZFS_IOC_POOL_SET_PROPS */
337 40, /* 41 ZFS_IOC_POOL_GET_PROPS */
338 41, /* 42 ZFS_IOC_SET_FSACL */
339 42, /* 43 ZFS_IOC_GET_FSACL */
340 ZFS_IOC_COMPAT_PASS, /* 44 ZFS_IOC_ISCSI_PERM_CHECK */
341 43, /* 45 ZFS_IOC_SHARE */
342 44, /* 46 ZFS_IOC_IHNERIT_PROP */
343 58, /* 47 ZFS_IOC_JAIL */
344 59, /* 48 ZFS_IOC_UNJAIL */
345 45, /* 49 ZFS_IOC_SMB_ACL */
346 46, /* 50 ZFS_IOC_USERSPACE_ONE */
347 47, /* 51 ZFS_IOC_USERSPACE_MANY */
348 48, /* 52 ZFS_IOC_USERSPACE_UPGRADE */
349 17, /* 53 ZFS_IOC_SETFRU */
353 unsigned static long zfs_ioctl_v28_to_v15[] = {
354 0, /* 0 ZFS_IOC_POOL_CREATE */
355 1, /* 1 ZFS_IOC_POOL_DESTROY */
356 2, /* 2 ZFS_IOC_POOL_IMPORT */
357 3, /* 3 ZFS_IOC_POOL_EXPORT */
358 4, /* 4 ZFS_IOC_POOL_CONFIGS */
359 5, /* 5 ZFS_IOC_POOL_STATS */
360 6, /* 6 ZFS_IOC_POOL_TRYIMPORT */
361 7, /* 7 ZFS_IOC_POOL_SCAN */
362 8, /* 8 ZFS_IOC_POOL_FREEZE */
363 9, /* 9 ZFS_IOC_POOL_UPGRADE */
364 10, /* 10 ZFS_IOC_POOL_GET_HISTORY */
365 11, /* 11 ZFS_IOC_VDEV_ADD */
366 12, /* 12 ZFS_IOC_VDEV_REMOVE */
367 13, /* 13 ZFS_IOC_VDEV_SET_STATE */
368 14, /* 14 ZFS_IOC_VDEV_ATTACH */
369 15, /* 15 ZFS_IOC_VDEV_DETACH */
370 16, /* 16 ZFS_IOC_VDEV_SETPATH */
371 53, /* 17 ZFS_IOC_VDEV_SETFRU */
372 17, /* 18 ZFS_IOC_OBJSET_STATS */
373 18, /* 19 ZFS_IOC_OBJSET_ZPLPROPS */
374 19, /* 20 ZFS_IOC_DATASET_LIST_NEXT */
375 20, /* 21 ZFS_IOC_SNAPSHOT_LIST_NEXT */
376 21, /* 22 ZFS_IOC_SET_PROP */
377 24, /* 23 ZFS_IOC_CREATE */
378 25, /* 24 ZFS_IOC_DESTROY */
379 26, /* 25 ZFS_IOC_ROLLBACK */
380 27, /* 26 ZFS_IOC_RENAME */
381 28, /* 27 ZFS_IOC_RECV */
382 29, /* 28 ZFS_IOC_SEND */
383 30, /* 39 ZFS_IOC_INJECT_FAULT */
384 31, /* 30 ZFS_IOC_CLEAR_FAULT */
385 32, /* 31 ZFS_IOC_INJECT_LIST_NEXT */
386 33, /* 32 ZFS_IOC_ERROR_LOG */
387 34, /* 33 ZFS_IOC_CLEAR */
388 35, /* 34 ZFS_IOC_PROMOTE */
389 36, /* 35 ZFS_IOC_DESTROY_SNAPS */
390 37, /* 36 ZFS_IOC_SNAPSHOT */
391 38, /* 37 ZFS_IOC_DSOBJ_TO_DSNAME */
392 39, /* 38 ZFS_IOC_OBJ_TO_PATH */
393 40, /* 39 ZFS_IOC_POOL_SET_PROPS */
394 41, /* 40 ZFS_IOC_POOL_GET_PROPS */
395 42, /* 41 ZFS_IOC_SET_FSACL */
396 43, /* 42 ZFS_IOC_GET_FSACL */
397 45, /* 43 ZFS_IOC_SHARE */
398 46, /* 44 ZFS_IOC_IHNERIT_PROP */
399 49, /* 45 ZFS_IOC_SMB_ACL */
400 50, /* 46 ZFS_IOC_USERSPACE_ONE */
401 51, /* 47 ZFS_IOC_USERSPACE_MANY */
402 52, /* 48 ZFS_IOC_USERSPACE_UPGRADE */
403 ZFS_IOC_COMPAT_FAIL, /* 49 ZFS_IOC_HOLD */
404 ZFS_IOC_COMPAT_FAIL, /* 50 ZFS_IOC_RELEASE */
405 ZFS_IOC_COMPAT_FAIL, /* 51 ZFS_IOC_GET_HOLDS */
406 ZFS_IOC_COMPAT_FAIL, /* 52 ZFS_IOC_OBJSET_RECVD_PROPS */
407 ZFS_IOC_COMPAT_FAIL, /* 53 ZFS_IOC_VDEV_SPLIT */
408 ZFS_IOC_COMPAT_FAIL, /* 54 ZFS_IOC_NEXT_OBJ */
409 ZFS_IOC_COMPAT_FAIL, /* 55 ZFS_IOC_DIFF */
410 ZFS_IOC_COMPAT_FAIL, /* 56 ZFS_IOC_TMP_SNAPSHOT */
411 ZFS_IOC_COMPAT_FAIL, /* 57 ZFS_IOC_OBJ_TO_STATS */
412 47, /* 58 ZFS_IOC_JAIL */
413 48, /* 59 ZFS_IOC_UNJAIL */
415 #endif /* ! _KERNEL */
418 int zfs_ioctl_compat_pre(zfs_cmd_t *, int *, const int);
419 void zfs_ioctl_compat_post(zfs_cmd_t *, const int, const int);
420 nvlist_t *zfs_ioctl_compat_innvl(zfs_cmd_t *, nvlist_t *, const int,
422 nvlist_t *zfs_ioctl_compat_outnvl(zfs_cmd_t *, nvlist_t *, const int,
425 int zcmd_ioctl_compat(int, int, zfs_cmd_t *, const int);
427 void zfs_cmd_compat_get(zfs_cmd_t *, caddr_t, const int);
428 void zfs_cmd_compat_put(zfs_cmd_t *, caddr_t, const int, const int);
434 #endif /* _SYS_ZFS_IOCTL_COMPAT_H */