xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/zfs_ioctl.h (revision a07094369b21309434206d9b3601d162693466fc)
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 2006 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 #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 			uint64_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 zfs_cmd {
101 	char		zc_name[MAXNAMELEN];
102 	char		zc_prop_name[MAXNAMELEN];
103 	char		zc_prop_value[MAXPATHLEN];
104 	char		zc_root[MAXPATHLEN];
105 	char		zc_filename[MAXPATHLEN];
106 	uint32_t	zc_intsz;
107 	uint32_t	zc_numints;
108 	uint64_t	zc_pool_guid;
109 	uint64_t	zc_config_src;	/* really (char *) */
110 	uint64_t	zc_config_src_size;
111 	uint64_t	zc_config_dst;	/* really (char *) */
112 	uint64_t	zc_config_dst_size;
113 	uint64_t	zc_cookie;
114 	uint64_t	zc_cred;
115 	uint64_t	zc_dev;
116 	uint64_t	zc_volsize;
117 	uint64_t	zc_volblocksize;
118 	uint64_t	zc_objset_type;
119 	dmu_object_info_t zc_object_info;
120 	dmu_objset_stats_t zc_objset_stats;
121 	struct drr_begin zc_begin_record;
122 } zfs_cmd_t;
123 
124 #define	ZVOL_MAX_MINOR	(1 << 16)
125 #define	ZFS_MIN_MINOR	(ZVOL_MAX_MINOR + 1)
126 
127 #ifdef _KERNEL
128 
129 extern dev_info_t *zfs_dip;
130 
131 extern int zfs_secpolicy_write(const char *dataset, const char *, cred_t *cr);
132 extern int zfs_busy(void);
133 
134 extern int zvol_check_volsize(zfs_cmd_t *zc, uint64_t blocksize);
135 extern int zvol_check_volblocksize(zfs_cmd_t *zc);
136 extern int zvol_get_stats(zfs_cmd_t *zc, objset_t *os);
137 extern void zvol_create_cb(objset_t *os, void *arg, dmu_tx_t *tx);
138 extern int zvol_create_minor(zfs_cmd_t *zc);
139 extern int zvol_remove_minor(zfs_cmd_t *zc);
140 extern int zvol_set_volsize(zfs_cmd_t *zc);
141 extern int zvol_set_volblocksize(zfs_cmd_t *zc);
142 extern int zvol_open(dev_t *devp, int flag, int otyp, cred_t *cr);
143 extern int zvol_close(dev_t dev, int flag, int otyp, cred_t *cr);
144 extern int zvol_strategy(buf_t *bp);
145 extern int zvol_read(dev_t dev, uio_t *uiop, cred_t *cr);
146 extern int zvol_write(dev_t dev, uio_t *uiop, cred_t *cr);
147 extern int zvol_aread(dev_t dev, struct aio_req *aio, cred_t *cr);
148 extern int zvol_awrite(dev_t dev, struct aio_req *aio, cred_t *cr);
149 extern int zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr,
150     int *rvalp);
151 extern int zvol_busy(void);
152 extern void zvol_init(void);
153 extern void zvol_fini(void);
154 
155 #endif	/* _KERNEL */
156 
157 #ifdef	__cplusplus
158 }
159 #endif
160 
161 #endif	/* _SYS_ZFS_IOCTL_H */
162