]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.h
MFC r247187,247265,247348,247398,247540,247585,247852,248265,248267
[FreeBSD/stable/9.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_DEADMAN      1
49 #define ZFS_IOCVER_CURRENT      ZFS_IOCVER_DEADMAN
50
51 /* compatibility conversion flag */
52 #define ZFS_CMD_COMPAT_NONE     0
53 #define ZFS_CMD_COMPAT_V15      1
54 #define ZFS_CMD_COMPAT_V28      2
55
56 #define ZFS_IOC_COMPAT_PASS     254
57 #define ZFS_IOC_COMPAT_FAIL     255
58
59 typedef struct zinject_record_v15 {
60         uint64_t        zi_objset;
61         uint64_t        zi_object;
62         uint64_t        zi_start;
63         uint64_t        zi_end;
64         uint64_t        zi_guid;
65         uint32_t        zi_level;
66         uint32_t        zi_error;
67         uint64_t        zi_type;
68         uint32_t        zi_freq;
69         uint32_t        zi_failfast;
70 } zinject_record_v15_t;
71
72 typedef struct zfs_cmd_v15 {
73         char            zc_name[MAXPATHLEN];
74         char            zc_value[MAXPATHLEN];
75         char            zc_string[MAXNAMELEN];
76         uint64_t        zc_guid;
77         uint64_t        zc_nvlist_conf;         /* really (char *) */
78         uint64_t        zc_nvlist_conf_size;
79         uint64_t        zc_nvlist_src;          /* really (char *) */
80         uint64_t        zc_nvlist_src_size;
81         uint64_t        zc_nvlist_dst;          /* really (char *) */
82         uint64_t        zc_nvlist_dst_size;
83         uint64_t        zc_cookie;
84         uint64_t        zc_objset_type;
85         uint64_t        zc_perm_action;
86         uint64_t        zc_history;             /* really (char *) */
87         uint64_t        zc_history_len;
88         uint64_t        zc_history_offset;
89         uint64_t        zc_obj;
90         zfs_share_t     zc_share;
91         uint64_t        zc_jailid;
92         dmu_objset_stats_t zc_objset_stats;
93         struct drr_begin zc_begin_record;
94         zinject_record_v15_t zc_inject_record;
95 } zfs_cmd_v15_t;
96
97 typedef struct zinject_record_v28 {
98         uint64_t        zi_objset;
99         uint64_t        zi_object;
100         uint64_t        zi_start;
101         uint64_t        zi_end;
102         uint64_t        zi_guid;
103         uint32_t        zi_level;
104         uint32_t        zi_error;
105         uint64_t        zi_type;
106         uint32_t        zi_freq;
107         uint32_t        zi_failfast;
108         char            zi_func[MAXNAMELEN];
109         uint32_t        zi_iotype;
110         int32_t         zi_duration;
111         uint64_t        zi_timer;
112 } zinject_record_v28_t;
113
114 typedef struct zfs_cmd_v28 {
115         char            zc_name[MAXPATHLEN];
116         char            zc_value[MAXPATHLEN * 2];
117         char            zc_string[MAXNAMELEN];
118         char            zc_top_ds[MAXPATHLEN];
119         uint64_t        zc_guid;
120         uint64_t        zc_nvlist_conf;         /* really (char *) */
121         uint64_t        zc_nvlist_conf_size;
122         uint64_t        zc_nvlist_src;          /* really (char *) */
123         uint64_t        zc_nvlist_src_size;
124         uint64_t        zc_nvlist_dst;          /* really (char *) */
125         uint64_t        zc_nvlist_dst_size;
126         uint64_t        zc_cookie;
127         uint64_t        zc_objset_type;
128         uint64_t        zc_perm_action;
129         uint64_t        zc_history;             /* really (char *) */
130         uint64_t        zc_history_len;
131         uint64_t        zc_history_offset;
132         uint64_t        zc_obj;
133         uint64_t        zc_iflags;              /* internal to zfs(7fs) */
134         zfs_share_t     zc_share;
135         uint64_t        zc_jailid;
136         dmu_objset_stats_t zc_objset_stats;
137         struct drr_begin zc_begin_record;
138         zinject_record_v28_t zc_inject_record;
139         boolean_t       zc_defer_destroy;
140         boolean_t       zc_temphold;
141         uint64_t        zc_action_handle;
142         int             zc_cleanup_fd;
143         uint8_t         zc_simple;
144         uint8_t         zc_pad[3];              /* alignment */
145         uint64_t        zc_sendobj;
146         uint64_t        zc_fromobj;
147         uint64_t        zc_createtxg;
148         zfs_stat_t      zc_stat;
149 } zfs_cmd_v28_t;
150
151 #ifdef _KERNEL
152 unsigned static long zfs_ioctl_v15_to_v28[] = {
153         0,      /*  0 ZFS_IOC_POOL_CREATE */
154         1,      /*  1 ZFS_IOC_POOL_DESTROY */
155         2,      /*  2 ZFS_IOC_POOL_IMPORT */
156         3,      /*  3 ZFS_IOC_POOL_EXPORT */
157         4,      /*  4 ZFS_IOC_POOL_CONFIGS */
158         5,      /*  5 ZFS_IOC_POOL_STATS */
159         6,      /*  6 ZFS_IOC_POOL_TRYIMPORT */
160         7,      /*  7 ZFS_IOC_POOL_SCRUB */
161         8,      /*  8 ZFS_IOC_POOL_FREEZE */
162         9,      /*  9 ZFS_IOC_POOL_UPGRADE */
163         10,     /* 10 ZFS_IOC_POOL_GET_HISTORY */
164         11,     /* 11 ZFS_IOC_VDEV_ADD */
165         12,     /* 12 ZFS_IOC_VDEV_REMOVE */
166         13,     /* 13 ZFS_IOC_VDEV_SET_STATE */
167         14,     /* 14 ZFS_IOC_VDEV_ATTACH */
168         15,     /* 15 ZFS_IOC_VDEV_DETACH */
169         16,     /* 16 ZFS_IOC_VDEV_SETPATH */
170         18,     /* 17 ZFS_IOC_OBJSET_STATS */
171         19,     /* 18 ZFS_IOC_OBJSET_ZPLPROPS */
172         20,     /* 19 ZFS_IOC_DATASET_LIST_NEXT */
173         21,     /* 20 ZFS_IOC_SNAPSHOT_LIST_NEXT */
174         22,     /* 21 ZFS_IOC_SET_PROP */
175         ZFS_IOC_COMPAT_PASS,    /* 22 ZFS_IOC_CREATE_MINOR */
176         ZFS_IOC_COMPAT_PASS,    /* 23 ZFS_IOC_REMOVE_MINOR */
177         23,     /* 24 ZFS_IOC_CREATE */
178         24,     /* 25 ZFS_IOC_DESTROY */
179         25,     /* 26 ZFS_IOC_ROLLBACK */
180         26,     /* 27 ZFS_IOC_RENAME */
181         27,     /* 28 ZFS_IOC_RECV */
182         28,     /* 29 ZFS_IOC_SEND */
183         29,     /* 30 ZFS_IOC_INJECT_FAULT */
184         30,     /* 31 ZFS_IOC_CLEAR_FAULT */
185         31,     /* 32 ZFS_IOC_INJECT_LIST_NEXT */
186         32,     /* 33 ZFS_IOC_ERROR_LOG */
187         33,     /* 34 ZFS_IOC_CLEAR */
188         34,     /* 35 ZFS_IOC_PROMOTE */
189         35,     /* 36 ZFS_IOC_DESTROY_SNAPS */
190         36,     /* 37 ZFS_IOC_SNAPSHOT */
191         37,     /* 38 ZFS_IOC_DSOBJ_TO_DSNAME */
192         38,     /* 39 ZFS_IOC_OBJ_TO_PATH */
193         39,     /* 40 ZFS_IOC_POOL_SET_PROPS */
194         40,     /* 41 ZFS_IOC_POOL_GET_PROPS */
195         41,     /* 42 ZFS_IOC_SET_FSACL */
196         42,     /* 43 ZFS_IOC_GET_FSACL */
197         ZFS_IOC_COMPAT_PASS,    /* 44 ZFS_IOC_ISCSI_PERM_CHECK */
198         43,     /* 45 ZFS_IOC_SHARE */
199         44,     /* 46 ZFS_IOC_IHNERIT_PROP */
200         58,     /* 47 ZFS_IOC_JAIL */
201         59,     /* 48 ZFS_IOC_UNJAIL */
202         45,     /* 49 ZFS_IOC_SMB_ACL */
203         46,     /* 50 ZFS_IOC_USERSPACE_ONE */
204         47,     /* 51 ZFS_IOC_USERSPACE_MANY */
205         48,     /* 52 ZFS_IOC_USERSPACE_UPGRADE */
206         17,     /* 53 ZFS_IOC_SETFRU */
207 };
208
209 #else   /* KERNEL */
210 unsigned static long zfs_ioctl_v28_to_v15[] = {
211         0,      /*  0 ZFS_IOC_POOL_CREATE */
212         1,      /*  1 ZFS_IOC_POOL_DESTROY */
213         2,      /*  2 ZFS_IOC_POOL_IMPORT */
214         3,      /*  3 ZFS_IOC_POOL_EXPORT */
215         4,      /*  4 ZFS_IOC_POOL_CONFIGS */
216         5,      /*  5 ZFS_IOC_POOL_STATS */
217         6,      /*  6 ZFS_IOC_POOL_TRYIMPORT */
218         7,      /*  7 ZFS_IOC_POOL_SCAN */
219         8,      /*  8 ZFS_IOC_POOL_FREEZE */
220         9,      /*  9 ZFS_IOC_POOL_UPGRADE */
221         10,     /* 10 ZFS_IOC_POOL_GET_HISTORY */
222         11,     /* 11 ZFS_IOC_VDEV_ADD */
223         12,     /* 12 ZFS_IOC_VDEV_REMOVE */
224         13,     /* 13 ZFS_IOC_VDEV_SET_STATE */
225         14,     /* 14 ZFS_IOC_VDEV_ATTACH */
226         15,     /* 15 ZFS_IOC_VDEV_DETACH */
227         16,     /* 16 ZFS_IOC_VDEV_SETPATH */
228         53,     /* 17 ZFS_IOC_VDEV_SETFRU */
229         17,     /* 18 ZFS_IOC_OBJSET_STATS */
230         18,     /* 19 ZFS_IOC_OBJSET_ZPLPROPS */
231         19,     /* 20 ZFS_IOC_DATASET_LIST_NEXT */
232         20,     /* 21 ZFS_IOC_SNAPSHOT_LIST_NEXT */
233         21,     /* 22 ZFS_IOC_SET_PROP */
234         24,     /* 23 ZFS_IOC_CREATE */
235         25,     /* 24 ZFS_IOC_DESTROY */
236         26,     /* 25 ZFS_IOC_ROLLBACK */
237         27,     /* 26 ZFS_IOC_RENAME */
238         28,     /* 27 ZFS_IOC_RECV */
239         29,     /* 28 ZFS_IOC_SEND */
240         30,     /* 39 ZFS_IOC_INJECT_FAULT */
241         31,     /* 30 ZFS_IOC_CLEAR_FAULT */
242         32,     /* 31 ZFS_IOC_INJECT_LIST_NEXT */
243         33,     /* 32 ZFS_IOC_ERROR_LOG */
244         34,     /* 33 ZFS_IOC_CLEAR */
245         35,     /* 34 ZFS_IOC_PROMOTE */
246         36,     /* 35 ZFS_IOC_DESTROY_SNAPS */
247         37,     /* 36 ZFS_IOC_SNAPSHOT */
248         38,     /* 37 ZFS_IOC_DSOBJ_TO_DSNAME */
249         39,     /* 38 ZFS_IOC_OBJ_TO_PATH */
250         40,     /* 39 ZFS_IOC_POOL_SET_PROPS */
251         41,     /* 40 ZFS_IOC_POOL_GET_PROPS */
252         42,     /* 41 ZFS_IOC_SET_FSACL */
253         43,     /* 42 ZFS_IOC_GET_FSACL */
254         45,     /* 43 ZFS_IOC_SHARE */
255         46,     /* 44 ZFS_IOC_IHNERIT_PROP */
256         49,     /* 45 ZFS_IOC_SMB_ACL */
257         50,     /* 46 ZFS_IOC_USERSPACE_ONE */
258         51,     /* 47 ZFS_IOC_USERSPACE_MANY */
259         52,     /* 48 ZFS_IOC_USERSPACE_UPGRADE */
260         ZFS_IOC_COMPAT_FAIL,    /* 49 ZFS_IOC_HOLD */
261         ZFS_IOC_COMPAT_FAIL,    /* 50 ZFS_IOC_RELEASE */
262         ZFS_IOC_COMPAT_FAIL,    /* 51 ZFS_IOC_GET_HOLDS */
263         ZFS_IOC_COMPAT_FAIL,    /* 52 ZFS_IOC_OBJSET_RECVD_PROPS */
264         ZFS_IOC_COMPAT_FAIL,    /* 53 ZFS_IOC_VDEV_SPLIT */
265         ZFS_IOC_COMPAT_FAIL,    /* 54 ZFS_IOC_NEXT_OBJ */
266         ZFS_IOC_COMPAT_FAIL,    /* 55 ZFS_IOC_DIFF */
267         ZFS_IOC_COMPAT_FAIL,    /* 56 ZFS_IOC_TMP_SNAPSHOT */
268         ZFS_IOC_COMPAT_FAIL,    /* 57 ZFS_IOC_OBJ_TO_STATS */
269         47,     /* 58 ZFS_IOC_JAIL */
270         48,     /* 59 ZFS_IOC_UNJAIL */
271 };
272 #endif  /* ! _KERNEL */
273
274 #ifdef _KERNEL
275 void zfs_ioctl_compat_pre(zfs_cmd_t *, int *, const int);
276 void zfs_ioctl_compat_post(zfs_cmd_t *, const int, const int);
277 #else
278 int zcmd_ioctl_compat(int, unsigned long, zfs_cmd_t *, const int);
279 #endif  /* _KERNEL */
280 void zfs_cmd_compat_get(zfs_cmd_t *, caddr_t, const int);
281 void zfs_cmd_compat_put(zfs_cmd_t *, caddr_t, const int);
282
283 #ifdef  __cplusplus
284 }
285 #endif
286
287 #endif  /* _SYS_ZFS_IOCTL_COMPAT_H */