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, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _SYS_ZFS_IOCTL_H 28 #define _SYS_ZFS_IOCTL_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #include <sys/cred.h> 33 #include <sys/dmu.h> 34 35 #ifdef __cplusplus 36 extern "C" { 37 #endif 38 39 #define ZFS_DRIVER_NAME "zfs" 40 #define ZFS_DS_TYPE "zfs" 41 42 /* 43 * Property values for snapdir 44 */ 45 #define HIDDEN 0 46 #define VISIBLE 1 47 48 typedef struct zfs_stats { 49 uint64_t zs_atime; 50 uint64_t zs_recordsize; 51 uint64_t zs_readonly; 52 uint64_t zs_devices; 53 uint64_t zs_exec; 54 uint64_t zs_setuid; 55 uint64_t zs_snapdir; 56 uint64_t zs_acl_mode; 57 uint64_t zs_acl_inherit; 58 char zs_mountpoint[MAXNAMELEN]; 59 char zs_atime_setpoint[MAXNAMELEN]; 60 char zs_recordsize_setpoint[MAXNAMELEN]; 61 char zs_readonly_setpoint[MAXNAMELEN]; 62 char zs_devices_setpoint[MAXNAMELEN]; 63 char zs_setuid_setpoint[MAXNAMELEN]; 64 char zs_exec_setpoint[MAXNAMELEN]; 65 char zs_mountpoint_setpoint[MAXNAMELEN]; 66 char zs_sharenfs[MAXNAMELEN]; 67 char zs_sharenfs_setpoint[MAXNAMELEN]; 68 char zs_snapdir_setpoint[MAXNAMELEN]; 69 char zs_acl_mode_setpoint[MAXNAMELEN]; 70 char zs_acl_inherit_setpoint[MAXNAMELEN]; 71 } zfs_stats_t; 72 73 #define DMU_BACKUP_VERSION (1ULL) 74 #define DMU_BACKUP_MAGIC 0x2F5bacbacULL 75 76 /* 77 * zfs ioctl command structure 78 */ 79 typedef struct dmu_replay_record { 80 enum { 81 DRR_BEGIN, DRR_OBJECT, DRR_FREEOBJECTS, 82 DRR_WRITE, DRR_FREE, DRR_END, 83 } drr_type; 84 uint32_t drr_pad; 85 union { 86 struct drr_begin { 87 uint64_t drr_magic; 88 uint64_t drr_version; 89 uint64_t drr_creation_time; 90 dmu_objset_type_t drr_type; 91 uint32_t drr_pad; 92 uint64_t drr_toguid; 93 uint64_t drr_fromguid; 94 char drr_toname[MAXNAMELEN]; 95 } drr_begin; 96 struct drr_end { 97 uint64_t drr_checksum; 98 } drr_end; 99 struct drr_object { 100 uint64_t drr_object; 101 dmu_object_type_t drr_type; 102 dmu_object_type_t drr_bonustype; 103 uint32_t drr_blksz; 104 uint32_t drr_bonuslen; 105 uint8_t drr_checksum; 106 uint8_t drr_compress; 107 uint8_t drr_pad[6]; 108 } drr_object; 109 struct drr_freeobjects { 110 uint64_t drr_firstobj; 111 uint64_t drr_numobjs; 112 } drr_freeobjects; 113 struct drr_write { 114 uint64_t drr_object; 115 dmu_object_type_t drr_type; 116 uint32_t drr_pad; 117 uint64_t drr_offset; 118 uint64_t drr_length; 119 } drr_write; 120 struct drr_free { 121 uint64_t drr_object; 122 uint64_t drr_offset; 123 uint64_t drr_length; 124 } drr_free; 125 } drr_u; 126 } dmu_replay_record_t; 127 128 typedef struct zfs_cmd { 129 char zc_name[MAXNAMELEN]; 130 char zc_prop_name[MAXNAMELEN]; 131 char zc_prop_value[MAXPATHLEN]; 132 char zc_root[MAXPATHLEN]; 133 char zc_filename[MAXPATHLEN]; 134 uint32_t zc_intsz; 135 uint32_t zc_numints; 136 uint64_t zc_pool_guid; 137 uint64_t zc_config_src; /* really (char *) */ 138 uint64_t zc_config_src_size; 139 uint64_t zc_config_dst; /* really (char *) */ 140 uint64_t zc_config_dst_size; 141 uint64_t zc_cookie; 142 uint64_t zc_cred; 143 uint64_t zc_dev; 144 uint64_t zc_volsize; 145 uint64_t zc_volblocksize; 146 uint64_t zc_objset_type; 147 zfs_stats_t zc_zfs_stats; 148 dmu_object_info_t zc_object_info; 149 dmu_objset_stats_t zc_objset_stats; 150 struct drr_begin zc_begin_record; 151 } zfs_cmd_t; 152 153 #ifdef _KERNEL 154 155 extern dev_info_t *zfs_dip; 156 157 extern int zfs_secpolicy_write(const char *dataset, const char *, cred_t *cr); 158 extern int zfs_busy(void); 159 160 extern int zvol_check_volsize(zfs_cmd_t *zc); 161 extern int zvol_check_volblocksize(zfs_cmd_t *zc); 162 extern int zvol_get_stats(zfs_cmd_t *zc, objset_t *os); 163 extern void zvol_create_cb(objset_t *os, void *arg, dmu_tx_t *tx); 164 extern int zvol_create_minor(zfs_cmd_t *zc); 165 extern int zvol_remove_minor(zfs_cmd_t *zc); 166 extern int zvol_set_volsize(zfs_cmd_t *zc); 167 extern int zvol_set_volblocksize(zfs_cmd_t *zc); 168 extern int zvol_open(dev_t *devp, int flag, int otyp, cred_t *cr); 169 extern int zvol_close(dev_t dev, int flag, int otyp, cred_t *cr); 170 extern int zvol_strategy(buf_t *bp); 171 extern int zvol_read(dev_t dev, uio_t *uiop, cred_t *cr); 172 extern int zvol_write(dev_t dev, uio_t *uiop, cred_t *cr); 173 extern int zvol_aread(dev_t dev, struct aio_req *aio, cred_t *cr); 174 extern int zvol_awrite(dev_t dev, struct aio_req *aio, cred_t *cr); 175 extern int zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, 176 int *rvalp); 177 extern int zvol_busy(void); 178 extern void zvol_init(void); 179 extern void zvol_fini(void); 180 181 #endif /* _KERNEL */ 182 183 #ifdef __cplusplus 184 } 185 #endif 186 187 #endif /* _SYS_ZFS_IOCTL_H */ 188