xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/zfs_ioctl.h (revision 15f66a7f2650f57ff45e30a01a5324ad3e96aaa8)
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 2006 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 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 /*
40  * Property values for snapdir
41  */
42 #define	ZFS_SNAPDIR_HIDDEN		0
43 #define	ZFS_SNAPDIR_VISIBLE		1
44 
45 #define	DMU_BACKUP_VERSION (1ULL)
46 #define	DMU_BACKUP_MAGIC 0x2F5bacbacULL
47 
48 /*
49  * zfs ioctl command structure
50  */
51 typedef struct dmu_replay_record {
52 	enum {
53 		DRR_BEGIN, DRR_OBJECT, DRR_FREEOBJECTS,
54 		DRR_WRITE, DRR_FREE, DRR_END,
55 	} drr_type;
56 	uint32_t drr_pad;
57 	union {
58 		struct drr_begin {
59 			uint64_t drr_magic;
60 			uint64_t drr_version;
61 			uint64_t drr_creation_time;
62 			dmu_objset_type_t drr_type;
63 			uint32_t drr_pad;
64 			uint64_t drr_toguid;
65 			uint64_t drr_fromguid;
66 			char drr_toname[MAXNAMELEN];
67 		} drr_begin;
68 		struct drr_end {
69 			zio_cksum_t drr_checksum;
70 		} drr_end;
71 		struct drr_object {
72 			uint64_t drr_object;
73 			dmu_object_type_t drr_type;
74 			dmu_object_type_t drr_bonustype;
75 			uint32_t drr_blksz;
76 			uint32_t drr_bonuslen;
77 			uint8_t drr_checksum;
78 			uint8_t drr_compress;
79 			uint8_t drr_pad[6];
80 		} drr_object;
81 		struct drr_freeobjects {
82 			uint64_t drr_firstobj;
83 			uint64_t drr_numobjs;
84 		} drr_freeobjects;
85 		struct drr_write {
86 			uint64_t drr_object;
87 			dmu_object_type_t drr_type;
88 			uint32_t drr_pad;
89 			uint64_t drr_offset;
90 			uint64_t drr_length;
91 		} drr_write;
92 		struct drr_free {
93 			uint64_t drr_object;
94 			uint64_t drr_offset;
95 			uint64_t drr_length;
96 		} drr_free;
97 	} drr_u;
98 } dmu_replay_record_t;
99 
100 typedef struct zinject_record {
101 	uint64_t	zi_objset;
102 	uint64_t	zi_object;
103 	uint64_t	zi_start;
104 	uint64_t	zi_end;
105 	uint64_t	zi_guid;
106 	uint32_t	zi_level;
107 	uint32_t	zi_error;
108 	uint64_t	zi_type;
109 	uint32_t	zi_freq;
110 } zinject_record_t;
111 
112 #define	ZINJECT_NULL		0x1
113 #define	ZINJECT_FLUSH_ARC	0x2
114 #define	ZINJECT_UNLOAD_SPA	0x4
115 
116 typedef struct zfs_cmd {
117 	char		zc_name[MAXPATHLEN];
118 	char		zc_prop_name[MAXNAMELEN];
119 	char		zc_prop_value[MAXPATHLEN];
120 	char		zc_root[MAXPATHLEN];
121 	char		zc_filename[MAXNAMELEN];
122 	uint32_t	zc_intsz;
123 	uint32_t	zc_numints;
124 	uint64_t	zc_guid;
125 	uint64_t	zc_config_src;	/* really (char *) */
126 	uint64_t	zc_config_src_size;
127 	uint64_t	zc_config_dst;	/* really (char *) */
128 	uint64_t	zc_config_dst_size;
129 	uint64_t	zc_cookie;
130 	uint64_t	zc_cred;
131 	uint64_t	zc_dev;
132 	uint64_t	zc_volsize;
133 	uint64_t	zc_volblocksize;
134 	uint64_t	zc_objset_type;
135 	dmu_objset_stats_t zc_objset_stats;
136 	struct drr_begin zc_begin_record;
137 	zinject_record_t zc_inject_record;
138 	zbookmark_t	zc_bookmark;
139 } zfs_cmd_t;
140 
141 #define	ZVOL_MAX_MINOR	(1 << 16)
142 #define	ZFS_MIN_MINOR	(ZVOL_MAX_MINOR + 1)
143 
144 #ifdef _KERNEL
145 
146 extern dev_info_t *zfs_dip;
147 
148 extern int zfs_secpolicy_write(const char *dataset, const char *, cred_t *cr);
149 extern int zfs_busy(void);
150 
151 extern int zvol_check_volsize(zfs_cmd_t *zc, uint64_t blocksize);
152 extern int zvol_check_volblocksize(zfs_cmd_t *zc);
153 extern int zvol_get_stats(zfs_cmd_t *zc, objset_t *os);
154 extern void zvol_create_cb(objset_t *os, void *arg, dmu_tx_t *tx);
155 extern int zvol_create_minor(zfs_cmd_t *zc);
156 extern int zvol_remove_minor(zfs_cmd_t *zc);
157 extern int zvol_set_volsize(zfs_cmd_t *zc);
158 extern int zvol_set_volblocksize(zfs_cmd_t *zc);
159 extern int zvol_open(dev_t *devp, int flag, int otyp, cred_t *cr);
160 extern int zvol_close(dev_t dev, int flag, int otyp, cred_t *cr);
161 extern int zvol_strategy(buf_t *bp);
162 extern int zvol_read(dev_t dev, uio_t *uiop, cred_t *cr);
163 extern int zvol_write(dev_t dev, uio_t *uiop, cred_t *cr);
164 extern int zvol_aread(dev_t dev, struct aio_req *aio, cred_t *cr);
165 extern int zvol_awrite(dev_t dev, struct aio_req *aio, cred_t *cr);
166 extern int zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr,
167     int *rvalp);
168 extern int zvol_busy(void);
169 extern void zvol_init(void);
170 extern void zvol_fini(void);
171 
172 #endif	/* _KERNEL */
173 
174 #ifdef	__cplusplus
175 }
176 #endif
177 
178 #endif	/* _SYS_ZFS_IOCTL_H */
179