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 2007 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _SYS_ZFS_IOCTL_H 27 #define _SYS_ZFS_IOCTL_H 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 30 31 #include <sys/cred.h> 32 #include <sys/dmu.h> 33 #include <sys/zio.h> 34 #include <sys/dsl_deleg.h> 35 36 #ifdef _KERNEL 37 #include <sys/nvpair.h> 38 #endif /* _KERNEL */ 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 /* 45 * Property values for snapdir 46 */ 47 #define ZFS_SNAPDIR_HIDDEN 0 48 #define ZFS_SNAPDIR_VISIBLE 1 49 50 #define DMU_BACKUP_VERSION (1ULL) 51 #define DMU_BACKUP_MAGIC 0x2F5bacbacULL 52 53 /* 54 * zfs ioctl command structure 55 */ 56 typedef struct dmu_replay_record { 57 enum { 58 DRR_BEGIN, DRR_OBJECT, DRR_FREEOBJECTS, 59 DRR_WRITE, DRR_FREE, DRR_END, 60 } drr_type; 61 uint32_t drr_pad; 62 union { 63 struct drr_begin { 64 uint64_t drr_magic; 65 uint64_t drr_version; 66 uint64_t drr_creation_time; 67 dmu_objset_type_t drr_type; 68 uint32_t drr_pad; 69 uint64_t drr_toguid; 70 uint64_t drr_fromguid; 71 char drr_toname[MAXNAMELEN]; 72 } drr_begin; 73 struct drr_end { 74 zio_cksum_t drr_checksum; 75 } drr_end; 76 struct drr_object { 77 uint64_t drr_object; 78 dmu_object_type_t drr_type; 79 dmu_object_type_t drr_bonustype; 80 uint32_t drr_blksz; 81 uint32_t drr_bonuslen; 82 uint8_t drr_checksum; 83 uint8_t drr_compress; 84 uint8_t drr_pad[6]; 85 /* bonus content follows */ 86 } drr_object; 87 struct drr_freeobjects { 88 uint64_t drr_firstobj; 89 uint64_t drr_numobjs; 90 } drr_freeobjects; 91 struct drr_write { 92 uint64_t drr_object; 93 dmu_object_type_t drr_type; 94 uint32_t drr_pad; 95 uint64_t drr_offset; 96 uint64_t drr_length; 97 /* content follows */ 98 } drr_write; 99 struct drr_free { 100 uint64_t drr_object; 101 uint64_t drr_offset; 102 uint64_t drr_length; 103 } drr_free; 104 } drr_u; 105 } dmu_replay_record_t; 106 107 typedef struct zinject_record { 108 uint64_t zi_objset; 109 uint64_t zi_object; 110 uint64_t zi_start; 111 uint64_t zi_end; 112 uint64_t zi_guid; 113 uint32_t zi_level; 114 uint32_t zi_error; 115 uint64_t zi_type; 116 uint32_t zi_freq; 117 uint32_t zi_pad; /* pad out to 64 bit alignment */ 118 } zinject_record_t; 119 120 #define ZINJECT_NULL 0x1 121 #define ZINJECT_FLUSH_ARC 0x2 122 #define ZINJECT_UNLOAD_SPA 0x4 123 124 typedef struct zfs_share { 125 uint64_t z_exportdata; 126 uint64_t z_sharedata; 127 uint64_t z_sharetype; /* 0 = share, 1 = unshare */ 128 uint64_t z_sharemax; /* max length of share string */ 129 } zfs_share_t; 130 131 typedef struct zfs_cmd { 132 char zc_name[MAXPATHLEN]; 133 char zc_value[MAXPATHLEN * 2]; 134 uint64_t zc_guid; 135 uint64_t zc_nvlist_conf; /* really (char *) */ 136 uint64_t zc_nvlist_conf_size; 137 uint64_t zc_nvlist_src; /* really (char *) */ 138 uint64_t zc_nvlist_src_size; 139 uint64_t zc_nvlist_dst; /* really (char *) */ 140 uint64_t zc_nvlist_dst_size; 141 uint64_t zc_cookie; 142 uint64_t zc_objset_type; 143 uint64_t zc_perm_action; 144 uint64_t zc_history; /* really (char *) */ 145 uint64_t zc_history_len; 146 uint64_t zc_history_offset; 147 uint64_t zc_obj; 148 zfs_share_t zc_share; 149 dmu_objset_stats_t zc_objset_stats; 150 struct drr_begin zc_begin_record; 151 zinject_record_t zc_inject_record; 152 } zfs_cmd_t; 153 154 #define ZVOL_MAX_MINOR (1 << 16) 155 #define ZFS_MIN_MINOR (ZVOL_MAX_MINOR + 1) 156 157 #ifdef _KERNEL 158 159 typedef struct zfs_creat { 160 int zct_norm; 161 nvlist_t *zct_props; 162 } zfs_creat_t; 163 164 extern dev_info_t *zfs_dip; 165 166 extern int zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr); 167 extern int zfs_secpolicy_rename_perms(const char *from, 168 const char *to, cred_t *cr); 169 extern int zfs_secpolicy_destroy_perms(const char *name, cred_t *cr); 170 extern int zfs_busy(void); 171 extern int zfs_unmount_snap(char *, void *); 172 173 #endif /* _KERNEL */ 174 175 #ifdef __cplusplus 176 } 177 #endif 178 179 #endif /* _SYS_ZFS_IOCTL_H */ 180