xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/zfs_ioctl.h (revision 88ecc943b4eb72f7c4fbbd8435997b85ef171fc3)
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,
61fa9e4066Sahrens 		DRR_WRITE, DRR_FREE, DRR_END,
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;
120*88ecc943SGeorge Wilson 	char		zi_func[MAXNAMELEN];
121ea8dc4b6Seschrock } zinject_record_t;
122ea8dc4b6Seschrock 
123ea8dc4b6Seschrock #define	ZINJECT_NULL		0x1
124ea8dc4b6Seschrock #define	ZINJECT_FLUSH_ARC	0x2
125ea8dc4b6Seschrock #define	ZINJECT_UNLOAD_SPA	0x4
126ea8dc4b6Seschrock 
127ecd6cf80Smarks typedef struct zfs_share {
128ecd6cf80Smarks 	uint64_t	z_exportdata;
129ecd6cf80Smarks 	uint64_t	z_sharedata;
130ecd6cf80Smarks 	uint64_t	z_sharetype;	/* 0 = share, 1 = unshare */
131ecd6cf80Smarks 	uint64_t	z_sharemax;  /* max length of share string */
132ecd6cf80Smarks } zfs_share_t;
133ecd6cf80Smarks 
134de8267e0Stimh /*
135de8267e0Stimh  * ZFS file systems may behave the usual, POSIX-compliant way, where
136de8267e0Stimh  * name lookups are case-sensitive.  They may also be set up so that
137de8267e0Stimh  * all the name lookups are case-insensitive, or so that only some
138de8267e0Stimh  * lookups, the ones that set an FIGNORECASE flag, are case-insensitive.
139de8267e0Stimh  */
140de8267e0Stimh typedef enum zfs_case {
141de8267e0Stimh 	ZFS_CASE_SENSITIVE,
142de8267e0Stimh 	ZFS_CASE_INSENSITIVE,
143de8267e0Stimh 	ZFS_CASE_MIXED
144de8267e0Stimh } zfs_case_t;
145de8267e0Stimh 
146fa9e4066Sahrens typedef struct zfs_cmd {
14715f66a7fSek 	char		zc_name[MAXPATHLEN];
14855434c77Sek 	char		zc_value[MAXPATHLEN * 2];
1493cb34c60Sahrens 	char		zc_string[MAXNAMELEN];
150ea8dc4b6Seschrock 	uint64_t	zc_guid;
151990b4856Slling 	uint64_t	zc_nvlist_conf;		/* really (char *) */
152990b4856Slling 	uint64_t	zc_nvlist_conf_size;
153990b4856Slling 	uint64_t	zc_nvlist_src;		/* really (char *) */
154e9dbad6fSeschrock 	uint64_t	zc_nvlist_src_size;
155990b4856Slling 	uint64_t	zc_nvlist_dst;		/* really (char *) */
156e9dbad6fSeschrock 	uint64_t	zc_nvlist_dst_size;
157fa9e4066Sahrens 	uint64_t	zc_cookie;
158fa9e4066Sahrens 	uint64_t	zc_objset_type;
159ecd6cf80Smarks 	uint64_t	zc_perm_action;
160990b4856Slling 	uint64_t 	zc_history;		/* really (char *) */
161ecd6cf80Smarks 	uint64_t 	zc_history_len;
16206eeb2adSek 	uint64_t	zc_history_offset;
16355434c77Sek 	uint64_t	zc_obj;
164478ed9adSEric Taylor 	uint64_t	zc_iflags;		/* internal to zfs(7fs) */
165ecd6cf80Smarks 	zfs_share_t	zc_share;
166fa9e4066Sahrens 	dmu_objset_stats_t zc_objset_stats;
167fa9e4066Sahrens 	struct drr_begin zc_begin_record;
168ea8dc4b6Seschrock 	zinject_record_t zc_inject_record;
169842727c2SChris Kirby 	boolean_t	zc_defer_destroy;
170ca45db41SChris Kirby 	boolean_t	zc_temphold;
171fa9e4066Sahrens } zfs_cmd_t;
172fa9e4066Sahrens 
17314843421SMatthew Ahrens typedef struct zfs_useracct {
17414843421SMatthew Ahrens 	char zu_domain[256];
17514843421SMatthew Ahrens 	uid_t zu_rid;
17614843421SMatthew Ahrens 	uint32_t zu_pad;
17714843421SMatthew Ahrens 	uint64_t zu_space;
17814843421SMatthew Ahrens } zfs_useracct_t;
17914843421SMatthew Ahrens 
180a0965f35Sbonwick #define	ZVOL_MAX_MINOR	(1 << 16)
181a0965f35Sbonwick #define	ZFS_MIN_MINOR	(ZVOL_MAX_MINOR + 1)
182a0965f35Sbonwick 
183fa9e4066Sahrens #ifdef _KERNEL
184fa9e4066Sahrens 
185da6c28aaSamw typedef struct zfs_creat {
186de8267e0Stimh 	nvlist_t	*zct_zplprops;
187da6c28aaSamw 	nvlist_t	*zct_props;
188da6c28aaSamw } zfs_creat_t;
189da6c28aaSamw 
190fa9e4066Sahrens extern dev_info_t *zfs_dip;
191fa9e4066Sahrens 
192ecd6cf80Smarks extern int zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr);
193ecd6cf80Smarks extern int zfs_secpolicy_rename_perms(const char *from,
194ecd6cf80Smarks     const char *to, cred_t *cr);
195ecd6cf80Smarks extern int zfs_secpolicy_destroy_perms(const char *name, cred_t *cr);
196fa9e4066Sahrens extern int zfs_busy(void);
197cdf5b4caSmmusante extern int zfs_unmount_snap(char *, void *);
198fa9e4066Sahrens 
199fa9e4066Sahrens #endif	/* _KERNEL */
200fa9e4066Sahrens 
201fa9e4066Sahrens #ifdef	__cplusplus
202fa9e4066Sahrens }
203fa9e4066Sahrens #endif
204fa9e4066Sahrens 
205fa9e4066Sahrens #endif	/* _SYS_ZFS_IOCTL_H */
206