xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/zfs_ioctl.h (revision a0965f35d4137b1f6bb1655ae1cb8fee88dfa66f)
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 /*
40  * Property values for snapdir
41  */
42 #define	ZFS_SNAPDIR_HIDDEN		0
43 #define	ZFS_SNAPDIR_VISIBLE		1
44 
45 typedef struct zfs_stats {
46 	uint64_t	zs_atime;
47 	uint64_t	zs_recordsize;
48 	uint64_t	zs_readonly;
49 	uint64_t	zs_devices;
50 	uint64_t	zs_exec;
51 	uint64_t	zs_setuid;
52 	uint64_t	zs_snapdir;
53 	uint64_t	zs_acl_mode;
54 	uint64_t	zs_acl_inherit;
55 	char		zs_mountpoint[MAXNAMELEN];
56 	char		zs_atime_setpoint[MAXNAMELEN];
57 	char		zs_recordsize_setpoint[MAXNAMELEN];
58 	char		zs_readonly_setpoint[MAXNAMELEN];
59 	char		zs_devices_setpoint[MAXNAMELEN];
60 	char		zs_setuid_setpoint[MAXNAMELEN];
61 	char		zs_exec_setpoint[MAXNAMELEN];
62 	char		zs_mountpoint_setpoint[MAXNAMELEN];
63 	char		zs_sharenfs[MAXNAMELEN];
64 	char		zs_sharenfs_setpoint[MAXNAMELEN];
65 	char		zs_snapdir_setpoint[MAXNAMELEN];
66 	char		zs_acl_mode_setpoint[MAXNAMELEN];
67 	char		zs_acl_inherit_setpoint[MAXNAMELEN];
68 } zfs_stats_t;
69 
70 #define	DMU_BACKUP_VERSION (1ULL)
71 #define	DMU_BACKUP_MAGIC 0x2F5bacbacULL
72 
73 /*
74  * zfs ioctl command structure
75  */
76 typedef struct dmu_replay_record {
77 	enum {
78 		DRR_BEGIN, DRR_OBJECT, DRR_FREEOBJECTS,
79 		DRR_WRITE, DRR_FREE, DRR_END,
80 	} drr_type;
81 	uint32_t drr_pad;
82 	union {
83 		struct drr_begin {
84 			uint64_t drr_magic;
85 			uint64_t drr_version;
86 			uint64_t drr_creation_time;
87 			dmu_objset_type_t drr_type;
88 			uint32_t drr_pad;
89 			uint64_t drr_toguid;
90 			uint64_t drr_fromguid;
91 			char drr_toname[MAXNAMELEN];
92 		} drr_begin;
93 		struct drr_end {
94 			uint64_t drr_checksum;
95 		} drr_end;
96 		struct drr_object {
97 			uint64_t drr_object;
98 			dmu_object_type_t drr_type;
99 			dmu_object_type_t drr_bonustype;
100 			uint32_t drr_blksz;
101 			uint32_t drr_bonuslen;
102 			uint8_t drr_checksum;
103 			uint8_t drr_compress;
104 			uint8_t drr_pad[6];
105 		} drr_object;
106 		struct drr_freeobjects {
107 			uint64_t drr_firstobj;
108 			uint64_t drr_numobjs;
109 		} drr_freeobjects;
110 		struct drr_write {
111 			uint64_t drr_object;
112 			dmu_object_type_t drr_type;
113 			uint32_t drr_pad;
114 			uint64_t drr_offset;
115 			uint64_t drr_length;
116 		} drr_write;
117 		struct drr_free {
118 			uint64_t drr_object;
119 			uint64_t drr_offset;
120 			uint64_t drr_length;
121 		} drr_free;
122 	} drr_u;
123 } dmu_replay_record_t;
124 
125 typedef struct zfs_cmd {
126 	char		zc_name[MAXNAMELEN];
127 	char		zc_prop_name[MAXNAMELEN];
128 	char		zc_prop_value[MAXPATHLEN];
129 	char		zc_root[MAXPATHLEN];
130 	char		zc_filename[MAXPATHLEN];
131 	uint32_t	zc_intsz;
132 	uint32_t	zc_numints;
133 	uint64_t	zc_pool_guid;
134 	uint64_t	zc_config_src;	/* really (char *) */
135 	uint64_t	zc_config_src_size;
136 	uint64_t	zc_config_dst;	/* really (char *) */
137 	uint64_t	zc_config_dst_size;
138 	uint64_t	zc_cookie;
139 	uint64_t	zc_cred;
140 	uint64_t	zc_dev;
141 	uint64_t	zc_volsize;
142 	uint64_t	zc_volblocksize;
143 	uint64_t	zc_objset_type;
144 	zfs_stats_t	zc_zfs_stats;
145 	dmu_object_info_t zc_object_info;
146 	dmu_objset_stats_t zc_objset_stats;
147 	struct drr_begin zc_begin_record;
148 } zfs_cmd_t;
149 
150 #define	ZVOL_MAX_MINOR	(1 << 16)
151 #define	ZFS_MIN_MINOR	(ZVOL_MAX_MINOR + 1)
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