xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/zfs_ioctl.h (revision e9dbad6f263d5570ed7ff5443ec5b958af8c24d7)
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 #include <sys/zvol.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * Property values for snapdir
42  */
43 #define	ZFS_SNAPDIR_HIDDEN		0
44 #define	ZFS_SNAPDIR_VISIBLE		1
45 
46 #define	DMU_BACKUP_VERSION (1ULL)
47 #define	DMU_BACKUP_MAGIC 0x2F5bacbacULL
48 
49 /*
50  * zfs ioctl command structure
51  */
52 typedef struct dmu_replay_record {
53 	enum {
54 		DRR_BEGIN, DRR_OBJECT, DRR_FREEOBJECTS,
55 		DRR_WRITE, DRR_FREE, DRR_END,
56 	} drr_type;
57 	uint32_t drr_pad;
58 	union {
59 		struct drr_begin {
60 			uint64_t drr_magic;
61 			uint64_t drr_version;
62 			uint64_t drr_creation_time;
63 			dmu_objset_type_t drr_type;
64 			uint32_t drr_pad;
65 			uint64_t drr_toguid;
66 			uint64_t drr_fromguid;
67 			char drr_toname[MAXNAMELEN];
68 		} drr_begin;
69 		struct drr_end {
70 			zio_cksum_t drr_checksum;
71 		} drr_end;
72 		struct drr_object {
73 			uint64_t drr_object;
74 			dmu_object_type_t drr_type;
75 			dmu_object_type_t drr_bonustype;
76 			uint32_t drr_blksz;
77 			uint32_t drr_bonuslen;
78 			uint8_t drr_checksum;
79 			uint8_t drr_compress;
80 			uint8_t drr_pad[6];
81 		} drr_object;
82 		struct drr_freeobjects {
83 			uint64_t drr_firstobj;
84 			uint64_t drr_numobjs;
85 		} drr_freeobjects;
86 		struct drr_write {
87 			uint64_t drr_object;
88 			dmu_object_type_t drr_type;
89 			uint32_t drr_pad;
90 			uint64_t drr_offset;
91 			uint64_t drr_length;
92 		} drr_write;
93 		struct drr_free {
94 			uint64_t drr_object;
95 			uint64_t drr_offset;
96 			uint64_t drr_length;
97 		} drr_free;
98 	} drr_u;
99 } dmu_replay_record_t;
100 
101 typedef struct zinject_record {
102 	uint64_t	zi_objset;
103 	uint64_t	zi_object;
104 	uint64_t	zi_start;
105 	uint64_t	zi_end;
106 	uint64_t	zi_guid;
107 	uint32_t	zi_level;
108 	uint32_t	zi_error;
109 	uint64_t	zi_type;
110 	uint32_t	zi_freq;
111 } zinject_record_t;
112 
113 #define	ZINJECT_NULL		0x1
114 #define	ZINJECT_FLUSH_ARC	0x2
115 #define	ZINJECT_UNLOAD_SPA	0x4
116 
117 typedef struct zfs_cmd {
118 	char		zc_name[MAXPATHLEN];
119 	char		zc_value[MAXPATHLEN];
120 	uint64_t	zc_guid;
121 	uint64_t	zc_nvlist_src;	/* really (char *) */
122 	uint64_t	zc_nvlist_src_size;
123 	uint64_t	zc_nvlist_dst;	/* really (char *) */
124 	uint64_t	zc_nvlist_dst_size;
125 	uint64_t	zc_cookie;
126 	uint64_t	zc_cred;
127 	uint64_t	zc_dev;
128 	uint64_t	zc_objset_type;
129 	dmu_objset_stats_t zc_objset_stats;
130 	zvol_stats_t	zc_vol_stats;
131 	struct drr_begin zc_begin_record;
132 	zinject_record_t zc_inject_record;
133 	zbookmark_t	zc_bookmark;
134 } zfs_cmd_t;
135 
136 typedef struct zfs_create_data {
137 	cred_t		*zc_cred;
138 	dev_t		zc_dev;
139 	nvlist_t	*zc_props;
140 } zfs_create_data_t;
141 
142 #define	ZVOL_MAX_MINOR	(1 << 16)
143 #define	ZFS_MIN_MINOR	(ZVOL_MAX_MINOR + 1)
144 
145 #ifdef _KERNEL
146 
147 extern dev_info_t *zfs_dip;
148 
149 extern int zfs_secpolicy_write(const char *dataset, cred_t *cr);
150 extern int zfs_busy(void);
151 
152 #endif	/* _KERNEL */
153 
154 #ifdef	__cplusplus
155 }
156 #endif
157 
158 #endif	/* _SYS_ZFS_IOCTL_H */
159