FreeBSD ZFS
The Zettabyte File System
|
00001 /* 00002 * CDDL HEADER START 00003 * 00004 * The contents of this file are subject to the terms of the 00005 * Common Development and Distribution License (the "License"). 00006 * You may not use this file except in compliance with the License. 00007 * 00008 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 00009 * or http://www.opensolaris.org/os/licensing. 00010 * See the License for the specific language governing permissions 00011 * and limitations under the License. 00012 * 00013 * When distributing Covered Code, include this CDDL HEADER in each 00014 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 00015 * If applicable, add the following below this CDDL HEADER, with the 00016 * fields enclosed by brackets "[]" replaced with your own identifying 00017 * information: Portions Copyright [yyyy] [name of copyright owner] 00018 * 00019 * CDDL HEADER END 00020 */ 00021 /* 00022 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 00023 */ 00024 00025 #ifndef _SYS_ZFS_IOCTL_H 00026 #define _SYS_ZFS_IOCTL_H 00027 00028 #include <sys/cred.h> 00029 #include <sys/dmu.h> 00030 #include <sys/zio.h> 00031 #include <sys/dsl_deleg.h> 00032 #include <sys/spa.h> 00033 #include <sys/zfs_stat.h> 00034 00035 #ifdef _KERNEL 00036 #include <sys/nvpair.h> 00037 #endif /* _KERNEL */ 00038 00039 #ifdef __cplusplus 00040 extern "C" { 00041 #endif 00042 00043 /* 00044 * Property values for snapdir 00045 */ 00046 #define ZFS_SNAPDIR_HIDDEN 0 00047 #define ZFS_SNAPDIR_VISIBLE 1 00048 00049 /* 00050 * Field manipulation macros for the drr_versioninfo field of the 00051 * send stream header. 00052 */ 00053 00057 typedef enum drr_headertype { 00058 DMU_SUBSTREAM = 0x1, 00059 DMU_COMPOUNDSTREAM = 0x2 00060 } drr_headertype_t; 00061 00062 #define DMU_GET_STREAM_HDRTYPE(vi) BF64_GET((vi), 0, 2) 00063 #define DMU_SET_STREAM_HDRTYPE(vi, x) BF64_SET((vi), 0, 2, x) 00064 00065 #define DMU_GET_FEATUREFLAGS(vi) BF64_GET((vi), 2, 30) 00066 #define DMU_SET_FEATUREFLAGS(vi, x) BF64_SET((vi), 2, 30, x) 00067 00068 /* 00069 * Feature flags for zfs send streams (flags in drr_versioninfo) 00070 */ 00071 00072 #define DMU_BACKUP_FEATURE_DEDUP (0x1) 00073 #define DMU_BACKUP_FEATURE_DEDUPPROPS (0x2) 00074 #define DMU_BACKUP_FEATURE_SA_SPILL (0x4) 00075 00079 #define DMU_BACKUP_FEATURE_MASK (DMU_BACKUP_FEATURE_DEDUP | \ 00080 DMU_BACKUP_FEATURE_DEDUPPROPS | DMU_BACKUP_FEATURE_SA_SPILL) 00081 00083 #define DMU_STREAM_SUPPORTED(x) (!((x) & ~DMU_BACKUP_FEATURE_MASK)) 00084 00085 #define DMU_BACKUP_MAGIC 0x2F5bacbacULL 00086 00087 #define DRR_FLAG_CLONE (1<<0) 00088 #define DRR_FLAG_CI_DATA (1<<1) 00089 00090 /* 00091 * flags in the drr_checksumflags field in the DRR_WRITE and 00092 * DRR_WRITE_BYREF blocks 00093 */ 00094 #define DRR_CHECKSUM_DEDUP (1<<0) 00095 00096 #define DRR_IS_DEDUP_CAPABLE(flags) ((flags) & DRR_CHECKSUM_DEDUP) 00097 00101 struct drr_begin { 00102 uint64_t drr_magic; 00123 uint64_t drr_versioninfo; 00124 uint64_t drr_creation_time; 00125 dmu_objset_type_t drr_type; 00126 uint32_t drr_flags; 00127 uint64_t drr_toguid; 00128 uint64_t drr_fromguid; 00129 char drr_toname[MAXNAMELEN]; 00130 }; 00131 00132 struct drr_end { 00133 zio_cksum_t drr_checksum; 00134 uint64_t drr_toguid; 00135 }; 00136 00138 struct drr_object { 00139 uint64_t drr_object; 00140 dmu_object_type_t drr_type; 00141 dmu_object_type_t drr_bonustype; 00142 uint32_t drr_blksz; 00143 uint32_t drr_bonuslen; 00144 uint8_t drr_checksumtype; 00145 uint8_t drr_compress; 00146 uint8_t drr_pad[6]; 00147 uint64_t drr_toguid; 00148 }; 00149 00150 struct drr_freeobjects { 00151 uint64_t drr_firstobj; 00152 uint64_t drr_numobjs; 00153 uint64_t drr_toguid; 00154 }; 00155 00157 struct drr_write { 00158 uint64_t drr_object; 00159 dmu_object_type_t drr_type; 00160 uint32_t drr_pad; 00161 uint64_t drr_offset; 00162 uint64_t drr_length; 00163 uint64_t drr_toguid; 00164 uint8_t drr_checksumtype; 00165 uint8_t drr_checksumflags; 00166 uint8_t drr_pad2[6]; 00167 ddt_key_t drr_key; 00168 }; 00169 00170 struct drr_free { 00171 uint64_t drr_object; 00172 uint64_t drr_offset; 00173 uint64_t drr_length; 00174 uint64_t drr_toguid; 00175 }; 00176 00177 struct drr_write_byref { 00181 uint64_t drr_object; 00182 uint64_t drr_offset; 00183 uint64_t drr_length; 00184 uint64_t drr_toguid; 00189 uint64_t drr_refguid; 00190 uint64_t drr_refobject; 00191 uint64_t drr_refoffset; 00196 uint8_t drr_checksumtype; 00197 uint8_t drr_checksumflags; 00198 uint8_t drr_pad2[6]; 00199 ddt_key_t drr_key; 00201 }; 00202 00204 struct drr_spill { 00205 uint64_t drr_object; 00206 uint64_t drr_length; 00207 uint64_t drr_toguid; 00208 uint64_t drr_pad[4]; 00209 }; 00210 00211 typedef struct dmu_replay_record { 00212 enum { 00213 DRR_BEGIN, DRR_OBJECT, DRR_FREEOBJECTS, 00214 DRR_WRITE, DRR_FREE, DRR_END, DRR_WRITE_BYREF, 00215 DRR_SPILL, DRR_NUMTYPES 00216 } drr_type; 00217 uint32_t drr_payloadlen; 00218 union { 00219 struct drr_begin drr_begin; 00220 struct drr_end drr_end; 00221 struct drr_object drr_object; 00222 struct drr_freeobjects drr_freeobjects; 00223 struct drr_write drr_write; 00224 struct drr_free drr_free; 00225 struct drr_write_byref drr_write_byref; 00226 struct drr_spill drr_spill; 00227 } drr_u; 00228 } dmu_replay_record_t; 00229 00231 typedef enum diff_type { 00232 DDR_NONE = 0x1, 00233 DDR_INUSE = 0x2, 00234 DDR_FREE = 0x4 00235 } diff_type_t; 00236 00240 typedef struct dmu_diff_record { 00241 uint64_t ddr_type; 00242 uint64_t ddr_first; 00243 uint64_t ddr_last; 00244 } dmu_diff_record_t; 00245 00246 typedef struct zinject_record { 00247 uint64_t zi_objset; 00248 uint64_t zi_object; 00249 uint64_t zi_start; 00250 uint64_t zi_end; 00251 uint64_t zi_guid; 00252 uint32_t zi_level; 00253 uint32_t zi_error; 00254 uint64_t zi_type; 00255 uint32_t zi_freq; 00256 uint32_t zi_failfast; 00257 char zi_func[MAXNAMELEN]; 00258 uint32_t zi_iotype; 00259 int32_t zi_duration; 00260 uint64_t zi_timer; 00261 } zinject_record_t; 00262 00263 #define ZINJECT_NULL 0x1 00264 #define ZINJECT_FLUSH_ARC 0x2 00265 #define ZINJECT_UNLOAD_SPA 0x4 00266 00267 typedef struct zfs_share { 00268 uint64_t z_exportdata; 00269 uint64_t z_sharedata; 00270 uint64_t z_sharetype; 00271 uint64_t z_sharemax; 00272 } zfs_share_t; 00273 00280 typedef enum zfs_case { 00281 ZFS_CASE_SENSITIVE, 00282 ZFS_CASE_INSENSITIVE, 00283 ZFS_CASE_MIXED 00284 } zfs_case_t; 00285 00286 typedef struct zfs_cmd { 00287 char zc_name[MAXPATHLEN]; 00288 char zc_value[MAXPATHLEN * 2]; 00289 char zc_string[MAXNAMELEN]; 00290 char zc_top_ds[MAXPATHLEN]; 00291 uint64_t zc_guid; 00292 uint64_t zc_nvlist_conf; 00293 uint64_t zc_nvlist_conf_size; 00294 uint64_t zc_nvlist_src; 00295 uint64_t zc_nvlist_src_size; 00296 uint64_t zc_nvlist_dst; 00297 uint64_t zc_nvlist_dst_size; 00298 uint64_t zc_cookie; 00299 uint64_t zc_objset_type; 00300 uint64_t zc_perm_action; 00301 uint64_t zc_history; 00302 uint64_t zc_history_len; 00303 uint64_t zc_history_offset; 00304 uint64_t zc_obj; 00305 uint64_t zc_iflags; 00306 zfs_share_t zc_share; 00307 uint64_t zc_jailid; 00308 dmu_objset_stats_t zc_objset_stats; 00309 struct drr_begin zc_begin_record; 00310 zinject_record_t zc_inject_record; 00311 boolean_t zc_defer_destroy; 00312 boolean_t zc_temphold; 00313 uint64_t zc_action_handle; 00314 int zc_cleanup_fd; 00315 uint8_t zc_simple; 00316 uint8_t zc_pad[3]; /* alignment */ 00317 uint64_t zc_sendobj; 00318 uint64_t zc_fromobj; 00319 uint64_t zc_createtxg; 00320 zfs_stat_t zc_stat; 00321 } zfs_cmd_t; 00322 00323 typedef struct zfs_useracct { 00324 char zu_domain[256]; 00325 uid_t zu_rid; 00326 uint32_t zu_pad; 00327 uint64_t zu_space; 00328 } zfs_useracct_t; 00329 00330 #define ZFSDEV_MAX_MINOR (1 << 16) 00331 #define ZFS_MIN_MINOR (ZFSDEV_MAX_MINOR + 1) 00332 00333 #define ZPOOL_EXPORT_AFTER_SPLIT 0x1 00334 00335 #ifdef _KERNEL 00336 00337 typedef struct zfs_creat { 00338 nvlist_t *zct_zplprops; 00339 nvlist_t *zct_props; 00340 } zfs_creat_t; 00341 00342 extern int zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr); 00343 extern int zfs_secpolicy_rename_perms(const char *from, 00344 const char *to, cred_t *cr); 00345 extern int zfs_secpolicy_destroy_perms(const char *name, cred_t *cr); 00346 extern int zfs_busy(void); 00347 extern int zfs_unmount_snap(const char *, void *); 00348 00354 enum zfs_soft_state_type { 00355 ZSST_ZVOL, 00356 ZSST_CTLDEV 00357 }; 00358 00359 typedef struct zfs_soft_state { 00360 enum zfs_soft_state_type zss_type; 00361 void *zss_data; 00362 } zfs_soft_state_t; 00363 00364 extern void *zfsdev_get_soft_state(minor_t minor, 00365 enum zfs_soft_state_type which); 00366 extern minor_t zfsdev_minor_alloc(void); 00367 00368 extern void *zfsdev_state; 00369 00370 #endif /* _KERNEL */ 00371 00372 #ifdef __cplusplus 00373 } 00374 #endif 00375 00376 #endif /* _SYS_ZFS_IOCTL_H */