]> git.proxmox.com Git - mirror_zfs.git/blob - include/os/freebsd/zfs/sys/zfs_ioctl_compat.h
FreeBSD: zfs commands backward compatibility
[mirror_zfs.git] / include / os / freebsd / zfs / sys / zfs_ioctl_compat.h
1 /*
2 * CDDL HEADER START
3 *
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.
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21 /*
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.
25 */
26
27 #ifndef _SYS_ZFS_IOCTL_COMPAT_H
28 #define _SYS_ZFS_IOCTL_COMPAT_H
29
30 #include <sys/cred.h>
31 #include <sys/dmu.h>
32 #include <sys/zio.h>
33 #include <sys/dsl_deleg.h>
34 #include <sys/zfs_ioctl.h>
35
36 #ifdef _KERNEL
37 #include <sys/nvpair.h>
38 #endif /* _KERNEL */
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43
44 /*
45 * Backwards ioctl compatibility
46 */
47
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
60
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
72
73 #define ZFS_IOC_COMPAT_PASS 254
74 #define ZFS_IOC_COMPAT_FAIL 255
75
76 #define ZFS_IOCREQ(ioreq) ((ioreq) & 0xff)
77
78 typedef struct zfs_iocparm {
79 uint32_t zfs_ioctl_version;
80 uint64_t zfs_cmd;
81 uint64_t zfs_cmd_size;
82 } zfs_iocparm_t;
83
84
85 #define LEGACY_MAXPATHLEN 1024
86 #define LEGACY_MAXNAMELEN 256
87
88 /*
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).
93 */
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? */
101 int zc_pad2;
102
103 /*
104 * The following members are for legacy ioctls which haven't been
105 * converted to the new method.
106 */
107 uint64_t zc_history; /* really (char *) */
108 char zc_value[LEGACY_MAXPATHLEN * 2];
109 char zc_string[LEGACY_MAXNAMELEN];
110 uint64_t zc_guid;
111 uint64_t zc_nvlist_conf; /* really (char *) */
112 uint64_t zc_nvlist_conf_size;
113 uint64_t zc_cookie;
114 uint64_t zc_objset_type;
115 uint64_t zc_perm_action;
116 uint64_t zc_history_len;
117 uint64_t zc_history_offset;
118 uint64_t zc_obj;
119 uint64_t zc_iflags; /* internal to zfs(7fs) */
120 zfs_share_t zc_share;
121 uint64_t zc_jailid;
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;
126 uint32_t zc_flags;
127 uint64_t zc_action_handle;
128 int zc_cleanup_fd;
129 uint8_t zc_simple;
130 uint8_t zc_pad3[3];
131 boolean_t zc_resumable;
132 uint32_t zc_pad4;
133 uint64_t zc_sendobj;
134 uint64_t zc_fromobj;
135 uint64_t zc_createtxg;
136 zfs_stat_t zc_stat;
137 } zfs_cmd_legacy_t;
138
139
140 #ifdef _KERNEL
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,
144 const int);
145 nvlist_t *zfs_ioctl_compat_outnvl(zfs_cmd_t *, nvlist_t *, const int,
146 const int);
147 #endif /* _KERNEL */
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);
153
154 void zfs_cmd_compat_put(zfs_cmd_t *, caddr_t, const int, const int);
155
156 #ifdef __cplusplus
157 }
158 #endif
159
160 #endif /* _SYS_ZFS_IOCTL_COMPAT_H */