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 (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 23 */ 24 25 #ifndef _SYS_ZFS_IOCTL_H 26 #define _SYS_ZFS_IOCTL_H 27 28 #include <sys/cred.h> 29 #include <sys/dmu.h> 30 #include <sys/zio.h> 31 #include <sys/dsl_deleg.h> 32 #include <sys/spa.h> 33 34 #ifdef _KERNEL 35 #include <sys/nvpair.h> 36 #endif /* _KERNEL */ 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 /* 43 * Property values for snapdir 44 */ 45 #define ZFS_SNAPDIR_HIDDEN 0 46 #define ZFS_SNAPDIR_VISIBLE 1 47 48 /* 49 * Field manipulation macros for the drr_versioninfo field of the 50 * send stream header. 51 */ 52 53 /* 54 * Header types for zfs send streams. 55 */ 56 typedef enum drr_headertype { 57 DMU_SUBSTREAM = 0x1, 58 DMU_COMPOUNDSTREAM = 0x2 59 } drr_headertype_t; 60 61 #define DMU_GET_STREAM_HDRTYPE(vi) BF64_GET((vi), 0, 2) 62 #define DMU_SET_STREAM_HDRTYPE(vi, x) BF64_SET((vi), 0, 2, x) 63 64 #define DMU_GET_FEATUREFLAGS(vi) BF64_GET((vi), 2, 30) 65 #define DMU_SET_FEATUREFLAGS(vi, x) BF64_SET((vi), 2, 30, x) 66 67 /* 68 * Feature flags for zfs send streams (flags in drr_versioninfo) 69 */ 70 71 #define DMU_BACKUP_FEATURE_DEDUP (0x1) 72 #define DMU_BACKUP_FEATURE_DEDUPPROPS (0x2) 73 #define DMU_BACKUP_FEATURE_SA_SPILL (0x4) 74 75 /* 76 * Mask of all supported backup features 77 */ 78 #define DMU_BACKUP_FEATURE_MASK (DMU_BACKUP_FEATURE_DEDUP | \ 79 DMU_BACKUP_FEATURE_DEDUPPROPS | DMU_BACKUP_FEATURE_SA_SPILL) 80 81 /* Are all features in the given flag word currently supported? */ 82 #define DMU_STREAM_SUPPORTED(x) (!((x) & ~DMU_BACKUP_FEATURE_MASK)) 83 84 /* 85 * The drr_versioninfo field of the dmu_replay_record has the 86 * following layout: 87 * 88 * 64 56 48 40 32 24 16 8 0 89 * +-------+-------+-------+-------+-------+-------+-------+-------+ 90 * | reserved | feature-flags |C|S| 91 * +-------+-------+-------+-------+-------+-------+-------+-------+ 92 * 93 * The low order two bits indicate the header type: SUBSTREAM (0x1) 94 * or COMPOUNDSTREAM (0x2). Using two bits for this is historical: 95 * this field used to be a version number, where the two version types 96 * were 1 and 2. Using two bits for this allows earlier versions of 97 * the code to be able to recognize send streams that don't use any 98 * of the features indicated by feature flags. 99 */ 100 101 #define DMU_BACKUP_MAGIC 0x2F5bacbacULL 102 103 #define DRR_FLAG_CLONE (1<<0) 104 #define DRR_FLAG_CI_DATA (1<<1) 105 106 /* 107 * flags in the drr_checksumflags field in the DRR_WRITE and 108 * DRR_WRITE_BYREF blocks 109 */ 110 #define DRR_CHECKSUM_DEDUP (1<<0) 111 112 #define DRR_IS_DEDUP_CAPABLE(flags) ((flags) & DRR_CHECKSUM_DEDUP) 113 114 /* 115 * zfs ioctl command structure 116 */ 117 typedef struct dmu_replay_record { 118 enum { 119 DRR_BEGIN, DRR_OBJECT, DRR_FREEOBJECTS, 120 DRR_WRITE, DRR_FREE, DRR_END, DRR_WRITE_BYREF, 121 DRR_SPILL, DRR_NUMTYPES 122 } drr_type; 123 uint32_t drr_payloadlen; 124 union { 125 struct drr_begin { 126 uint64_t drr_magic; 127 uint64_t drr_versioninfo; /* was drr_version */ 128 uint64_t drr_creation_time; 129 dmu_objset_type_t drr_type; 130 uint32_t drr_flags; 131 uint64_t drr_toguid; 132 uint64_t drr_fromguid; 133 char drr_toname[MAXNAMELEN]; 134 } drr_begin; 135 struct drr_end { 136 zio_cksum_t drr_checksum; 137 uint64_t drr_toguid; 138 } drr_end; 139 struct drr_object { 140 uint64_t drr_object; 141 dmu_object_type_t drr_type; 142 dmu_object_type_t drr_bonustype; 143 uint32_t drr_blksz; 144 uint32_t drr_bonuslen; 145 uint8_t drr_checksumtype; 146 uint8_t drr_compress; 147 uint8_t drr_pad[6]; 148 uint64_t drr_toguid; 149 /* bonus content follows */ 150 } drr_object; 151 struct drr_freeobjects { 152 uint64_t drr_firstobj; 153 uint64_t drr_numobjs; 154 uint64_t drr_toguid; 155 } drr_freeobjects; 156 struct drr_write { 157 uint64_t drr_object; 158 dmu_object_type_t drr_type; 159 uint32_t drr_pad; 160 uint64_t drr_offset; 161 uint64_t drr_length; 162 uint64_t drr_toguid; 163 uint8_t drr_checksumtype; 164 uint8_t drr_checksumflags; 165 uint8_t drr_pad2[6]; 166 ddt_key_t drr_key; /* deduplication key */ 167 /* content follows */ 168 } drr_write; 169 struct drr_free { 170 uint64_t drr_object; 171 uint64_t drr_offset; 172 uint64_t drr_length; 173 uint64_t drr_toguid; 174 } drr_free; 175 struct drr_write_byref { 176 /* where to put the data */ 177 uint64_t drr_object; 178 uint64_t drr_offset; 179 uint64_t drr_length; 180 uint64_t drr_toguid; 181 /* where to find the prior copy of the data */ 182 uint64_t drr_refguid; 183 uint64_t drr_refobject; 184 uint64_t drr_refoffset; 185 /* properties of the data */ 186 uint8_t drr_checksumtype; 187 uint8_t drr_checksumflags; 188 uint8_t drr_pad2[6]; 189 ddt_key_t drr_key; /* deduplication key */ 190 } drr_write_byref; 191 struct drr_spill { 192 uint64_t drr_object; 193 uint64_t drr_length; 194 uint64_t drr_toguid; 195 uint64_t drr_pad[4]; /* needed for crypto */ 196 /* spill data follows */ 197 } drr_spill; 198 } drr_u; 199 } dmu_replay_record_t; 200 201 typedef struct zinject_record { 202 uint64_t zi_objset; 203 uint64_t zi_object; 204 uint64_t zi_start; 205 uint64_t zi_end; 206 uint64_t zi_guid; 207 uint32_t zi_level; 208 uint32_t zi_error; 209 uint64_t zi_type; 210 uint32_t zi_freq; 211 uint32_t zi_failfast; 212 char zi_func[MAXNAMELEN]; 213 uint32_t zi_iotype; 214 int32_t zi_duration; 215 uint64_t zi_timer; 216 } zinject_record_t; 217 218 #define ZINJECT_NULL 0x1 219 #define ZINJECT_FLUSH_ARC 0x2 220 #define ZINJECT_UNLOAD_SPA 0x4 221 222 typedef struct zfs_share { 223 uint64_t z_exportdata; 224 uint64_t z_sharedata; 225 uint64_t z_sharetype; /* 0 = share, 1 = unshare */ 226 uint64_t z_sharemax; /* max length of share string */ 227 } zfs_share_t; 228 229 /* 230 * ZFS file systems may behave the usual, POSIX-compliant way, where 231 * name lookups are case-sensitive. They may also be set up so that 232 * all the name lookups are case-insensitive, or so that only some 233 * lookups, the ones that set an FIGNORECASE flag, are case-insensitive. 234 */ 235 typedef enum zfs_case { 236 ZFS_CASE_SENSITIVE, 237 ZFS_CASE_INSENSITIVE, 238 ZFS_CASE_MIXED 239 } zfs_case_t; 240 241 typedef struct zfs_cmd { 242 char zc_name[MAXPATHLEN]; 243 char zc_value[MAXPATHLEN * 2]; 244 char zc_string[MAXNAMELEN]; 245 char zc_top_ds[MAXPATHLEN]; 246 uint64_t zc_guid; 247 uint64_t zc_nvlist_conf; /* really (char *) */ 248 uint64_t zc_nvlist_conf_size; 249 uint64_t zc_nvlist_src; /* really (char *) */ 250 uint64_t zc_nvlist_src_size; 251 uint64_t zc_nvlist_dst; /* really (char *) */ 252 uint64_t zc_nvlist_dst_size; 253 uint64_t zc_cookie; 254 uint64_t zc_objset_type; 255 uint64_t zc_perm_action; 256 uint64_t zc_history; /* really (char *) */ 257 uint64_t zc_history_len; 258 uint64_t zc_history_offset; 259 uint64_t zc_obj; 260 uint64_t zc_iflags; /* internal to zfs(7fs) */ 261 zfs_share_t zc_share; 262 dmu_objset_stats_t zc_objset_stats; 263 struct drr_begin zc_begin_record; 264 zinject_record_t zc_inject_record; 265 boolean_t zc_defer_destroy; 266 boolean_t zc_temphold; 267 uint64_t zc_action_handle; 268 int zc_cleanup_fd; 269 uint8_t zc_pad[4]; 270 uint64_t zc_sendobj; 271 uint64_t zc_fromobj; 272 uint64_t zc_createtxg; 273 } zfs_cmd_t; 274 275 typedef struct zfs_useracct { 276 char zu_domain[256]; 277 uid_t zu_rid; 278 uint32_t zu_pad; 279 uint64_t zu_space; 280 } zfs_useracct_t; 281 282 #define ZFSDEV_MAX_MINOR (1 << 16) 283 #define ZFS_MIN_MINOR (ZFSDEV_MAX_MINOR + 1) 284 285 #define ZPOOL_EXPORT_AFTER_SPLIT 0x1 286 287 #ifdef _KERNEL 288 289 typedef struct zfs_creat { 290 nvlist_t *zct_zplprops; 291 nvlist_t *zct_props; 292 } zfs_creat_t; 293 294 extern dev_info_t *zfs_dip; 295 296 extern int zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr); 297 extern int zfs_secpolicy_rename_perms(const char *from, 298 const char *to, cred_t *cr); 299 extern int zfs_secpolicy_destroy_perms(const char *name, cred_t *cr); 300 extern int zfs_busy(void); 301 extern int zfs_unmount_snap(const char *, void *); 302 303 /* 304 * ZFS minor numbers can refer to either a control device instance or 305 * a zvol. Depending on the value of zss_type, zss_data points to either 306 * a zvol_state_t or a zfs_onexit_t. 307 */ 308 enum zfs_soft_state_type { 309 ZSST_ZVOL, 310 ZSST_CTLDEV 311 }; 312 313 typedef struct zfs_soft_state { 314 enum zfs_soft_state_type zss_type; 315 void *zss_data; 316 } zfs_soft_state_t; 317 318 extern void *zfsdev_get_soft_state(minor_t minor, 319 enum zfs_soft_state_type which); 320 extern minor_t zfsdev_minor_alloc(void); 321 322 extern void *zfsdev_state; 323 extern kmutex_t zfsdev_state_lock; 324 325 #endif /* _KERNEL */ 326 327 #ifdef __cplusplus 328 } 329 #endif 330 331 #endif /* _SYS_ZFS_IOCTL_H */ 332