xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/zfs_ioctl.h (revision ab04eb8ef60d9dc9614d6cccffc474f24ca1d162)
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 /*
22*ab04eb8eStimh  * Copyright 2008 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30fa9e4066Sahrens 
31fa9e4066Sahrens #include <sys/cred.h>
32fa9e4066Sahrens #include <sys/dmu.h>
33ea8dc4b6Seschrock #include <sys/zio.h>
34ecd6cf80Smarks #include <sys/dsl_deleg.h>
35fa9e4066Sahrens 
36da6c28aaSamw #ifdef _KERNEL
37da6c28aaSamw #include <sys/nvpair.h>
38da6c28aaSamw #endif	/* _KERNEL */
39da6c28aaSamw 
40fa9e4066Sahrens #ifdef	__cplusplus
41fa9e4066Sahrens extern "C" {
42fa9e4066Sahrens #endif
43fa9e4066Sahrens 
44fa9e4066Sahrens /*
45fa9e4066Sahrens  * Property values for snapdir
46fa9e4066Sahrens  */
47a0965f35Sbonwick #define	ZFS_SNAPDIR_HIDDEN		0
48a0965f35Sbonwick #define	ZFS_SNAPDIR_VISIBLE		1
49fa9e4066Sahrens 
503cb34c60Sahrens #define	DMU_BACKUP_STREAM_VERSION (1ULL)
513cb34c60Sahrens #define	DMU_BACKUP_HEADER_VERSION (2ULL)
52fa9e4066Sahrens #define	DMU_BACKUP_MAGIC 0x2F5bacbacULL
53fa9e4066Sahrens 
54*ab04eb8eStimh #define	DRR_FLAG_CLONE		(1<<0)
55*ab04eb8eStimh #define	DRR_FLAG_CI_DATA	(1<<1)
563cb34c60Sahrens 
57fa9e4066Sahrens /*
58fa9e4066Sahrens  * zfs ioctl command structure
59fa9e4066Sahrens  */
60fa9e4066Sahrens typedef struct dmu_replay_record {
61fa9e4066Sahrens 	enum {
62fa9e4066Sahrens 		DRR_BEGIN, DRR_OBJECT, DRR_FREEOBJECTS,
63fa9e4066Sahrens 		DRR_WRITE, DRR_FREE, DRR_END,
64fa9e4066Sahrens 	} drr_type;
653cb34c60Sahrens 	uint32_t drr_payloadlen;
66fa9e4066Sahrens 	union {
67fa9e4066Sahrens 		struct drr_begin {
68fa9e4066Sahrens 			uint64_t drr_magic;
69fa9e4066Sahrens 			uint64_t drr_version;
70fa9e4066Sahrens 			uint64_t drr_creation_time;
71fa9e4066Sahrens 			dmu_objset_type_t drr_type;
723cb34c60Sahrens 			uint32_t drr_flags;
73fa9e4066Sahrens 			uint64_t drr_toguid;
74fa9e4066Sahrens 			uint64_t drr_fromguid;
75fa9e4066Sahrens 			char drr_toname[MAXNAMELEN];
76fa9e4066Sahrens 		} drr_begin;
77fa9e4066Sahrens 		struct drr_end {
78ea8dc4b6Seschrock 			zio_cksum_t drr_checksum;
79fa9e4066Sahrens 		} drr_end;
80fa9e4066Sahrens 		struct drr_object {
81fa9e4066Sahrens 			uint64_t drr_object;
82fa9e4066Sahrens 			dmu_object_type_t drr_type;
83fa9e4066Sahrens 			dmu_object_type_t drr_bonustype;
84fa9e4066Sahrens 			uint32_t drr_blksz;
85fa9e4066Sahrens 			uint32_t drr_bonuslen;
86fa9e4066Sahrens 			uint8_t drr_checksum;
87fa9e4066Sahrens 			uint8_t drr_compress;
88fa9e4066Sahrens 			uint8_t drr_pad[6];
89a2eea2e1Sahrens 			/* bonus content follows */
90fa9e4066Sahrens 		} drr_object;
91fa9e4066Sahrens 		struct drr_freeobjects {
92fa9e4066Sahrens 			uint64_t drr_firstobj;
93fa9e4066Sahrens 			uint64_t drr_numobjs;
94fa9e4066Sahrens 		} drr_freeobjects;
95fa9e4066Sahrens 		struct drr_write {
96fa9e4066Sahrens 			uint64_t drr_object;
97fa9e4066Sahrens 			dmu_object_type_t drr_type;
98fa9e4066Sahrens 			uint32_t drr_pad;
99fa9e4066Sahrens 			uint64_t drr_offset;
100fa9e4066Sahrens 			uint64_t drr_length;
101a2eea2e1Sahrens 			/* content follows */
102fa9e4066Sahrens 		} drr_write;
103fa9e4066Sahrens 		struct drr_free {
104fa9e4066Sahrens 			uint64_t drr_object;
105fa9e4066Sahrens 			uint64_t drr_offset;
106fa9e4066Sahrens 			uint64_t drr_length;
107fa9e4066Sahrens 		} drr_free;
108fa9e4066Sahrens 	} drr_u;
109fa9e4066Sahrens } dmu_replay_record_t;
110fa9e4066Sahrens 
111ea8dc4b6Seschrock typedef struct zinject_record {
112ea8dc4b6Seschrock 	uint64_t	zi_objset;
113ea8dc4b6Seschrock 	uint64_t	zi_object;
114ea8dc4b6Seschrock 	uint64_t	zi_start;
115ea8dc4b6Seschrock 	uint64_t	zi_end;
116ea8dc4b6Seschrock 	uint64_t	zi_guid;
117ea8dc4b6Seschrock 	uint32_t	zi_level;
118ea8dc4b6Seschrock 	uint32_t	zi_error;
119ea8dc4b6Seschrock 	uint64_t	zi_type;
120ea8dc4b6Seschrock 	uint32_t	zi_freq;
121ecd6cf80Smarks 	uint32_t	zi_pad;	/* pad out to 64 bit alignment */
122ea8dc4b6Seschrock } zinject_record_t;
123ea8dc4b6Seschrock 
124ea8dc4b6Seschrock #define	ZINJECT_NULL		0x1
125ea8dc4b6Seschrock #define	ZINJECT_FLUSH_ARC	0x2
126ea8dc4b6Seschrock #define	ZINJECT_UNLOAD_SPA	0x4
127ea8dc4b6Seschrock 
128ecd6cf80Smarks typedef struct zfs_share {
129ecd6cf80Smarks 	uint64_t	z_exportdata;
130ecd6cf80Smarks 	uint64_t	z_sharedata;
131ecd6cf80Smarks 	uint64_t	z_sharetype;	/* 0 = share, 1 = unshare */
132ecd6cf80Smarks 	uint64_t	z_sharemax;  /* max length of share string */
133ecd6cf80Smarks } zfs_share_t;
134ecd6cf80Smarks 
135de8267e0Stimh /*
136de8267e0Stimh  * ZFS file systems may behave the usual, POSIX-compliant way, where
137de8267e0Stimh  * name lookups are case-sensitive.  They may also be set up so that
138de8267e0Stimh  * all the name lookups are case-insensitive, or so that only some
139de8267e0Stimh  * lookups, the ones that set an FIGNORECASE flag, are case-insensitive.
140de8267e0Stimh  */
141de8267e0Stimh typedef enum zfs_case {
142de8267e0Stimh 	ZFS_CASE_SENSITIVE,
143de8267e0Stimh 	ZFS_CASE_INSENSITIVE,
144de8267e0Stimh 	ZFS_CASE_MIXED
145de8267e0Stimh } zfs_case_t;
146de8267e0Stimh 
147fa9e4066Sahrens typedef struct zfs_cmd {
14815f66a7fSek 	char		zc_name[MAXPATHLEN];
14955434c77Sek 	char		zc_value[MAXPATHLEN * 2];
1503cb34c60Sahrens 	char		zc_string[MAXNAMELEN];
151ea8dc4b6Seschrock 	uint64_t	zc_guid;
152990b4856Slling 	uint64_t	zc_nvlist_conf;		/* really (char *) */
153990b4856Slling 	uint64_t	zc_nvlist_conf_size;
154990b4856Slling 	uint64_t	zc_nvlist_src;		/* really (char *) */
155e9dbad6fSeschrock 	uint64_t	zc_nvlist_src_size;
156990b4856Slling 	uint64_t	zc_nvlist_dst;		/* really (char *) */
157e9dbad6fSeschrock 	uint64_t	zc_nvlist_dst_size;
158fa9e4066Sahrens 	uint64_t	zc_cookie;
159fa9e4066Sahrens 	uint64_t	zc_objset_type;
160ecd6cf80Smarks 	uint64_t	zc_perm_action;
161990b4856Slling 	uint64_t 	zc_history;		/* really (char *) */
162ecd6cf80Smarks 	uint64_t 	zc_history_len;
16306eeb2adSek 	uint64_t	zc_history_offset;
16455434c77Sek 	uint64_t	zc_obj;
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;
169fa9e4066Sahrens } zfs_cmd_t;
170fa9e4066Sahrens 
171a0965f35Sbonwick #define	ZVOL_MAX_MINOR	(1 << 16)
172a0965f35Sbonwick #define	ZFS_MIN_MINOR	(ZVOL_MAX_MINOR + 1)
173a0965f35Sbonwick 
174fa9e4066Sahrens #ifdef _KERNEL
175fa9e4066Sahrens 
176da6c28aaSamw typedef struct zfs_creat {
177de8267e0Stimh 	nvlist_t	*zct_zplprops;
178da6c28aaSamw 	nvlist_t	*zct_props;
179da6c28aaSamw } zfs_creat_t;
180da6c28aaSamw 
181fa9e4066Sahrens extern dev_info_t *zfs_dip;
182fa9e4066Sahrens 
183ecd6cf80Smarks extern int zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr);
184ecd6cf80Smarks extern int zfs_secpolicy_rename_perms(const char *from,
185ecd6cf80Smarks     const char *to, cred_t *cr);
186ecd6cf80Smarks extern int zfs_secpolicy_destroy_perms(const char *name, cred_t *cr);
187fa9e4066Sahrens extern int zfs_busy(void);
188cdf5b4caSmmusante extern int zfs_unmount_snap(char *, void *);
189fa9e4066Sahrens 
190fa9e4066Sahrens #endif	/* _KERNEL */
191fa9e4066Sahrens 
192fa9e4066Sahrens #ifdef	__cplusplus
193fa9e4066Sahrens }
194fa9e4066Sahrens #endif
195fa9e4066Sahrens 
196fa9e4066Sahrens #endif	/* _SYS_ZFS_IOCTL_H */
197