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_LEGACY ZFS_IOCVER_PAD
59 #define ZFS_IOCVER_OZFS 15
61 /* compatibility conversion flag */
62 #define ZFS_CMD_COMPAT_NONE 0
63 #define ZFS_CMD_COMPAT_V15 1
64 #define ZFS_CMD_COMPAT_V28 2
65 #define ZFS_CMD_COMPAT_DEADMAN 3
66 #define ZFS_CMD_COMPAT_LZC 4
67 #define ZFS_CMD_COMPAT_ZCMD 5
68 #define ZFS_CMD_COMPAT_EDBP 6
69 #define ZFS_CMD_COMPAT_RESUME 7
70 #define ZFS_CMD_COMPAT_INLANES 8
71 #define ZFS_CMD_COMPAT_LEGACY 9
73 #define ZFS_IOC_COMPAT_PASS 254
74 #define ZFS_IOC_COMPAT_FAIL 255
76 #define ZFS_IOCREQ(ioreq) ((ioreq) & 0xff)
78 typedef struct zfs_iocparm
{
79 uint32_t zfs_ioctl_version
;
81 uint64_t zfs_cmd_size
;
85 #define LEGACY_MAXPATHLEN 1024
86 #define LEGACY_MAXNAMELEN 256
89 * Note: this struct must have the same layout in 32-bit and 64-bit, so
90 * that 32-bit processes (like /sbin/zfs) can pass it to the 64-bit
91 * kernel. Therefore, we add padding to it so that no "hidden" padding
92 * is automatically added on 64-bit (but not on 32-bit).
94 typedef struct zfs_cmd_legacy
{
95 char zc_name
[LEGACY_MAXPATHLEN
]; /* pool|dataset name */
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
;
100 boolean_t zc_nvlist_dst_filled
; /* put an nvlist in dst? */
104 * The following members are for legacy ioctls which haven't been
105 * converted to the new method.
107 uint64_t zc_history
; /* really (char *) */
108 char zc_value
[LEGACY_MAXPATHLEN
* 2];
109 char zc_string
[LEGACY_MAXNAMELEN
];
111 uint64_t zc_nvlist_conf
; /* really (char *) */
112 uint64_t zc_nvlist_conf_size
;
114 uint64_t zc_objset_type
;
115 uint64_t zc_perm_action
;
116 uint64_t zc_history_len
;
117 uint64_t zc_history_offset
;
119 uint64_t zc_iflags
; /* internal to zfs(7fs) */
120 zfs_share_t zc_share
;
122 dmu_objset_stats_t zc_objset_stats
;
123 dmu_replay_record_t zc_begin_record
;
124 zinject_record_t zc_inject_record
;
125 uint32_t zc_defer_destroy
;
127 uint64_t zc_action_handle
;
131 boolean_t zc_resumable
;
135 uint64_t zc_createtxg
;
141 int zfs_ioctl_compat_pre(zfs_cmd_t
*, int *, const int);
142 void zfs_ioctl_compat_post(zfs_cmd_t
*, const int, const int);
143 nvlist_t
*zfs_ioctl_compat_innvl(zfs_cmd_t
*, nvlist_t
*, const int,
145 nvlist_t
*zfs_ioctl_compat_outnvl(zfs_cmd_t
*, nvlist_t
*, const int,
148 int zfs_ioctl_legacy_to_ozfs(int request
);
149 int zfs_ioctl_ozfs_to_legacy(int request
);
150 void zfs_cmd_legacy_to_ozfs(zfs_cmd_legacy_t
*src
, zfs_cmd_t
*dst
);
151 void zfs_cmd_compat_get(zfs_cmd_t
*, caddr_t
, const int);
152 void zfs_cmd_ozfs_to_legacy(zfs_cmd_t
*src
, zfs_cmd_legacy_t
*dst
);
154 void zfs_cmd_compat_put(zfs_cmd_t
*, caddr_t
, const int, const int);
160 #endif /* _SYS_ZFS_IOCTL_COMPAT_H */