xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/zfs_ioctl.h (revision 46b592853d0f4f11781b6b0a7533f267c6aee132)
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 2009 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 #include <sys/cred.h>
30 #include <sys/dmu.h>
31 #include <sys/zio.h>
32 #include <sys/dsl_deleg.h>
33 
34 #ifdef _KERNEL
35 #include <sys/nvpair.h>
36 #endif	/* _KERNEL */
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 /*
43  * Property values for snapdir
44  */
45 #define	ZFS_SNAPDIR_HIDDEN		0
46 #define	ZFS_SNAPDIR_VISIBLE		1
47 
48 #define	DMU_BACKUP_STREAM_VERSION (1ULL)
49 #define	DMU_BACKUP_HEADER_VERSION (2ULL)
50 #define	DMU_BACKUP_MAGIC 0x2F5bacbacULL
51 
52 #define	DRR_FLAG_CLONE		(1<<0)
53 #define	DRR_FLAG_CI_DATA	(1<<1)
54 
55 /*
56  * zfs ioctl command structure
57  */
58 typedef struct dmu_replay_record {
59 	enum {
60 		DRR_BEGIN, DRR_OBJECT, DRR_FREEOBJECTS,
61 		DRR_WRITE, DRR_FREE, DRR_END, DRR_NUMTYPES
62 	} drr_type;
63 	uint32_t drr_payloadlen;
64 	union {
65 		struct drr_begin {
66 			uint64_t drr_magic;
67 			uint64_t drr_version;
68 			uint64_t drr_creation_time;
69 			dmu_objset_type_t drr_type;
70 			uint32_t drr_flags;
71 			uint64_t drr_toguid;
72 			uint64_t drr_fromguid;
73 			char drr_toname[MAXNAMELEN];
74 		} drr_begin;
75 		struct drr_end {
76 			zio_cksum_t drr_checksum;
77 		} drr_end;
78 		struct drr_object {
79 			uint64_t drr_object;
80 			dmu_object_type_t drr_type;
81 			dmu_object_type_t drr_bonustype;
82 			uint32_t drr_blksz;
83 			uint32_t drr_bonuslen;
84 			uint8_t drr_checksum;
85 			uint8_t drr_compress;
86 			uint8_t drr_pad[6];
87 			/* bonus content follows */
88 		} drr_object;
89 		struct drr_freeobjects {
90 			uint64_t drr_firstobj;
91 			uint64_t drr_numobjs;
92 		} drr_freeobjects;
93 		struct drr_write {
94 			uint64_t drr_object;
95 			dmu_object_type_t drr_type;
96 			uint32_t drr_pad;
97 			uint64_t drr_offset;
98 			uint64_t drr_length;
99 			/* content follows */
100 		} drr_write;
101 		struct drr_free {
102 			uint64_t drr_object;
103 			uint64_t drr_offset;
104 			uint64_t drr_length;
105 		} drr_free;
106 	} drr_u;
107 } dmu_replay_record_t;
108 
109 typedef struct zinject_record {
110 	uint64_t	zi_objset;
111 	uint64_t	zi_object;
112 	uint64_t	zi_start;
113 	uint64_t	zi_end;
114 	uint64_t	zi_guid;
115 	uint32_t	zi_level;
116 	uint32_t	zi_error;
117 	uint64_t	zi_type;
118 	uint32_t	zi_freq;
119 	uint32_t	zi_failfast;
120 	char		zi_func[MAXNAMELEN];
121 	uint32_t	zi_iotype;
122 	int32_t		zi_duration;
123 	uint64_t	zi_timer;
124 } zinject_record_t;
125 
126 #define	ZINJECT_NULL		0x1
127 #define	ZINJECT_FLUSH_ARC	0x2
128 #define	ZINJECT_UNLOAD_SPA	0x4
129 
130 typedef struct zfs_share {
131 	uint64_t	z_exportdata;
132 	uint64_t	z_sharedata;
133 	uint64_t	z_sharetype;	/* 0 = share, 1 = unshare */
134 	uint64_t	z_sharemax;  /* max length of share string */
135 } zfs_share_t;
136 
137 /*
138  * ZFS file systems may behave the usual, POSIX-compliant way, where
139  * name lookups are case-sensitive.  They may also be set up so that
140  * all the name lookups are case-insensitive, or so that only some
141  * lookups, the ones that set an FIGNORECASE flag, are case-insensitive.
142  */
143 typedef enum zfs_case {
144 	ZFS_CASE_SENSITIVE,
145 	ZFS_CASE_INSENSITIVE,
146 	ZFS_CASE_MIXED
147 } zfs_case_t;
148 
149 typedef struct zfs_cmd {
150 	char		zc_name[MAXPATHLEN];
151 	char		zc_value[MAXPATHLEN * 2];
152 	char		zc_string[MAXNAMELEN];
153 	uint64_t	zc_guid;
154 	uint64_t	zc_nvlist_conf;		/* really (char *) */
155 	uint64_t	zc_nvlist_conf_size;
156 	uint64_t	zc_nvlist_src;		/* really (char *) */
157 	uint64_t	zc_nvlist_src_size;
158 	uint64_t	zc_nvlist_dst;		/* really (char *) */
159 	uint64_t	zc_nvlist_dst_size;
160 	uint64_t	zc_cookie;
161 	uint64_t	zc_objset_type;
162 	uint64_t	zc_perm_action;
163 	uint64_t 	zc_history;		/* really (char *) */
164 	uint64_t 	zc_history_len;
165 	uint64_t	zc_history_offset;
166 	uint64_t	zc_obj;
167 	uint64_t	zc_iflags;		/* internal to zfs(7fs) */
168 	zfs_share_t	zc_share;
169 	dmu_objset_stats_t zc_objset_stats;
170 	struct drr_begin zc_begin_record;
171 	zinject_record_t zc_inject_record;
172 	boolean_t	zc_defer_destroy;
173 	boolean_t	zc_temphold;
174 } zfs_cmd_t;
175 
176 typedef struct zfs_useracct {
177 	char zu_domain[256];
178 	uid_t zu_rid;
179 	uint32_t zu_pad;
180 	uint64_t zu_space;
181 } zfs_useracct_t;
182 
183 #define	ZVOL_MAX_MINOR	(1 << 16)
184 #define	ZFS_MIN_MINOR	(ZVOL_MAX_MINOR + 1)
185 
186 #ifdef _KERNEL
187 
188 typedef struct zfs_creat {
189 	nvlist_t	*zct_zplprops;
190 	nvlist_t	*zct_props;
191 } zfs_creat_t;
192 
193 extern dev_info_t *zfs_dip;
194 
195 extern int zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr);
196 extern int zfs_secpolicy_rename_perms(const char *from,
197     const char *to, cred_t *cr);
198 extern int zfs_secpolicy_destroy_perms(const char *name, cred_t *cr);
199 extern int zfs_busy(void);
200 extern int zfs_unmount_snap(char *, void *);
201 
202 #endif	/* _KERNEL */
203 
204 #ifdef	__cplusplus
205 }
206 #endif
207 
208 #endif	/* _SYS_ZFS_IOCTL_H */
209