xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/zfs_ioctl.h (revision 8f18d1fadf6a0c20fac9ff7259a5368faa3c3bfb)
1fa9e4066Sahrens /*
2fa9e4066Sahrens  * CDDL HEADER START
3fa9e4066Sahrens  *
4fa9e4066Sahrens  * The contents of this file are subject to the terms of the
5ea8dc4b6Seschrock  * Common Development and Distribution License (the "License").
6ea8dc4b6Seschrock  * You may not use this file except in compliance with the License.
7fa9e4066Sahrens  *
8fa9e4066Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fa9e4066Sahrens  * or http://www.opensolaris.org/os/licensing.
10fa9e4066Sahrens  * See the License for the specific language governing permissions
11fa9e4066Sahrens  * and limitations under the License.
12fa9e4066Sahrens  *
13fa9e4066Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
14fa9e4066Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fa9e4066Sahrens  * If applicable, add the following below this CDDL HEADER, with the
16fa9e4066Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
17fa9e4066Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
18fa9e4066Sahrens  *
19fa9e4066Sahrens  * CDDL HEADER END
20fa9e4066Sahrens  */
21fa9e4066Sahrens /*
222c2961f8Sjose borrego  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23fa9e4066Sahrens  * Use is subject to license terms.
24fa9e4066Sahrens  */
25fa9e4066Sahrens 
26fa9e4066Sahrens #ifndef	_SYS_ZFS_IOCTL_H
27fa9e4066Sahrens #define	_SYS_ZFS_IOCTL_H
28fa9e4066Sahrens 
29fa9e4066Sahrens #include <sys/cred.h>
30fa9e4066Sahrens #include <sys/dmu.h>
31ea8dc4b6Seschrock #include <sys/zio.h>
32ecd6cf80Smarks #include <sys/dsl_deleg.h>
33fa9e4066Sahrens 
34da6c28aaSamw #ifdef _KERNEL
35da6c28aaSamw #include <sys/nvpair.h>
36da6c28aaSamw #endif	/* _KERNEL */
37da6c28aaSamw 
38fa9e4066Sahrens #ifdef	__cplusplus
39fa9e4066Sahrens extern "C" {
40fa9e4066Sahrens #endif
41fa9e4066Sahrens 
42fa9e4066Sahrens /*
43fa9e4066Sahrens  * Property values for snapdir
44fa9e4066Sahrens  */
45a0965f35Sbonwick #define	ZFS_SNAPDIR_HIDDEN		0
46a0965f35Sbonwick #define	ZFS_SNAPDIR_VISIBLE		1
47fa9e4066Sahrens 
483cb34c60Sahrens #define	DMU_BACKUP_STREAM_VERSION (1ULL)
493cb34c60Sahrens #define	DMU_BACKUP_HEADER_VERSION (2ULL)
50fa9e4066Sahrens #define	DMU_BACKUP_MAGIC 0x2F5bacbacULL
51fa9e4066Sahrens 
52ab04eb8eStimh #define	DRR_FLAG_CLONE		(1<<0)
53ab04eb8eStimh #define	DRR_FLAG_CI_DATA	(1<<1)
543cb34c60Sahrens 
55fa9e4066Sahrens /*
56fa9e4066Sahrens  * zfs ioctl command structure
57fa9e4066Sahrens  */
58fa9e4066Sahrens typedef struct dmu_replay_record {
59fa9e4066Sahrens 	enum {
60fa9e4066Sahrens 		DRR_BEGIN, DRR_OBJECT, DRR_FREEOBJECTS,
61495db6fbSLori Alt 		DRR_WRITE, DRR_FREE, DRR_END, DRR_NUMTYPES
62fa9e4066Sahrens 	} drr_type;
633cb34c60Sahrens 	uint32_t drr_payloadlen;
64fa9e4066Sahrens 	union {
65fa9e4066Sahrens 		struct drr_begin {
66fa9e4066Sahrens 			uint64_t drr_magic;
67fa9e4066Sahrens 			uint64_t drr_version;
68fa9e4066Sahrens 			uint64_t drr_creation_time;
69fa9e4066Sahrens 			dmu_objset_type_t drr_type;
703cb34c60Sahrens 			uint32_t drr_flags;
71fa9e4066Sahrens 			uint64_t drr_toguid;
72fa9e4066Sahrens 			uint64_t drr_fromguid;
73fa9e4066Sahrens 			char drr_toname[MAXNAMELEN];
74fa9e4066Sahrens 		} drr_begin;
75fa9e4066Sahrens 		struct drr_end {
76ea8dc4b6Seschrock 			zio_cksum_t drr_checksum;
77fa9e4066Sahrens 		} drr_end;
78fa9e4066Sahrens 		struct drr_object {
79fa9e4066Sahrens 			uint64_t drr_object;
80fa9e4066Sahrens 			dmu_object_type_t drr_type;
81fa9e4066Sahrens 			dmu_object_type_t drr_bonustype;
82fa9e4066Sahrens 			uint32_t drr_blksz;
83fa9e4066Sahrens 			uint32_t drr_bonuslen;
84fa9e4066Sahrens 			uint8_t drr_checksum;
85fa9e4066Sahrens 			uint8_t drr_compress;
86fa9e4066Sahrens 			uint8_t drr_pad[6];
87a2eea2e1Sahrens 			/* bonus content follows */
88fa9e4066Sahrens 		} drr_object;
89fa9e4066Sahrens 		struct drr_freeobjects {
90fa9e4066Sahrens 			uint64_t drr_firstobj;
91fa9e4066Sahrens 			uint64_t drr_numobjs;
92fa9e4066Sahrens 		} drr_freeobjects;
93fa9e4066Sahrens 		struct drr_write {
94fa9e4066Sahrens 			uint64_t drr_object;
95fa9e4066Sahrens 			dmu_object_type_t drr_type;
96fa9e4066Sahrens 			uint32_t drr_pad;
97fa9e4066Sahrens 			uint64_t drr_offset;
98fa9e4066Sahrens 			uint64_t drr_length;
99a2eea2e1Sahrens 			/* content follows */
100fa9e4066Sahrens 		} drr_write;
101fa9e4066Sahrens 		struct drr_free {
102fa9e4066Sahrens 			uint64_t drr_object;
103fa9e4066Sahrens 			uint64_t drr_offset;
104fa9e4066Sahrens 			uint64_t drr_length;
105fa9e4066Sahrens 		} drr_free;
106fa9e4066Sahrens 	} drr_u;
107fa9e4066Sahrens } dmu_replay_record_t;
108fa9e4066Sahrens 
109ea8dc4b6Seschrock typedef struct zinject_record {
110ea8dc4b6Seschrock 	uint64_t	zi_objset;
111ea8dc4b6Seschrock 	uint64_t	zi_object;
112ea8dc4b6Seschrock 	uint64_t	zi_start;
113ea8dc4b6Seschrock 	uint64_t	zi_end;
114ea8dc4b6Seschrock 	uint64_t	zi_guid;
115ea8dc4b6Seschrock 	uint32_t	zi_level;
116ea8dc4b6Seschrock 	uint32_t	zi_error;
117ea8dc4b6Seschrock 	uint64_t	zi_type;
118ea8dc4b6Seschrock 	uint32_t	zi_freq;
1198956713aSEric Schrock 	uint32_t	zi_failfast;
12088ecc943SGeorge Wilson 	char		zi_func[MAXNAMELEN];
121*8f18d1faSGeorge Wilson 	uint32_t	zi_iotype;
122*8f18d1faSGeorge Wilson 	uint32_t	zi_pad;		/* 64-bit alignment */
123ea8dc4b6Seschrock } zinject_record_t;
124ea8dc4b6Seschrock 
125ea8dc4b6Seschrock #define	ZINJECT_NULL		0x1
126ea8dc4b6Seschrock #define	ZINJECT_FLUSH_ARC	0x2
127ea8dc4b6Seschrock #define	ZINJECT_UNLOAD_SPA	0x4
128ea8dc4b6Seschrock 
129ecd6cf80Smarks typedef struct zfs_share {
130ecd6cf80Smarks 	uint64_t	z_exportdata;
131ecd6cf80Smarks 	uint64_t	z_sharedata;
132ecd6cf80Smarks 	uint64_t	z_sharetype;	/* 0 = share, 1 = unshare */
133ecd6cf80Smarks 	uint64_t	z_sharemax;  /* max length of share string */
134ecd6cf80Smarks } zfs_share_t;
135ecd6cf80Smarks 
136de8267e0Stimh /*
137de8267e0Stimh  * ZFS file systems may behave the usual, POSIX-compliant way, where
138de8267e0Stimh  * name lookups are case-sensitive.  They may also be set up so that
139de8267e0Stimh  * all the name lookups are case-insensitive, or so that only some
140de8267e0Stimh  * lookups, the ones that set an FIGNORECASE flag, are case-insensitive.
141de8267e0Stimh  */
142de8267e0Stimh typedef enum zfs_case {
143de8267e0Stimh 	ZFS_CASE_SENSITIVE,
144de8267e0Stimh 	ZFS_CASE_INSENSITIVE,
145de8267e0Stimh 	ZFS_CASE_MIXED
146de8267e0Stimh } zfs_case_t;
147de8267e0Stimh 
148fa9e4066Sahrens typedef struct zfs_cmd {
14915f66a7fSek 	char		zc_name[MAXPATHLEN];
15055434c77Sek 	char		zc_value[MAXPATHLEN * 2];
1513cb34c60Sahrens 	char		zc_string[MAXNAMELEN];
152ea8dc4b6Seschrock 	uint64_t	zc_guid;
153990b4856Slling 	uint64_t	zc_nvlist_conf;		/* really (char *) */
154990b4856Slling 	uint64_t	zc_nvlist_conf_size;
155990b4856Slling 	uint64_t	zc_nvlist_src;		/* really (char *) */
156e9dbad6fSeschrock 	uint64_t	zc_nvlist_src_size;
157990b4856Slling 	uint64_t	zc_nvlist_dst;		/* really (char *) */
158e9dbad6fSeschrock 	uint64_t	zc_nvlist_dst_size;
159fa9e4066Sahrens 	uint64_t	zc_cookie;
160fa9e4066Sahrens 	uint64_t	zc_objset_type;
161ecd6cf80Smarks 	uint64_t	zc_perm_action;
162990b4856Slling 	uint64_t 	zc_history;		/* really (char *) */
163ecd6cf80Smarks 	uint64_t 	zc_history_len;
16406eeb2adSek 	uint64_t	zc_history_offset;
16555434c77Sek 	uint64_t	zc_obj;
166478ed9adSEric Taylor 	uint64_t	zc_iflags;		/* internal to zfs(7fs) */
167ecd6cf80Smarks 	zfs_share_t	zc_share;
168fa9e4066Sahrens 	dmu_objset_stats_t zc_objset_stats;
169fa9e4066Sahrens 	struct drr_begin zc_begin_record;
170ea8dc4b6Seschrock 	zinject_record_t zc_inject_record;
171842727c2SChris Kirby 	boolean_t	zc_defer_destroy;
172ca45db41SChris Kirby 	boolean_t	zc_temphold;
173fa9e4066Sahrens } zfs_cmd_t;
174fa9e4066Sahrens 
17514843421SMatthew Ahrens typedef struct zfs_useracct {
17614843421SMatthew Ahrens 	char zu_domain[256];
17714843421SMatthew Ahrens 	uid_t zu_rid;
17814843421SMatthew Ahrens 	uint32_t zu_pad;
17914843421SMatthew Ahrens 	uint64_t zu_space;
18014843421SMatthew Ahrens } zfs_useracct_t;
18114843421SMatthew Ahrens 
182a0965f35Sbonwick #define	ZVOL_MAX_MINOR	(1 << 16)
183a0965f35Sbonwick #define	ZFS_MIN_MINOR	(ZVOL_MAX_MINOR + 1)
184a0965f35Sbonwick 
185fa9e4066Sahrens #ifdef _KERNEL
186fa9e4066Sahrens 
187da6c28aaSamw typedef struct zfs_creat {
188de8267e0Stimh 	nvlist_t	*zct_zplprops;
189da6c28aaSamw 	nvlist_t	*zct_props;
190da6c28aaSamw } zfs_creat_t;
191da6c28aaSamw 
192fa9e4066Sahrens extern dev_info_t *zfs_dip;
193fa9e4066Sahrens 
194ecd6cf80Smarks extern int zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr);
195ecd6cf80Smarks extern int zfs_secpolicy_rename_perms(const char *from,
196ecd6cf80Smarks     const char *to, cred_t *cr);
197ecd6cf80Smarks extern int zfs_secpolicy_destroy_perms(const char *name, cred_t *cr);
198fa9e4066Sahrens extern int zfs_busy(void);
199cdf5b4caSmmusante extern int zfs_unmount_snap(char *, void *);
200fa9e4066Sahrens 
201fa9e4066Sahrens #endif	/* _KERNEL */
202fa9e4066Sahrens 
203fa9e4066Sahrens #ifdef	__cplusplus
204fa9e4066Sahrens }
205fa9e4066Sahrens #endif
206fa9e4066Sahrens 
207fa9e4066Sahrens #endif	/* _SYS_ZFS_IOCTL_H */
208