]> CyberLeo.Net >> Repos - FreeBSD/releng/10.3.git/blob - sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.h
- Copy stable/10@296371 to releng/10.3 in preparation for 10.3-RC1
[FreeBSD/releng/10.3.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 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_CURRENT      ZFS_IOCVER_RESUME
57
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
66
67 #define ZFS_IOC_COMPAT_PASS     254
68 #define ZFS_IOC_COMPAT_FAIL     255
69
70 #define ZFS_IOCREQ(ioreq)       ((ioreq) & 0xff)
71
72 typedef struct zfs_iocparm {
73         uint32_t        zfs_ioctl_version;
74         uint64_t        zfs_cmd;
75         uint64_t        zfs_cmd_size;
76 } zfs_iocparm_t;
77
78 typedef struct zinject_record_v15 {
79         uint64_t        zi_objset;
80         uint64_t        zi_object;
81         uint64_t        zi_start;
82         uint64_t        zi_end;
83         uint64_t        zi_guid;
84         uint32_t        zi_level;
85         uint32_t        zi_error;
86         uint64_t        zi_type;
87         uint32_t        zi_freq;
88         uint32_t        zi_failfast;
89 } zinject_record_v15_t;
90
91 typedef struct zfs_cmd_v15 {
92         char            zc_name[MAXPATHLEN];
93         char            zc_value[MAXPATHLEN];
94         char            zc_string[MAXNAMELEN];
95         uint64_t        zc_guid;
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;
102         uint64_t        zc_cookie;
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;
108         uint64_t        zc_obj;
109         zfs_share_t     zc_share;
110         uint64_t        zc_jailid;
111         dmu_objset_stats_t zc_objset_stats;
112         struct drr_begin zc_begin_record;
113         zinject_record_v15_t zc_inject_record;
114 } zfs_cmd_v15_t;
115
116 typedef struct zinject_record_v28 {
117         uint64_t        zi_objset;
118         uint64_t        zi_object;
119         uint64_t        zi_start;
120         uint64_t        zi_end;
121         uint64_t        zi_guid;
122         uint32_t        zi_level;
123         uint32_t        zi_error;
124         uint64_t        zi_type;
125         uint32_t        zi_freq;
126         uint32_t        zi_failfast;
127         char            zi_func[MAXNAMELEN];
128         uint32_t        zi_iotype;
129         int32_t         zi_duration;
130         uint64_t        zi_timer;
131 } zinject_record_v28_t;
132
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];
138         uint64_t        zc_guid;
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;
145         uint64_t        zc_cookie;
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;
151         uint64_t        zc_obj;
152         uint64_t        zc_iflags;              /* internal to zfs(7fs) */
153         zfs_share_t     zc_share;
154         uint64_t        zc_jailid;
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;
161         int             zc_cleanup_fd;
162         uint8_t         zc_simple;
163         uint8_t         zc_pad[3];              /* alignment */
164         uint64_t        zc_sendobj;
165         uint64_t        zc_fromobj;
166         uint64_t        zc_createtxg;
167         zfs_stat_t      zc_stat;
168 } zfs_cmd_v28_t;
169
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];
175         uint64_t        zc_guid;
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;
182         uint64_t        zc_cookie;
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;
188         uint64_t        zc_obj;
189         uint64_t        zc_iflags;              /* internal to zfs(7fs) */
190         zfs_share_t     zc_share;
191         uint64_t        zc_jailid;
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;
199         int             zc_cleanup_fd;
200         uint8_t         zc_simple;
201         uint8_t         zc_pad[3];              /* alignment */
202         uint64_t        zc_sendobj;
203         uint64_t        zc_fromobj;
204         uint64_t        zc_createtxg;
205         zfs_stat_t      zc_stat;
206 } zfs_cmd_deadman_t;
207
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? */
215         int             zc_pad2;
216
217         /*
218          * The following members are for legacy ioctls which haven't been
219          * converted to the new method.
220          */
221         uint64_t        zc_history;             /* really (char *) */
222         char            zc_value[MAXPATHLEN * 2];
223         char            zc_string[MAXNAMELEN];
224         uint64_t        zc_guid;
225         uint64_t        zc_nvlist_conf;         /* really (char *) */
226         uint64_t        zc_nvlist_conf_size;
227         uint64_t        zc_cookie;
228         uint64_t        zc_objset_type;
229         uint64_t        zc_perm_action;
230         uint64_t        zc_history_len;
231         uint64_t        zc_history_offset;
232         uint64_t        zc_obj;
233         uint64_t        zc_iflags;              /* internal to zfs(7fs) */
234         zfs_share_t     zc_share;
235         uint64_t        zc_jailid;
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;
242         int             zc_cleanup_fd;
243         uint8_t         zc_simple;
244         uint8_t         zc_pad[3];              /* alignment */
245         uint64_t        zc_sendobj;
246         uint64_t        zc_fromobj;
247         uint64_t        zc_createtxg;
248         zfs_stat_t      zc_stat;
249 } zfs_cmd_zcmd_t;
250
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? */
258         int             zc_pad2;
259
260         /*
261          * The following members are for legacy ioctls which haven't been
262          * converted to the new method.
263          */
264         uint64_t        zc_history;             /* really (char *) */
265         char            zc_value[MAXPATHLEN * 2];
266         char            zc_string[MAXNAMELEN];
267         uint64_t        zc_guid;
268         uint64_t        zc_nvlist_conf;         /* really (char *) */
269         uint64_t        zc_nvlist_conf_size;
270         uint64_t        zc_cookie;
271         uint64_t        zc_objset_type;
272         uint64_t        zc_perm_action;
273         uint64_t        zc_history_len;
274         uint64_t        zc_history_offset;
275         uint64_t        zc_obj;
276         uint64_t        zc_iflags;              /* internal to zfs(7fs) */
277         zfs_share_t     zc_share;
278         uint64_t        zc_jailid;
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;
283         uint32_t        zc_flags;
284         uint64_t        zc_action_handle;
285         int             zc_cleanup_fd;
286         uint8_t         zc_simple;
287         uint8_t         zc_pad[3];              /* alignment */
288         uint64_t        zc_sendobj;
289         uint64_t        zc_fromobj;
290         uint64_t        zc_createtxg;
291         zfs_stat_t      zc_stat;
292 } zfs_cmd_edbp_t;
293
294 #ifdef _KERNEL
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 */
350 };
351
352 #else   /* KERNEL */
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 */
414 };
415 #endif  /* ! _KERNEL */
416
417 #ifdef _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,
421     const int);
422 nvlist_t *zfs_ioctl_compat_outnvl(zfs_cmd_t *, nvlist_t *, const int,
423     const int);
424 #else
425 int zcmd_ioctl_compat(int, int, zfs_cmd_t *, const int);
426 #endif  /* _KERNEL */
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);
429
430 #ifdef  __cplusplus
431 }
432 #endif
433
434 #endif  /* _SYS_ZFS_IOCTL_COMPAT_H */