1fa9e4066Sahrens /* 2fa9e4066Sahrens * CDDL HEADER START 3fa9e4066Sahrens * 4fa9e4066Sahrens * The contents of this file are subject to the terms of the 5ea8dc4b6Seschrock * Common Development and Distribution License (the "License"). 6ea8dc4b6Seschrock * You may not use this file except in compliance with the License. 7fa9e4066Sahrens * 8fa9e4066Sahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9fa9e4066Sahrens * or http://www.opensolaris.org/os/licensing. 10fa9e4066Sahrens * See the License for the specific language governing permissions 11fa9e4066Sahrens * and limitations under the License. 12fa9e4066Sahrens * 13fa9e4066Sahrens * When distributing Covered Code, include this CDDL HEADER in each 14fa9e4066Sahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15fa9e4066Sahrens * If applicable, add the following below this CDDL HEADER, with the 16fa9e4066Sahrens * fields enclosed by brackets "[]" replaced with your own identifying 17fa9e4066Sahrens * information: Portions Copyright [yyyy] [name of copyright owner] 18fa9e4066Sahrens * 19fa9e4066Sahrens * CDDL HEADER END 20fa9e4066Sahrens */ 21fa9e4066Sahrens /* 22*1195e687SMark J Musante * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 23fa9e4066Sahrens * Use is subject to license terms. 24fa9e4066Sahrens */ 25fa9e4066Sahrens 26fa9e4066Sahrens #ifndef _SYS_ZFS_IOCTL_H 27fa9e4066Sahrens #define _SYS_ZFS_IOCTL_H 28fa9e4066Sahrens 29fa9e4066Sahrens #include <sys/cred.h> 30fa9e4066Sahrens #include <sys/dmu.h> 31ea8dc4b6Seschrock #include <sys/zio.h> 32ecd6cf80Smarks #include <sys/dsl_deleg.h> 339e69d7d0SLori Alt #include <sys/spa.h> 34fa9e4066Sahrens 35da6c28aaSamw #ifdef _KERNEL 36da6c28aaSamw #include <sys/nvpair.h> 37da6c28aaSamw #endif /* _KERNEL */ 38da6c28aaSamw 39fa9e4066Sahrens #ifdef __cplusplus 40fa9e4066Sahrens extern "C" { 41fa9e4066Sahrens #endif 42fa9e4066Sahrens 43fa9e4066Sahrens /* 44fa9e4066Sahrens * Property values for snapdir 45fa9e4066Sahrens */ 46a0965f35Sbonwick #define ZFS_SNAPDIR_HIDDEN 0 47a0965f35Sbonwick #define ZFS_SNAPDIR_VISIBLE 1 48fa9e4066Sahrens 499e69d7d0SLori Alt /* 509e69d7d0SLori Alt * Field manipulation macros for the drr_versioninfo field of the 519e69d7d0SLori Alt * send stream header. 529e69d7d0SLori Alt */ 539e69d7d0SLori Alt 549e69d7d0SLori Alt /* 559e69d7d0SLori Alt * Header types for zfs send streams. 569e69d7d0SLori Alt */ 579e69d7d0SLori Alt typedef enum drr_headertype { 589e69d7d0SLori Alt DMU_SUBSTREAM = 0x1, 599e69d7d0SLori Alt DMU_COMPOUNDSTREAM = 0x2 609e69d7d0SLori Alt } drr_headertype_t; 619e69d7d0SLori Alt 629e69d7d0SLori Alt #define DMU_GET_STREAM_HDRTYPE(vi) BF64_GET((vi), 0, 2) 639e69d7d0SLori Alt #define DMU_SET_STREAM_HDRTYPE(vi, x) BF64_SET((vi), 0, 2, x) 649e69d7d0SLori Alt 659e69d7d0SLori Alt #define DMU_GET_FEATUREFLAGS(vi) BF64_GET((vi), 2, 30) 669e69d7d0SLori Alt #define DMU_SET_FEATUREFLAGS(vi, x) BF64_SET((vi), 2, 30, x) 679e69d7d0SLori Alt 689e69d7d0SLori Alt /* 699e69d7d0SLori Alt * Feature flags for zfs send streams (flags in drr_versioninfo) 709e69d7d0SLori Alt */ 719e69d7d0SLori Alt 729e69d7d0SLori Alt #define DMU_BACKUP_FEATURE_DEDUP (0x1) 738e714474SLori Alt #define DMU_BACKUP_FEATURE_DEDUPPROPS (0x2) 749e69d7d0SLori Alt 759e69d7d0SLori Alt /* 769e69d7d0SLori Alt * Mask of all supported backup features 779e69d7d0SLori Alt */ 788e714474SLori Alt #define DMU_BACKUP_FEATURE_MASK (DMU_BACKUP_FEATURE_DEDUP | \ 798e714474SLori Alt DMU_BACKUP_FEATURE_DEDUPPROPS) 809e69d7d0SLori Alt 819e69d7d0SLori Alt /* Are all features in the given flag word currently supported? */ 829e69d7d0SLori Alt #define DMU_STREAM_SUPPORTED(x) (!((x) & ~DMU_BACKUP_FEATURE_MASK)) 839e69d7d0SLori Alt 849e69d7d0SLori Alt /* 859e69d7d0SLori Alt * The drr_versioninfo field of the dmu_replay_record has the 869e69d7d0SLori Alt * following layout: 879e69d7d0SLori Alt * 889e69d7d0SLori Alt * 64 56 48 40 32 24 16 8 0 899e69d7d0SLori Alt * +-------+-------+-------+-------+-------+-------+-------+-------+ 909e69d7d0SLori Alt * | reserved | feature-flags |C|S| 919e69d7d0SLori Alt * +-------+-------+-------+-------+-------+-------+-------+-------+ 929e69d7d0SLori Alt * 939e69d7d0SLori Alt * The low order two bits indicate the header type: SUBSTREAM (0x1) 949e69d7d0SLori Alt * or COMPOUNDSTREAM (0x2). Using two bits for this is historical: 959e69d7d0SLori Alt * this field used to be a version number, where the two version types 969e69d7d0SLori Alt * were 1 and 2. Using two bits for this allows earlier versions of 979e69d7d0SLori Alt * the code to be able to recognize send streams that don't use any 989e69d7d0SLori Alt * of the features indicated by feature flags. 999e69d7d0SLori Alt */ 1009e69d7d0SLori Alt 101fa9e4066Sahrens #define DMU_BACKUP_MAGIC 0x2F5bacbacULL 102fa9e4066Sahrens 103ab04eb8eStimh #define DRR_FLAG_CLONE (1<<0) 104ab04eb8eStimh #define DRR_FLAG_CI_DATA (1<<1) 1053cb34c60Sahrens 1068e714474SLori Alt /* 1078e714474SLori Alt * flags in the drr_checksumflags field in the DRR_WRITE and 1088e714474SLori Alt * DRR_WRITE_BYREF blocks 1098e714474SLori Alt */ 1108e714474SLori Alt #define DRR_CHECKSUM_DEDUP (1<<0) 1118e714474SLori Alt 1128e714474SLori Alt #define DRR_IS_DEDUP_CAPABLE(flags) ((flags) & DRR_CHECKSUM_DEDUP) 1138e714474SLori Alt 114fa9e4066Sahrens /* 115fa9e4066Sahrens * zfs ioctl command structure 116fa9e4066Sahrens */ 117fa9e4066Sahrens typedef struct dmu_replay_record { 118fa9e4066Sahrens enum { 119fa9e4066Sahrens DRR_BEGIN, DRR_OBJECT, DRR_FREEOBJECTS, 1209e69d7d0SLori Alt DRR_WRITE, DRR_FREE, DRR_END, DRR_WRITE_BYREF, 1219e69d7d0SLori Alt DRR_NUMTYPES 122fa9e4066Sahrens } drr_type; 1233cb34c60Sahrens uint32_t drr_payloadlen; 124fa9e4066Sahrens union { 125fa9e4066Sahrens struct drr_begin { 126fa9e4066Sahrens uint64_t drr_magic; 1279e69d7d0SLori Alt uint64_t drr_versioninfo; /* was drr_version */ 128fa9e4066Sahrens uint64_t drr_creation_time; 129fa9e4066Sahrens dmu_objset_type_t drr_type; 1303cb34c60Sahrens uint32_t drr_flags; 131fa9e4066Sahrens uint64_t drr_toguid; 132fa9e4066Sahrens uint64_t drr_fromguid; 133fa9e4066Sahrens char drr_toname[MAXNAMELEN]; 134fa9e4066Sahrens } drr_begin; 135fa9e4066Sahrens struct drr_end { 136ea8dc4b6Seschrock zio_cksum_t drr_checksum; 1379e69d7d0SLori Alt uint64_t drr_toguid; 138fa9e4066Sahrens } drr_end; 139fa9e4066Sahrens struct drr_object { 140fa9e4066Sahrens uint64_t drr_object; 141fa9e4066Sahrens dmu_object_type_t drr_type; 142fa9e4066Sahrens dmu_object_type_t drr_bonustype; 143fa9e4066Sahrens uint32_t drr_blksz; 144fa9e4066Sahrens uint32_t drr_bonuslen; 1459e69d7d0SLori Alt uint8_t drr_checksumtype; 146fa9e4066Sahrens uint8_t drr_compress; 147fa9e4066Sahrens uint8_t drr_pad[6]; 1489e69d7d0SLori Alt uint64_t drr_toguid; 149a2eea2e1Sahrens /* bonus content follows */ 150fa9e4066Sahrens } drr_object; 151fa9e4066Sahrens struct drr_freeobjects { 152fa9e4066Sahrens uint64_t drr_firstobj; 153fa9e4066Sahrens uint64_t drr_numobjs; 1549e69d7d0SLori Alt uint64_t drr_toguid; 155fa9e4066Sahrens } drr_freeobjects; 156fa9e4066Sahrens struct drr_write { 157fa9e4066Sahrens uint64_t drr_object; 158fa9e4066Sahrens dmu_object_type_t drr_type; 159fa9e4066Sahrens uint32_t drr_pad; 160fa9e4066Sahrens uint64_t drr_offset; 161fa9e4066Sahrens uint64_t drr_length; 1629e69d7d0SLori Alt uint64_t drr_toguid; 1639e69d7d0SLori Alt uint8_t drr_checksumtype; 1648e714474SLori Alt uint8_t drr_checksumflags; 1658e714474SLori Alt uint8_t drr_pad2[6]; 1668e714474SLori Alt ddt_key_t drr_key; /* deduplication key */ 167a2eea2e1Sahrens /* content follows */ 168fa9e4066Sahrens } drr_write; 169fa9e4066Sahrens struct drr_free { 170fa9e4066Sahrens uint64_t drr_object; 171fa9e4066Sahrens uint64_t drr_offset; 172fa9e4066Sahrens uint64_t drr_length; 1739e69d7d0SLori Alt uint64_t drr_toguid; 174fa9e4066Sahrens } drr_free; 1759e69d7d0SLori Alt struct drr_write_byref { 1769e69d7d0SLori Alt /* where to put the data */ 1779e69d7d0SLori Alt uint64_t drr_object; 1789e69d7d0SLori Alt uint64_t drr_offset; 1799e69d7d0SLori Alt uint64_t drr_length; 1809e69d7d0SLori Alt uint64_t drr_toguid; 1819e69d7d0SLori Alt /* where to find the prior copy of the data */ 1829e69d7d0SLori Alt uint64_t drr_refguid; 1839e69d7d0SLori Alt uint64_t drr_refobject; 1849e69d7d0SLori Alt uint64_t drr_refoffset; 1858e714474SLori Alt /* properties of the data */ 1869e69d7d0SLori Alt uint8_t drr_checksumtype; 1878e714474SLori Alt uint8_t drr_checksumflags; 1888e714474SLori Alt uint8_t drr_pad2[6]; 1898e714474SLori Alt ddt_key_t drr_key; /* deduplication key */ 1909e69d7d0SLori Alt } drr_write_byref; 191fa9e4066Sahrens } drr_u; 192fa9e4066Sahrens } dmu_replay_record_t; 193fa9e4066Sahrens 194ea8dc4b6Seschrock typedef struct zinject_record { 195ea8dc4b6Seschrock uint64_t zi_objset; 196ea8dc4b6Seschrock uint64_t zi_object; 197ea8dc4b6Seschrock uint64_t zi_start; 198ea8dc4b6Seschrock uint64_t zi_end; 199ea8dc4b6Seschrock uint64_t zi_guid; 200ea8dc4b6Seschrock uint32_t zi_level; 201ea8dc4b6Seschrock uint32_t zi_error; 202ea8dc4b6Seschrock uint64_t zi_type; 203ea8dc4b6Seschrock uint32_t zi_freq; 2048956713aSEric Schrock uint32_t zi_failfast; 20588ecc943SGeorge Wilson char zi_func[MAXNAMELEN]; 2068f18d1faSGeorge Wilson uint32_t zi_iotype; 207468c413aSTim Haley int32_t zi_duration; 208468c413aSTim Haley uint64_t zi_timer; 209ea8dc4b6Seschrock } zinject_record_t; 210ea8dc4b6Seschrock 211ea8dc4b6Seschrock #define ZINJECT_NULL 0x1 212ea8dc4b6Seschrock #define ZINJECT_FLUSH_ARC 0x2 213ea8dc4b6Seschrock #define ZINJECT_UNLOAD_SPA 0x4 214ea8dc4b6Seschrock 215ecd6cf80Smarks typedef struct zfs_share { 216ecd6cf80Smarks uint64_t z_exportdata; 217ecd6cf80Smarks uint64_t z_sharedata; 218ecd6cf80Smarks uint64_t z_sharetype; /* 0 = share, 1 = unshare */ 219ecd6cf80Smarks uint64_t z_sharemax; /* max length of share string */ 220ecd6cf80Smarks } zfs_share_t; 221ecd6cf80Smarks 222de8267e0Stimh /* 223de8267e0Stimh * ZFS file systems may behave the usual, POSIX-compliant way, where 224de8267e0Stimh * name lookups are case-sensitive. They may also be set up so that 225de8267e0Stimh * all the name lookups are case-insensitive, or so that only some 226de8267e0Stimh * lookups, the ones that set an FIGNORECASE flag, are case-insensitive. 227de8267e0Stimh */ 228de8267e0Stimh typedef enum zfs_case { 229de8267e0Stimh ZFS_CASE_SENSITIVE, 230de8267e0Stimh ZFS_CASE_INSENSITIVE, 231de8267e0Stimh ZFS_CASE_MIXED 232de8267e0Stimh } zfs_case_t; 233de8267e0Stimh 234fa9e4066Sahrens typedef struct zfs_cmd { 23515f66a7fSek char zc_name[MAXPATHLEN]; 23655434c77Sek char zc_value[MAXPATHLEN * 2]; 2373cb34c60Sahrens char zc_string[MAXNAMELEN]; 2389e69d7d0SLori Alt char zc_top_ds[MAXPATHLEN]; 239ea8dc4b6Seschrock uint64_t zc_guid; 240990b4856Slling uint64_t zc_nvlist_conf; /* really (char *) */ 241990b4856Slling uint64_t zc_nvlist_conf_size; 242990b4856Slling uint64_t zc_nvlist_src; /* really (char *) */ 243e9dbad6fSeschrock uint64_t zc_nvlist_src_size; 244990b4856Slling uint64_t zc_nvlist_dst; /* really (char *) */ 245e9dbad6fSeschrock uint64_t zc_nvlist_dst_size; 246fa9e4066Sahrens uint64_t zc_cookie; 247fa9e4066Sahrens uint64_t zc_objset_type; 248ecd6cf80Smarks uint64_t zc_perm_action; 249990b4856Slling uint64_t zc_history; /* really (char *) */ 250ecd6cf80Smarks uint64_t zc_history_len; 25106eeb2adSek uint64_t zc_history_offset; 25255434c77Sek uint64_t zc_obj; 253478ed9adSEric Taylor uint64_t zc_iflags; /* internal to zfs(7fs) */ 254ecd6cf80Smarks zfs_share_t zc_share; 255fa9e4066Sahrens dmu_objset_stats_t zc_objset_stats; 256fa9e4066Sahrens struct drr_begin zc_begin_record; 257ea8dc4b6Seschrock zinject_record_t zc_inject_record; 258842727c2SChris Kirby boolean_t zc_defer_destroy; 259ca45db41SChris Kirby boolean_t zc_temphold; 260fa9e4066Sahrens } zfs_cmd_t; 261fa9e4066Sahrens 26214843421SMatthew Ahrens typedef struct zfs_useracct { 26314843421SMatthew Ahrens char zu_domain[256]; 26414843421SMatthew Ahrens uid_t zu_rid; 26514843421SMatthew Ahrens uint32_t zu_pad; 26614843421SMatthew Ahrens uint64_t zu_space; 26714843421SMatthew Ahrens } zfs_useracct_t; 26814843421SMatthew Ahrens 269a0965f35Sbonwick #define ZVOL_MAX_MINOR (1 << 16) 270a0965f35Sbonwick #define ZFS_MIN_MINOR (ZVOL_MAX_MINOR + 1) 271a0965f35Sbonwick 272*1195e687SMark J Musante #define ZPOOL_EXPORT_AFTER_SPLIT 0x1 273*1195e687SMark J Musante 274fa9e4066Sahrens #ifdef _KERNEL 275fa9e4066Sahrens 276da6c28aaSamw typedef struct zfs_creat { 277de8267e0Stimh nvlist_t *zct_zplprops; 278da6c28aaSamw nvlist_t *zct_props; 279da6c28aaSamw } zfs_creat_t; 280da6c28aaSamw 281fa9e4066Sahrens extern dev_info_t *zfs_dip; 282fa9e4066Sahrens 283ecd6cf80Smarks extern int zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr); 284ecd6cf80Smarks extern int zfs_secpolicy_rename_perms(const char *from, 285ecd6cf80Smarks const char *to, cred_t *cr); 286ecd6cf80Smarks extern int zfs_secpolicy_destroy_perms(const char *name, cred_t *cr); 287fa9e4066Sahrens extern int zfs_busy(void); 288fd136879SMatthew Ahrens extern int zfs_unmount_snap(const char *, void *); 289fa9e4066Sahrens 290fa9e4066Sahrens #endif /* _KERNEL */ 291fa9e4066Sahrens 292fa9e4066Sahrens #ifdef __cplusplus 293fa9e4066Sahrens } 294fa9e4066Sahrens #endif 295fa9e4066Sahrens 296fa9e4066Sahrens #endif /* _SYS_ZFS_IOCTL_H */ 297