zfs_ioctl_compat.h revision 297108
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 41extern "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_CURRENT ZFS_IOCVER_INLANES 58 59/* compatibility conversion flag */ 60#define ZFS_CMD_COMPAT_NONE 0 61#define ZFS_CMD_COMPAT_V15 1 62#define ZFS_CMD_COMPAT_V28 2 63#define ZFS_CMD_COMPAT_DEADMAN 3 64#define ZFS_CMD_COMPAT_LZC 4 65#define ZFS_CMD_COMPAT_ZCMD 5 66#define ZFS_CMD_COMPAT_EDBP 6 67#define ZFS_CMD_COMPAT_RESUME 7 68 69#define ZFS_IOC_COMPAT_PASS 254 70#define ZFS_IOC_COMPAT_FAIL 255 71 72#define ZFS_IOCREQ(ioreq) ((ioreq) & 0xff) 73 74typedef struct zfs_iocparm { 75 uint32_t zfs_ioctl_version; 76 uint64_t zfs_cmd; 77 uint64_t zfs_cmd_size; 78} zfs_iocparm_t; 79 80typedef struct zinject_record_v15 { 81 uint64_t zi_objset; 82 uint64_t zi_object; 83 uint64_t zi_start; 84 uint64_t zi_end; 85 uint64_t zi_guid; 86 uint32_t zi_level; 87 uint32_t zi_error; 88 uint64_t zi_type; 89 uint32_t zi_freq; 90 uint32_t zi_failfast; 91} zinject_record_v15_t; 92 93typedef struct zfs_cmd_v15 { 94 char zc_name[MAXPATHLEN]; 95 char zc_value[MAXPATHLEN]; 96 char zc_string[MAXNAMELEN]; 97 uint64_t zc_guid; 98 uint64_t zc_nvlist_conf; /* really (char *) */ 99 uint64_t zc_nvlist_conf_size; 100 uint64_t zc_nvlist_src; /* really (char *) */ 101 uint64_t zc_nvlist_src_size; 102 uint64_t zc_nvlist_dst; /* really (char *) */ 103 uint64_t zc_nvlist_dst_size; 104 uint64_t zc_cookie; 105 uint64_t zc_objset_type; 106 uint64_t zc_perm_action; 107 uint64_t zc_history; /* really (char *) */ 108 uint64_t zc_history_len; 109 uint64_t zc_history_offset; 110 uint64_t zc_obj; 111 zfs_share_t zc_share; 112 uint64_t zc_jailid; 113 dmu_objset_stats_t zc_objset_stats; 114 struct drr_begin zc_begin_record; 115 zinject_record_v15_t zc_inject_record; 116} zfs_cmd_v15_t; 117 118typedef struct zinject_record_v28 { 119 uint64_t zi_objset; 120 uint64_t zi_object; 121 uint64_t zi_start; 122 uint64_t zi_end; 123 uint64_t zi_guid; 124 uint32_t zi_level; 125 uint32_t zi_error; 126 uint64_t zi_type; 127 uint32_t zi_freq; 128 uint32_t zi_failfast; 129 char zi_func[MAXNAMELEN]; 130 uint32_t zi_iotype; 131 int32_t zi_duration; 132 uint64_t zi_timer; 133} zinject_record_v28_t; 134 135typedef struct zfs_cmd_v28 { 136 char zc_name[MAXPATHLEN]; 137 char zc_value[MAXPATHLEN * 2]; 138 char zc_string[MAXNAMELEN]; 139 char zc_top_ds[MAXPATHLEN]; 140 uint64_t zc_guid; 141 uint64_t zc_nvlist_conf; /* really (char *) */ 142 uint64_t zc_nvlist_conf_size; 143 uint64_t zc_nvlist_src; /* really (char *) */ 144 uint64_t zc_nvlist_src_size; 145 uint64_t zc_nvlist_dst; /* really (char *) */ 146 uint64_t zc_nvlist_dst_size; 147 uint64_t zc_cookie; 148 uint64_t zc_objset_type; 149 uint64_t zc_perm_action; 150 uint64_t zc_history; /* really (char *) */ 151 uint64_t zc_history_len; 152 uint64_t zc_history_offset; 153 uint64_t zc_obj; 154 uint64_t zc_iflags; /* internal to zfs(7fs) */ 155 zfs_share_t zc_share; 156 uint64_t zc_jailid; 157 dmu_objset_stats_t zc_objset_stats; 158 struct drr_begin zc_begin_record; 159 zinject_record_v28_t zc_inject_record; 160 boolean_t zc_defer_destroy; 161 boolean_t zc_temphold; 162 uint64_t zc_action_handle; 163 int zc_cleanup_fd; 164 uint8_t zc_simple; 165 uint8_t zc_pad[3]; /* alignment */ 166 uint64_t zc_sendobj; 167 uint64_t zc_fromobj; 168 uint64_t zc_createtxg; 169 zfs_stat_t zc_stat; 170} zfs_cmd_v28_t; 171 172typedef struct zinject_record_deadman { 173 uint64_t zi_objset; 174 uint64_t zi_object; 175 uint64_t zi_start; 176 uint64_t zi_end; 177 uint64_t zi_guid; 178 uint32_t zi_level; 179 uint32_t zi_error; 180 uint64_t zi_type; 181 uint32_t zi_freq; 182 uint32_t zi_failfast; 183 char zi_func[MAXNAMELEN]; 184 uint32_t zi_iotype; 185 int32_t zi_duration; 186 uint64_t zi_timer; 187 uint32_t zi_cmd; 188 uint32_t zi_pad; 189} zinject_record_deadman_t; 190 191typedef struct zfs_cmd_deadman { 192 char zc_name[MAXPATHLEN]; 193 char zc_value[MAXPATHLEN * 2]; 194 char zc_string[MAXNAMELEN]; 195 char zc_top_ds[MAXPATHLEN]; 196 uint64_t zc_guid; 197 uint64_t zc_nvlist_conf; /* really (char *) */ 198 uint64_t zc_nvlist_conf_size; 199 uint64_t zc_nvlist_src; /* really (char *) */ 200 uint64_t zc_nvlist_src_size; 201 uint64_t zc_nvlist_dst; /* really (char *) */ 202 uint64_t zc_nvlist_dst_size; 203 uint64_t zc_cookie; 204 uint64_t zc_objset_type; 205 uint64_t zc_perm_action; 206 uint64_t zc_history; /* really (char *) */ 207 uint64_t zc_history_len; 208 uint64_t zc_history_offset; 209 uint64_t zc_obj; 210 uint64_t zc_iflags; /* internal to zfs(7fs) */ 211 zfs_share_t zc_share; 212 uint64_t zc_jailid; 213 dmu_objset_stats_t zc_objset_stats; 214 struct drr_begin zc_begin_record; 215 /* zc_inject_record doesn't change in libzfs_core */ 216 zinject_record_deadman_t zc_inject_record; 217 boolean_t zc_defer_destroy; 218 boolean_t zc_temphold; 219 uint64_t zc_action_handle; 220 int zc_cleanup_fd; 221 uint8_t zc_simple; 222 uint8_t zc_pad[3]; /* alignment */ 223 uint64_t zc_sendobj; 224 uint64_t zc_fromobj; 225 uint64_t zc_createtxg; 226 zfs_stat_t zc_stat; 227} zfs_cmd_deadman_t; 228 229typedef struct zfs_cmd_zcmd { 230 char zc_name[MAXPATHLEN]; /* name of pool or dataset */ 231 uint64_t zc_nvlist_src; /* really (char *) */ 232 uint64_t zc_nvlist_src_size; 233 uint64_t zc_nvlist_dst; /* really (char *) */ 234 uint64_t zc_nvlist_dst_size; 235 boolean_t zc_nvlist_dst_filled; /* put an nvlist in dst? */ 236 int zc_pad2; 237 238 /* 239 * The following members are for legacy ioctls which haven't been 240 * converted to the new method. 241 */ 242 uint64_t zc_history; /* really (char *) */ 243 char zc_value[MAXPATHLEN * 2]; 244 char zc_string[MAXNAMELEN]; 245 uint64_t zc_guid; 246 uint64_t zc_nvlist_conf; /* really (char *) */ 247 uint64_t zc_nvlist_conf_size; 248 uint64_t zc_cookie; 249 uint64_t zc_objset_type; 250 uint64_t zc_perm_action; 251 uint64_t zc_history_len; 252 uint64_t zc_history_offset; 253 uint64_t zc_obj; 254 uint64_t zc_iflags; /* internal to zfs(7fs) */ 255 zfs_share_t zc_share; 256 uint64_t zc_jailid; 257 dmu_objset_stats_t zc_objset_stats; 258 struct drr_begin zc_begin_record; 259 zinject_record_deadman_t zc_inject_record; 260 boolean_t zc_defer_destroy; 261 boolean_t zc_temphold; 262 uint64_t zc_action_handle; 263 int zc_cleanup_fd; 264 uint8_t zc_simple; 265 uint8_t zc_pad[3]; /* alignment */ 266 uint64_t zc_sendobj; 267 uint64_t zc_fromobj; 268 uint64_t zc_createtxg; 269 zfs_stat_t zc_stat; 270} zfs_cmd_zcmd_t; 271 272typedef struct zfs_cmd_edbp { 273 char zc_name[MAXPATHLEN]; /* name of pool or dataset */ 274 uint64_t zc_nvlist_src; /* really (char *) */ 275 uint64_t zc_nvlist_src_size; 276 uint64_t zc_nvlist_dst; /* really (char *) */ 277 uint64_t zc_nvlist_dst_size; 278 boolean_t zc_nvlist_dst_filled; /* put an nvlist in dst? */ 279 int zc_pad2; 280 281 /* 282 * The following members are for legacy ioctls which haven't been 283 * converted to the new method. 284 */ 285 uint64_t zc_history; /* really (char *) */ 286 char zc_value[MAXPATHLEN * 2]; 287 char zc_string[MAXNAMELEN]; 288 uint64_t zc_guid; 289 uint64_t zc_nvlist_conf; /* really (char *) */ 290 uint64_t zc_nvlist_conf_size; 291 uint64_t zc_cookie; 292 uint64_t zc_objset_type; 293 uint64_t zc_perm_action; 294 uint64_t zc_history_len; 295 uint64_t zc_history_offset; 296 uint64_t zc_obj; 297 uint64_t zc_iflags; /* internal to zfs(7fs) */ 298 zfs_share_t zc_share; 299 uint64_t zc_jailid; 300 dmu_objset_stats_t zc_objset_stats; 301 struct drr_begin zc_begin_record; 302 zinject_record_deadman_t zc_inject_record; 303 uint32_t zc_defer_destroy; 304 uint32_t zc_flags; 305 uint64_t zc_action_handle; 306 int zc_cleanup_fd; 307 uint8_t zc_simple; 308 uint8_t zc_pad[3]; /* alignment */ 309 uint64_t zc_sendobj; 310 uint64_t zc_fromobj; 311 uint64_t zc_createtxg; 312 zfs_stat_t zc_stat; 313} zfs_cmd_edbp_t; 314 315typedef struct zfs_cmd_resume { 316 char zc_name[MAXPATHLEN]; /* name of pool or dataset */ 317 uint64_t zc_nvlist_src; /* really (char *) */ 318 uint64_t zc_nvlist_src_size; 319 uint64_t zc_nvlist_dst; /* really (char *) */ 320 uint64_t zc_nvlist_dst_size; 321 boolean_t zc_nvlist_dst_filled; /* put an nvlist in dst? */ 322 int zc_pad2; 323 324 /* 325 * The following members are for legacy ioctls which haven't been 326 * converted to the new method. 327 */ 328 uint64_t zc_history; /* really (char *) */ 329 char zc_value[MAXPATHLEN * 2]; 330 char zc_string[MAXNAMELEN]; 331 uint64_t zc_guid; 332 uint64_t zc_nvlist_conf; /* really (char *) */ 333 uint64_t zc_nvlist_conf_size; 334 uint64_t zc_cookie; 335 uint64_t zc_objset_type; 336 uint64_t zc_perm_action; 337 uint64_t zc_history_len; 338 uint64_t zc_history_offset; 339 uint64_t zc_obj; 340 uint64_t zc_iflags; /* internal to zfs(7fs) */ 341 zfs_share_t zc_share; 342 uint64_t zc_jailid; 343 dmu_objset_stats_t zc_objset_stats; 344 dmu_replay_record_t zc_begin_record; 345 zinject_record_deadman_t zc_inject_record; 346 uint32_t zc_defer_destroy; 347 uint32_t zc_flags; 348 uint64_t zc_action_handle; 349 int zc_cleanup_fd; 350 uint8_t zc_simple; 351 boolean_t zc_resumable; 352 uint64_t zc_sendobj; 353 uint64_t zc_fromobj; 354 uint64_t zc_createtxg; 355 zfs_stat_t zc_stat; 356} zfs_cmd_resume_t; 357 358#ifdef _KERNEL 359unsigned static long zfs_ioctl_v15_to_v28[] = { 360 0, /* 0 ZFS_IOC_POOL_CREATE */ 361 1, /* 1 ZFS_IOC_POOL_DESTROY */ 362 2, /* 2 ZFS_IOC_POOL_IMPORT */ 363 3, /* 3 ZFS_IOC_POOL_EXPORT */ 364 4, /* 4 ZFS_IOC_POOL_CONFIGS */ 365 5, /* 5 ZFS_IOC_POOL_STATS */ 366 6, /* 6 ZFS_IOC_POOL_TRYIMPORT */ 367 7, /* 7 ZFS_IOC_POOL_SCRUB */ 368 8, /* 8 ZFS_IOC_POOL_FREEZE */ 369 9, /* 9 ZFS_IOC_POOL_UPGRADE */ 370 10, /* 10 ZFS_IOC_POOL_GET_HISTORY */ 371 11, /* 11 ZFS_IOC_VDEV_ADD */ 372 12, /* 12 ZFS_IOC_VDEV_REMOVE */ 373 13, /* 13 ZFS_IOC_VDEV_SET_STATE */ 374 14, /* 14 ZFS_IOC_VDEV_ATTACH */ 375 15, /* 15 ZFS_IOC_VDEV_DETACH */ 376 16, /* 16 ZFS_IOC_VDEV_SETPATH */ 377 18, /* 17 ZFS_IOC_OBJSET_STATS */ 378 19, /* 18 ZFS_IOC_OBJSET_ZPLPROPS */ 379 20, /* 19 ZFS_IOC_DATASET_LIST_NEXT */ 380 21, /* 20 ZFS_IOC_SNAPSHOT_LIST_NEXT */ 381 22, /* 21 ZFS_IOC_SET_PROP */ 382 ZFS_IOC_COMPAT_PASS, /* 22 ZFS_IOC_CREATE_MINOR */ 383 ZFS_IOC_COMPAT_PASS, /* 23 ZFS_IOC_REMOVE_MINOR */ 384 23, /* 24 ZFS_IOC_CREATE */ 385 24, /* 25 ZFS_IOC_DESTROY */ 386 25, /* 26 ZFS_IOC_ROLLBACK */ 387 26, /* 27 ZFS_IOC_RENAME */ 388 27, /* 28 ZFS_IOC_RECV */ 389 28, /* 29 ZFS_IOC_SEND */ 390 29, /* 30 ZFS_IOC_INJECT_FAULT */ 391 30, /* 31 ZFS_IOC_CLEAR_FAULT */ 392 31, /* 32 ZFS_IOC_INJECT_LIST_NEXT */ 393 32, /* 33 ZFS_IOC_ERROR_LOG */ 394 33, /* 34 ZFS_IOC_CLEAR */ 395 34, /* 35 ZFS_IOC_PROMOTE */ 396 35, /* 36 ZFS_IOC_DESTROY_SNAPS */ 397 36, /* 37 ZFS_IOC_SNAPSHOT */ 398 37, /* 38 ZFS_IOC_DSOBJ_TO_DSNAME */ 399 38, /* 39 ZFS_IOC_OBJ_TO_PATH */ 400 39, /* 40 ZFS_IOC_POOL_SET_PROPS */ 401 40, /* 41 ZFS_IOC_POOL_GET_PROPS */ 402 41, /* 42 ZFS_IOC_SET_FSACL */ 403 42, /* 43 ZFS_IOC_GET_FSACL */ 404 ZFS_IOC_COMPAT_PASS, /* 44 ZFS_IOC_ISCSI_PERM_CHECK */ 405 43, /* 45 ZFS_IOC_SHARE */ 406 44, /* 46 ZFS_IOC_IHNERIT_PROP */ 407 58, /* 47 ZFS_IOC_JAIL */ 408 59, /* 48 ZFS_IOC_UNJAIL */ 409 45, /* 49 ZFS_IOC_SMB_ACL */ 410 46, /* 50 ZFS_IOC_USERSPACE_ONE */ 411 47, /* 51 ZFS_IOC_USERSPACE_MANY */ 412 48, /* 52 ZFS_IOC_USERSPACE_UPGRADE */ 413 17, /* 53 ZFS_IOC_SETFRU */ 414}; 415 416#else /* KERNEL */ 417unsigned static long zfs_ioctl_v28_to_v15[] = { 418 0, /* 0 ZFS_IOC_POOL_CREATE */ 419 1, /* 1 ZFS_IOC_POOL_DESTROY */ 420 2, /* 2 ZFS_IOC_POOL_IMPORT */ 421 3, /* 3 ZFS_IOC_POOL_EXPORT */ 422 4, /* 4 ZFS_IOC_POOL_CONFIGS */ 423 5, /* 5 ZFS_IOC_POOL_STATS */ 424 6, /* 6 ZFS_IOC_POOL_TRYIMPORT */ 425 7, /* 7 ZFS_IOC_POOL_SCAN */ 426 8, /* 8 ZFS_IOC_POOL_FREEZE */ 427 9, /* 9 ZFS_IOC_POOL_UPGRADE */ 428 10, /* 10 ZFS_IOC_POOL_GET_HISTORY */ 429 11, /* 11 ZFS_IOC_VDEV_ADD */ 430 12, /* 12 ZFS_IOC_VDEV_REMOVE */ 431 13, /* 13 ZFS_IOC_VDEV_SET_STATE */ 432 14, /* 14 ZFS_IOC_VDEV_ATTACH */ 433 15, /* 15 ZFS_IOC_VDEV_DETACH */ 434 16, /* 16 ZFS_IOC_VDEV_SETPATH */ 435 53, /* 17 ZFS_IOC_VDEV_SETFRU */ 436 17, /* 18 ZFS_IOC_OBJSET_STATS */ 437 18, /* 19 ZFS_IOC_OBJSET_ZPLPROPS */ 438 19, /* 20 ZFS_IOC_DATASET_LIST_NEXT */ 439 20, /* 21 ZFS_IOC_SNAPSHOT_LIST_NEXT */ 440 21, /* 22 ZFS_IOC_SET_PROP */ 441 24, /* 23 ZFS_IOC_CREATE */ 442 25, /* 24 ZFS_IOC_DESTROY */ 443 26, /* 25 ZFS_IOC_ROLLBACK */ 444 27, /* 26 ZFS_IOC_RENAME */ 445 28, /* 27 ZFS_IOC_RECV */ 446 29, /* 28 ZFS_IOC_SEND */ 447 30, /* 39 ZFS_IOC_INJECT_FAULT */ 448 31, /* 30 ZFS_IOC_CLEAR_FAULT */ 449 32, /* 31 ZFS_IOC_INJECT_LIST_NEXT */ 450 33, /* 32 ZFS_IOC_ERROR_LOG */ 451 34, /* 33 ZFS_IOC_CLEAR */ 452 35, /* 34 ZFS_IOC_PROMOTE */ 453 36, /* 35 ZFS_IOC_DESTROY_SNAPS */ 454 37, /* 36 ZFS_IOC_SNAPSHOT */ 455 38, /* 37 ZFS_IOC_DSOBJ_TO_DSNAME */ 456 39, /* 38 ZFS_IOC_OBJ_TO_PATH */ 457 40, /* 39 ZFS_IOC_POOL_SET_PROPS */ 458 41, /* 40 ZFS_IOC_POOL_GET_PROPS */ 459 42, /* 41 ZFS_IOC_SET_FSACL */ 460 43, /* 42 ZFS_IOC_GET_FSACL */ 461 45, /* 43 ZFS_IOC_SHARE */ 462 46, /* 44 ZFS_IOC_IHNERIT_PROP */ 463 49, /* 45 ZFS_IOC_SMB_ACL */ 464 50, /* 46 ZFS_IOC_USERSPACE_ONE */ 465 51, /* 47 ZFS_IOC_USERSPACE_MANY */ 466 52, /* 48 ZFS_IOC_USERSPACE_UPGRADE */ 467 ZFS_IOC_COMPAT_FAIL, /* 49 ZFS_IOC_HOLD */ 468 ZFS_IOC_COMPAT_FAIL, /* 50 ZFS_IOC_RELEASE */ 469 ZFS_IOC_COMPAT_FAIL, /* 51 ZFS_IOC_GET_HOLDS */ 470 ZFS_IOC_COMPAT_FAIL, /* 52 ZFS_IOC_OBJSET_RECVD_PROPS */ 471 ZFS_IOC_COMPAT_FAIL, /* 53 ZFS_IOC_VDEV_SPLIT */ 472 ZFS_IOC_COMPAT_FAIL, /* 54 ZFS_IOC_NEXT_OBJ */ 473 ZFS_IOC_COMPAT_FAIL, /* 55 ZFS_IOC_DIFF */ 474 ZFS_IOC_COMPAT_FAIL, /* 56 ZFS_IOC_TMP_SNAPSHOT */ 475 ZFS_IOC_COMPAT_FAIL, /* 57 ZFS_IOC_OBJ_TO_STATS */ 476 47, /* 58 ZFS_IOC_JAIL */ 477 48, /* 59 ZFS_IOC_UNJAIL */ 478}; 479#endif /* ! _KERNEL */ 480 481#ifdef _KERNEL 482int zfs_ioctl_compat_pre(zfs_cmd_t *, int *, const int); 483void zfs_ioctl_compat_post(zfs_cmd_t *, const int, const int); 484nvlist_t *zfs_ioctl_compat_innvl(zfs_cmd_t *, nvlist_t *, const int, 485 const int); 486nvlist_t *zfs_ioctl_compat_outnvl(zfs_cmd_t *, nvlist_t *, const int, 487 const int); 488#else 489int zcmd_ioctl_compat(int, int, zfs_cmd_t *, const int); 490#endif /* _KERNEL */ 491void zfs_cmd_compat_get(zfs_cmd_t *, caddr_t, const int); 492void zfs_cmd_compat_put(zfs_cmd_t *, caddr_t, const int, const int); 493 494#ifdef __cplusplus 495} 496#endif 497 498#endif /* _SYS_ZFS_IOCTL_COMPAT_H */ 499