]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / cddl / contrib / opensolaris / common / zfs / 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 2013 Martin Matuska <mm@FreeBSD.org>.  All rights reserved.
23  * Use is subject to license terms.
24  */
25
26 #ifndef _SYS_ZFS_IOCTL_COMPAT_H
27 #define _SYS_ZFS_IOCTL_COMPAT_H
28
29 #include <sys/cred.h>
30 #include <sys/dmu.h>
31 #include <sys/zio.h>
32 #include <sys/dsl_deleg.h>
33 #include <sys/zfs_ioctl.h>
34
35 #ifdef _KERNEL
36 #include <sys/nvpair.h>
37 #endif  /* _KERNEL */
38
39 #ifdef  __cplusplus
40 extern "C" {
41 #endif
42
43 /*
44  * Backwards ioctl compatibility
45  */
46
47 /* ioctl versions for vfs.zfs.version.ioctl */
48 #define ZFS_IOCVER_UNDEF        -1
49 #define ZFS_IOCVER_NONE         0
50 #define ZFS_IOCVER_DEADMAN      1
51 #define ZFS_IOCVER_LZC          2
52 #define ZFS_IOCVER_ZCMD         3
53 #define ZFS_IOCVER_CURRENT      ZFS_IOCVER_ZCMD
54
55 /* compatibility conversion flag */
56 #define ZFS_CMD_COMPAT_NONE     0
57 #define ZFS_CMD_COMPAT_V15      1
58 #define ZFS_CMD_COMPAT_V28      2
59 #define ZFS_CMD_COMPAT_DEADMAN  3
60 #define ZFS_CMD_COMPAT_LZC      4
61
62 #define ZFS_IOC_COMPAT_PASS     254
63 #define ZFS_IOC_COMPAT_FAIL     255
64
65 #define ZFS_IOCREQ(ioreq)       ((ioreq) & 0xff)
66
67 typedef struct zfs_iocparm {
68         uint32_t        zfs_ioctl_version;
69         uint64_t        zfs_cmd;
70         uint64_t        zfs_cmd_size;
71 } zfs_iocparm_t;
72
73 typedef struct zinject_record_v15 {
74         uint64_t        zi_objset;
75         uint64_t        zi_object;
76         uint64_t        zi_start;
77         uint64_t        zi_end;
78         uint64_t        zi_guid;
79         uint32_t        zi_level;
80         uint32_t        zi_error;
81         uint64_t        zi_type;
82         uint32_t        zi_freq;
83         uint32_t        zi_failfast;
84 } zinject_record_v15_t;
85
86 typedef struct zfs_cmd_v15 {
87         char            zc_name[MAXPATHLEN];
88         char            zc_value[MAXPATHLEN];
89         char            zc_string[MAXNAMELEN];
90         uint64_t        zc_guid;
91         uint64_t        zc_nvlist_conf;         /* really (char *) */
92         uint64_t        zc_nvlist_conf_size;
93         uint64_t        zc_nvlist_src;          /* really (char *) */
94         uint64_t        zc_nvlist_src_size;
95         uint64_t        zc_nvlist_dst;          /* really (char *) */
96         uint64_t        zc_nvlist_dst_size;
97         uint64_t        zc_cookie;
98         uint64_t        zc_objset_type;
99         uint64_t        zc_perm_action;
100         uint64_t        zc_history;             /* really (char *) */
101         uint64_t        zc_history_len;
102         uint64_t        zc_history_offset;
103         uint64_t        zc_obj;
104         zfs_share_t     zc_share;
105         uint64_t        zc_jailid;
106         dmu_objset_stats_t zc_objset_stats;
107         struct drr_begin zc_begin_record;
108         zinject_record_v15_t zc_inject_record;
109 } zfs_cmd_v15_t;
110
111 typedef struct zinject_record_v28 {
112         uint64_t        zi_objset;
113         uint64_t        zi_object;
114         uint64_t        zi_start;
115         uint64_t        zi_end;
116         uint64_t        zi_guid;
117         uint32_t        zi_level;
118         uint32_t        zi_error;
119         uint64_t        zi_type;
120         uint32_t        zi_freq;
121         uint32_t        zi_failfast;
122         char            zi_func[MAXNAMELEN];
123         uint32_t        zi_iotype;
124         int32_t         zi_duration;
125         uint64_t        zi_timer;
126 } zinject_record_v28_t;
127
128 typedef struct zfs_cmd_v28 {
129         char            zc_name[MAXPATHLEN];
130         char            zc_value[MAXPATHLEN * 2];
131         char            zc_string[MAXNAMELEN];
132         char            zc_top_ds[MAXPATHLEN];
133         uint64_t        zc_guid;
134         uint64_t        zc_nvlist_conf;         /* really (char *) */
135         uint64_t        zc_nvlist_conf_size;
136         uint64_t        zc_nvlist_src;          /* really (char *) */
137         uint64_t        zc_nvlist_src_size;
138         uint64_t        zc_nvlist_dst;          /* really (char *) */
139         uint64_t        zc_nvlist_dst_size;
140         uint64_t        zc_cookie;
141         uint64_t        zc_objset_type;
142         uint64_t        zc_perm_action;
143         uint64_t        zc_history;             /* really (char *) */
144         uint64_t        zc_history_len;
145         uint64_t        zc_history_offset;
146         uint64_t        zc_obj;
147         uint64_t        zc_iflags;              /* internal to zfs(7fs) */
148         zfs_share_t     zc_share;
149         uint64_t        zc_jailid;
150         dmu_objset_stats_t zc_objset_stats;
151         struct drr_begin zc_begin_record;
152         zinject_record_v28_t zc_inject_record;
153         boolean_t       zc_defer_destroy;
154         boolean_t       zc_temphold;
155         uint64_t        zc_action_handle;
156         int             zc_cleanup_fd;
157         uint8_t         zc_simple;
158         uint8_t         zc_pad[3];              /* alignment */
159         uint64_t        zc_sendobj;
160         uint64_t        zc_fromobj;
161         uint64_t        zc_createtxg;
162         zfs_stat_t      zc_stat;
163 } zfs_cmd_v28_t;
164
165 typedef struct zfs_cmd_deadman {
166         char            zc_name[MAXPATHLEN];
167         char            zc_value[MAXPATHLEN * 2];
168         char            zc_string[MAXNAMELEN];
169         char            zc_top_ds[MAXPATHLEN];
170         uint64_t        zc_guid;
171         uint64_t        zc_nvlist_conf;         /* really (char *) */
172         uint64_t        zc_nvlist_conf_size;
173         uint64_t        zc_nvlist_src;          /* really (char *) */
174         uint64_t        zc_nvlist_src_size;
175         uint64_t        zc_nvlist_dst;          /* really (char *) */
176         uint64_t        zc_nvlist_dst_size;
177         uint64_t        zc_cookie;
178         uint64_t        zc_objset_type;
179         uint64_t        zc_perm_action;
180         uint64_t        zc_history;             /* really (char *) */
181         uint64_t        zc_history_len;
182         uint64_t        zc_history_offset;
183         uint64_t        zc_obj;
184         uint64_t        zc_iflags;              /* internal to zfs(7fs) */
185         zfs_share_t     zc_share;
186         uint64_t        zc_jailid;
187         dmu_objset_stats_t zc_objset_stats;
188         struct drr_begin zc_begin_record;
189         /* zc_inject_record doesn't change in libzfs_core */
190         zinject_record_t zc_inject_record;
191         boolean_t       zc_defer_destroy;
192         boolean_t       zc_temphold;
193         uint64_t        zc_action_handle;
194         int             zc_cleanup_fd;
195         uint8_t         zc_simple;
196         uint8_t         zc_pad[3];              /* alignment */
197         uint64_t        zc_sendobj;
198         uint64_t        zc_fromobj;
199         uint64_t        zc_createtxg;
200         zfs_stat_t      zc_stat;
201 } zfs_cmd_deadman_t;
202
203 #ifdef _KERNEL
204 unsigned static long zfs_ioctl_v15_to_v28[] = {
205         0,      /*  0 ZFS_IOC_POOL_CREATE */
206         1,      /*  1 ZFS_IOC_POOL_DESTROY */
207         2,      /*  2 ZFS_IOC_POOL_IMPORT */
208         3,      /*  3 ZFS_IOC_POOL_EXPORT */
209         4,      /*  4 ZFS_IOC_POOL_CONFIGS */
210         5,      /*  5 ZFS_IOC_POOL_STATS */
211         6,      /*  6 ZFS_IOC_POOL_TRYIMPORT */
212         7,      /*  7 ZFS_IOC_POOL_SCRUB */
213         8,      /*  8 ZFS_IOC_POOL_FREEZE */
214         9,      /*  9 ZFS_IOC_POOL_UPGRADE */
215         10,     /* 10 ZFS_IOC_POOL_GET_HISTORY */
216         11,     /* 11 ZFS_IOC_VDEV_ADD */
217         12,     /* 12 ZFS_IOC_VDEV_REMOVE */
218         13,     /* 13 ZFS_IOC_VDEV_SET_STATE */
219         14,     /* 14 ZFS_IOC_VDEV_ATTACH */
220         15,     /* 15 ZFS_IOC_VDEV_DETACH */
221         16,     /* 16 ZFS_IOC_VDEV_SETPATH */
222         18,     /* 17 ZFS_IOC_OBJSET_STATS */
223         19,     /* 18 ZFS_IOC_OBJSET_ZPLPROPS */
224         20,     /* 19 ZFS_IOC_DATASET_LIST_NEXT */
225         21,     /* 20 ZFS_IOC_SNAPSHOT_LIST_NEXT */
226         22,     /* 21 ZFS_IOC_SET_PROP */
227         ZFS_IOC_COMPAT_PASS,    /* 22 ZFS_IOC_CREATE_MINOR */
228         ZFS_IOC_COMPAT_PASS,    /* 23 ZFS_IOC_REMOVE_MINOR */
229         23,     /* 24 ZFS_IOC_CREATE */
230         24,     /* 25 ZFS_IOC_DESTROY */
231         25,     /* 26 ZFS_IOC_ROLLBACK */
232         26,     /* 27 ZFS_IOC_RENAME */
233         27,     /* 28 ZFS_IOC_RECV */
234         28,     /* 29 ZFS_IOC_SEND */
235         29,     /* 30 ZFS_IOC_INJECT_FAULT */
236         30,     /* 31 ZFS_IOC_CLEAR_FAULT */
237         31,     /* 32 ZFS_IOC_INJECT_LIST_NEXT */
238         32,     /* 33 ZFS_IOC_ERROR_LOG */
239         33,     /* 34 ZFS_IOC_CLEAR */
240         34,     /* 35 ZFS_IOC_PROMOTE */
241         35,     /* 36 ZFS_IOC_DESTROY_SNAPS */
242         36,     /* 37 ZFS_IOC_SNAPSHOT */
243         37,     /* 38 ZFS_IOC_DSOBJ_TO_DSNAME */
244         38,     /* 39 ZFS_IOC_OBJ_TO_PATH */
245         39,     /* 40 ZFS_IOC_POOL_SET_PROPS */
246         40,     /* 41 ZFS_IOC_POOL_GET_PROPS */
247         41,     /* 42 ZFS_IOC_SET_FSACL */
248         42,     /* 43 ZFS_IOC_GET_FSACL */
249         ZFS_IOC_COMPAT_PASS,    /* 44 ZFS_IOC_ISCSI_PERM_CHECK */
250         43,     /* 45 ZFS_IOC_SHARE */
251         44,     /* 46 ZFS_IOC_IHNERIT_PROP */
252         58,     /* 47 ZFS_IOC_JAIL */
253         59,     /* 48 ZFS_IOC_UNJAIL */
254         45,     /* 49 ZFS_IOC_SMB_ACL */
255         46,     /* 50 ZFS_IOC_USERSPACE_ONE */
256         47,     /* 51 ZFS_IOC_USERSPACE_MANY */
257         48,     /* 52 ZFS_IOC_USERSPACE_UPGRADE */
258         17,     /* 53 ZFS_IOC_SETFRU */
259 };
260
261 #else   /* KERNEL */
262 unsigned static long zfs_ioctl_v28_to_v15[] = {
263         0,      /*  0 ZFS_IOC_POOL_CREATE */
264         1,      /*  1 ZFS_IOC_POOL_DESTROY */
265         2,      /*  2 ZFS_IOC_POOL_IMPORT */
266         3,      /*  3 ZFS_IOC_POOL_EXPORT */
267         4,      /*  4 ZFS_IOC_POOL_CONFIGS */
268         5,      /*  5 ZFS_IOC_POOL_STATS */
269         6,      /*  6 ZFS_IOC_POOL_TRYIMPORT */
270         7,      /*  7 ZFS_IOC_POOL_SCAN */
271         8,      /*  8 ZFS_IOC_POOL_FREEZE */
272         9,      /*  9 ZFS_IOC_POOL_UPGRADE */
273         10,     /* 10 ZFS_IOC_POOL_GET_HISTORY */
274         11,     /* 11 ZFS_IOC_VDEV_ADD */
275         12,     /* 12 ZFS_IOC_VDEV_REMOVE */
276         13,     /* 13 ZFS_IOC_VDEV_SET_STATE */
277         14,     /* 14 ZFS_IOC_VDEV_ATTACH */
278         15,     /* 15 ZFS_IOC_VDEV_DETACH */
279         16,     /* 16 ZFS_IOC_VDEV_SETPATH */
280         53,     /* 17 ZFS_IOC_VDEV_SETFRU */
281         17,     /* 18 ZFS_IOC_OBJSET_STATS */
282         18,     /* 19 ZFS_IOC_OBJSET_ZPLPROPS */
283         19,     /* 20 ZFS_IOC_DATASET_LIST_NEXT */
284         20,     /* 21 ZFS_IOC_SNAPSHOT_LIST_NEXT */
285         21,     /* 22 ZFS_IOC_SET_PROP */
286         24,     /* 23 ZFS_IOC_CREATE */
287         25,     /* 24 ZFS_IOC_DESTROY */
288         26,     /* 25 ZFS_IOC_ROLLBACK */
289         27,     /* 26 ZFS_IOC_RENAME */
290         28,     /* 27 ZFS_IOC_RECV */
291         29,     /* 28 ZFS_IOC_SEND */
292         30,     /* 39 ZFS_IOC_INJECT_FAULT */
293         31,     /* 30 ZFS_IOC_CLEAR_FAULT */
294         32,     /* 31 ZFS_IOC_INJECT_LIST_NEXT */
295         33,     /* 32 ZFS_IOC_ERROR_LOG */
296         34,     /* 33 ZFS_IOC_CLEAR */
297         35,     /* 34 ZFS_IOC_PROMOTE */
298         36,     /* 35 ZFS_IOC_DESTROY_SNAPS */
299         37,     /* 36 ZFS_IOC_SNAPSHOT */
300         38,     /* 37 ZFS_IOC_DSOBJ_TO_DSNAME */
301         39,     /* 38 ZFS_IOC_OBJ_TO_PATH */
302         40,     /* 39 ZFS_IOC_POOL_SET_PROPS */
303         41,     /* 40 ZFS_IOC_POOL_GET_PROPS */
304         42,     /* 41 ZFS_IOC_SET_FSACL */
305         43,     /* 42 ZFS_IOC_GET_FSACL */
306         45,     /* 43 ZFS_IOC_SHARE */
307         46,     /* 44 ZFS_IOC_IHNERIT_PROP */
308         49,     /* 45 ZFS_IOC_SMB_ACL */
309         50,     /* 46 ZFS_IOC_USERSPACE_ONE */
310         51,     /* 47 ZFS_IOC_USERSPACE_MANY */
311         52,     /* 48 ZFS_IOC_USERSPACE_UPGRADE */
312         ZFS_IOC_COMPAT_FAIL,    /* 49 ZFS_IOC_HOLD */
313         ZFS_IOC_COMPAT_FAIL,    /* 50 ZFS_IOC_RELEASE */
314         ZFS_IOC_COMPAT_FAIL,    /* 51 ZFS_IOC_GET_HOLDS */
315         ZFS_IOC_COMPAT_FAIL,    /* 52 ZFS_IOC_OBJSET_RECVD_PROPS */
316         ZFS_IOC_COMPAT_FAIL,    /* 53 ZFS_IOC_VDEV_SPLIT */
317         ZFS_IOC_COMPAT_FAIL,    /* 54 ZFS_IOC_NEXT_OBJ */
318         ZFS_IOC_COMPAT_FAIL,    /* 55 ZFS_IOC_DIFF */
319         ZFS_IOC_COMPAT_FAIL,    /* 56 ZFS_IOC_TMP_SNAPSHOT */
320         ZFS_IOC_COMPAT_FAIL,    /* 57 ZFS_IOC_OBJ_TO_STATS */
321         47,     /* 58 ZFS_IOC_JAIL */
322         48,     /* 59 ZFS_IOC_UNJAIL */
323 };
324 #endif  /* ! _KERNEL */
325
326 #ifdef _KERNEL
327 int zfs_ioctl_compat_pre(zfs_cmd_t *, int *, const int);
328 void zfs_ioctl_compat_post(zfs_cmd_t *, const int, const int);
329 nvlist_t *zfs_ioctl_compat_innvl(zfs_cmd_t *, nvlist_t *, const int,
330     const int);
331 nvlist_t *zfs_ioctl_compat_outnvl(zfs_cmd_t *, nvlist_t *, const int,
332     const int);
333 #else
334 int zcmd_ioctl_compat(int, int, zfs_cmd_t *, const int);
335 #endif  /* _KERNEL */
336 void zfs_cmd_compat_get(zfs_cmd_t *, caddr_t, const int);
337 void zfs_cmd_compat_put(zfs_cmd_t *, caddr_t, const int, const int);
338
339 #ifdef  __cplusplus
340 }
341 #endif
342
343 #endif  /* _SYS_ZFS_IOCTL_COMPAT_H */