xref: /freebsd/sys/contrib/openzfs/include/sys/xvattr.h (revision 271171e0)
1eda14cbcSMatt Macy /*
2eda14cbcSMatt Macy  * CDDL HEADER START
3eda14cbcSMatt Macy  *
4eda14cbcSMatt Macy  * The contents of this file are subject to the terms of the
5eda14cbcSMatt Macy  * Common Development and Distribution License (the "License").
6eda14cbcSMatt Macy  * You may not use this file except in compliance with the License.
7eda14cbcSMatt Macy  *
8eda14cbcSMatt Macy  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*271171e0SMartin Matuska  * or https://opensource.org/licenses/CDDL-1.0.
10eda14cbcSMatt Macy  * See the License for the specific language governing permissions
11eda14cbcSMatt Macy  * and limitations under the License.
12eda14cbcSMatt Macy  *
13eda14cbcSMatt Macy  * When distributing Covered Code, include this CDDL HEADER in each
14eda14cbcSMatt Macy  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15eda14cbcSMatt Macy  * If applicable, add the following below this CDDL HEADER, with the
16eda14cbcSMatt Macy  * fields enclosed by brackets "[]" replaced with your own identifying
17eda14cbcSMatt Macy  * information: Portions Copyright [yyyy] [name of copyright owner]
18eda14cbcSMatt Macy  *
19eda14cbcSMatt Macy  * CDDL HEADER END
20eda14cbcSMatt Macy  */
21eda14cbcSMatt Macy 
22eda14cbcSMatt Macy /*
23eda14cbcSMatt Macy  * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
24eda14cbcSMatt Macy  */
25eda14cbcSMatt Macy 
26eda14cbcSMatt Macy /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
27eda14cbcSMatt Macy /*	  All Rights Reserved  	*/
28eda14cbcSMatt Macy 
29eda14cbcSMatt Macy /*
30eda14cbcSMatt Macy  * University Copyright- Copyright (c) 1982, 1986, 1988
31eda14cbcSMatt Macy  * The Regents of the University of California
32eda14cbcSMatt Macy  * All Rights Reserved
33eda14cbcSMatt Macy  *
34eda14cbcSMatt Macy  * University Acknowledgment- Portions of this document are derived from
35eda14cbcSMatt Macy  * software developed by the University of California, Berkeley, and its
36eda14cbcSMatt Macy  * contributors.
37eda14cbcSMatt Macy  */
38eda14cbcSMatt Macy 
39eda14cbcSMatt Macy #ifndef _SYS_XVATTR_H
40eda14cbcSMatt Macy #define	_SYS_XVATTR_H
41eda14cbcSMatt Macy 
42eda14cbcSMatt Macy #include <sys/vnode.h>
43da5137abSMartin Matuska #include <sys/string.h>
44eda14cbcSMatt Macy 
45eda14cbcSMatt Macy #define	AV_SCANSTAMP_SZ	32		/* length of anti-virus scanstamp */
46eda14cbcSMatt Macy 
47eda14cbcSMatt Macy /*
48eda14cbcSMatt Macy  * Structure of all optional attributes.
49eda14cbcSMatt Macy  */
50eda14cbcSMatt Macy typedef struct xoptattr {
51eda14cbcSMatt Macy 	inode_timespec_t xoa_createtime;	/* Create time of file */
52eda14cbcSMatt Macy 	uint8_t		xoa_archive;
53eda14cbcSMatt Macy 	uint8_t		xoa_system;
54eda14cbcSMatt Macy 	uint8_t		xoa_readonly;
55eda14cbcSMatt Macy 	uint8_t		xoa_hidden;
56eda14cbcSMatt Macy 	uint8_t		xoa_nounlink;
57eda14cbcSMatt Macy 	uint8_t		xoa_immutable;
58eda14cbcSMatt Macy 	uint8_t		xoa_appendonly;
59eda14cbcSMatt Macy 	uint8_t		xoa_nodump;
60eda14cbcSMatt Macy 	uint8_t		xoa_opaque;
61eda14cbcSMatt Macy 	uint8_t		xoa_av_quarantined;
62eda14cbcSMatt Macy 	uint8_t		xoa_av_modified;
63eda14cbcSMatt Macy 	uint8_t		xoa_av_scanstamp[AV_SCANSTAMP_SZ];
64eda14cbcSMatt Macy 	uint8_t		xoa_reparse;
65eda14cbcSMatt Macy 	uint64_t	xoa_generation;
66eda14cbcSMatt Macy 	uint8_t		xoa_offline;
67eda14cbcSMatt Macy 	uint8_t		xoa_sparse;
68eda14cbcSMatt Macy 	uint8_t		xoa_projinherit;
69eda14cbcSMatt Macy 	uint64_t	xoa_projid;
70eda14cbcSMatt Macy } xoptattr_t;
71eda14cbcSMatt Macy 
72eda14cbcSMatt Macy /*
73eda14cbcSMatt Macy  * The xvattr structure is really a variable length structure that
74eda14cbcSMatt Macy  * is made up of:
75eda14cbcSMatt Macy  * - The classic vattr_t (xva_vattr)
76eda14cbcSMatt Macy  * - a 32 bit quantity (xva_mapsize) that specifies the size of the
77eda14cbcSMatt Macy  *   attribute bitmaps in 32 bit words.
78eda14cbcSMatt Macy  * - A pointer to the returned attribute bitmap (needed because the
79eda14cbcSMatt Macy  *   previous element, the requested attribute bitmap) is variable length.
80eda14cbcSMatt Macy  * - The requested attribute bitmap, which is an array of 32 bit words.
81eda14cbcSMatt Macy  *   Callers use the XVA_SET_REQ() macro to set the bits corresponding to
82eda14cbcSMatt Macy  *   the attributes that are being requested.
83eda14cbcSMatt Macy  * - The returned attribute bitmap, which is an array of 32 bit words.
84eda14cbcSMatt Macy  *   File systems that support optional attributes use the XVA_SET_RTN()
85eda14cbcSMatt Macy  *   macro to set the bits corresponding to the attributes that are being
86eda14cbcSMatt Macy  *   returned.
87eda14cbcSMatt Macy  * - The xoptattr_t structure which contains the attribute values
88eda14cbcSMatt Macy  *
89eda14cbcSMatt Macy  * xva_mapsize determines how many words in the attribute bitmaps.
90eda14cbcSMatt Macy  * Immediately following the attribute bitmaps is the xoptattr_t.
91eda14cbcSMatt Macy  * xva_getxoptattr() is used to get the pointer to the xoptattr_t
92eda14cbcSMatt Macy  * section.
93eda14cbcSMatt Macy  */
94eda14cbcSMatt Macy 
95eda14cbcSMatt Macy #define	XVA_MAPSIZE	3		/* Size of attr bitmaps */
96eda14cbcSMatt Macy #define	XVA_MAGIC	0x78766174	/* Magic # for verification */
97eda14cbcSMatt Macy 
98eda14cbcSMatt Macy /*
99eda14cbcSMatt Macy  * The xvattr structure is an extensible structure which permits optional
100eda14cbcSMatt Macy  * attributes to be requested/returned.  File systems may or may not support
101eda14cbcSMatt Macy  * optional attributes.  They do so at their own discretion but if they do
102eda14cbcSMatt Macy  * support optional attributes, they must register the VFSFT_XVATTR feature
103eda14cbcSMatt Macy  * so that the optional attributes can be set/retrieved.
104eda14cbcSMatt Macy  *
105eda14cbcSMatt Macy  * The fields of the xvattr structure are:
106eda14cbcSMatt Macy  *
107eda14cbcSMatt Macy  * xva_vattr - The first element of an xvattr is a legacy vattr structure
108eda14cbcSMatt Macy  * which includes the common attributes.  If AT_XVATTR is set in the va_mask
109eda14cbcSMatt Macy  * then the entire structure is treated as an xvattr.  If AT_XVATTR is not
110eda14cbcSMatt Macy  * set, then only the xva_vattr structure can be used.
111eda14cbcSMatt Macy  *
112eda14cbcSMatt Macy  * xva_magic - 0x78766174 (hex for "xvat"). Magic number for verification.
113eda14cbcSMatt Macy  *
114eda14cbcSMatt Macy  * xva_mapsize - Size of requested and returned attribute bitmaps.
115eda14cbcSMatt Macy  *
116eda14cbcSMatt Macy  * xva_rtnattrmapp - Pointer to xva_rtnattrmap[].  We need this since the
117eda14cbcSMatt Macy  * size of the array before it, xva_reqattrmap[], could change which means
118eda14cbcSMatt Macy  * the location of xva_rtnattrmap[] could change.  This will allow unbundled
119eda14cbcSMatt Macy  * file systems to find the location of xva_rtnattrmap[] when the sizes change.
120eda14cbcSMatt Macy  *
121eda14cbcSMatt Macy  * xva_reqattrmap[] - Array of requested attributes.  Attributes are
122eda14cbcSMatt Macy  * represented by a specific bit in a specific element of the attribute
123eda14cbcSMatt Macy  * map array.  Callers set the bits corresponding to the attributes
124eda14cbcSMatt Macy  * that the caller wants to get/set.
125eda14cbcSMatt Macy  *
126eda14cbcSMatt Macy  * xva_rtnattrmap[] - Array of attributes that the file system was able to
127eda14cbcSMatt Macy  * process.  Not all file systems support all optional attributes.  This map
128eda14cbcSMatt Macy  * informs the caller which attributes the underlying file system was able
129eda14cbcSMatt Macy  * to set/get.  (Same structure as the requested attributes array in terms
130eda14cbcSMatt Macy  * of each attribute  corresponding to specific bits and array elements.)
131eda14cbcSMatt Macy  *
132eda14cbcSMatt Macy  * xva_xoptattrs - Structure containing values of optional attributes.
133eda14cbcSMatt Macy  * These values are only valid if the corresponding bits in xva_reqattrmap
134eda14cbcSMatt Macy  * are set and the underlying file system supports those attributes.
135eda14cbcSMatt Macy  */
136eda14cbcSMatt Macy typedef struct xvattr {
137eda14cbcSMatt Macy 	vattr_t		xva_vattr;	/* Embedded vattr structure */
138eda14cbcSMatt Macy 	uint32_t	xva_magic;	/* Magic Number */
139eda14cbcSMatt Macy 	uint32_t	xva_mapsize;	/* Size of attr bitmap (32-bit words) */
140eda14cbcSMatt Macy 	uint32_t	*xva_rtnattrmapp;	/* Ptr to xva_rtnattrmap[] */
141eda14cbcSMatt Macy 	uint32_t	xva_reqattrmap[XVA_MAPSIZE];	/* Requested attrs */
142eda14cbcSMatt Macy 	uint32_t	xva_rtnattrmap[XVA_MAPSIZE];	/* Returned attrs */
143eda14cbcSMatt Macy 	xoptattr_t	xva_xoptattrs;	/* Optional attributes */
144eda14cbcSMatt Macy } xvattr_t;
145eda14cbcSMatt Macy 
146eda14cbcSMatt Macy /*
147eda14cbcSMatt Macy  * Attribute bits used in the extensible attribute's (xva's) attribute
148eda14cbcSMatt Macy  * bitmaps.  Note that the bitmaps are made up of a variable length number
149eda14cbcSMatt Macy  * of 32-bit words.  The convention is to use XAT{n}_{attrname} where "n"
150eda14cbcSMatt Macy  * is the element in the bitmap (starting at 1).  This convention is for
151eda14cbcSMatt Macy  * the convenience of the maintainer to keep track of which element each
152eda14cbcSMatt Macy  * attribute belongs to.
153eda14cbcSMatt Macy  *
154eda14cbcSMatt Macy  * NOTE THAT CONSUMERS MUST *NOT* USE THE XATn_* DEFINES DIRECTLY.  CONSUMERS
155eda14cbcSMatt Macy  * MUST USE THE XAT_* DEFINES.
156eda14cbcSMatt Macy  */
157eda14cbcSMatt Macy #define	XAT0_INDEX	0LL		/* Index into bitmap for XAT0 attrs */
158eda14cbcSMatt Macy #define	XAT0_CREATETIME	0x00000001	/* Create time of file */
159eda14cbcSMatt Macy #define	XAT0_ARCHIVE	0x00000002	/* Archive */
160eda14cbcSMatt Macy #define	XAT0_SYSTEM	0x00000004	/* System */
161eda14cbcSMatt Macy #define	XAT0_READONLY	0x00000008	/* Readonly */
162eda14cbcSMatt Macy #define	XAT0_HIDDEN	0x00000010	/* Hidden */
163eda14cbcSMatt Macy #define	XAT0_NOUNLINK	0x00000020	/* Nounlink */
164eda14cbcSMatt Macy #define	XAT0_IMMUTABLE	0x00000040	/* immutable */
165eda14cbcSMatt Macy #define	XAT0_APPENDONLY	0x00000080	/* appendonly */
166eda14cbcSMatt Macy #define	XAT0_NODUMP	0x00000100	/* nodump */
167eda14cbcSMatt Macy #define	XAT0_OPAQUE	0x00000200	/* opaque */
168eda14cbcSMatt Macy #define	XAT0_AV_QUARANTINED	0x00000400	/* anti-virus quarantine */
169eda14cbcSMatt Macy #define	XAT0_AV_MODIFIED	0x00000800	/* anti-virus modified */
170eda14cbcSMatt Macy #define	XAT0_AV_SCANSTAMP	0x00001000	/* anti-virus scanstamp */
171eda14cbcSMatt Macy #define	XAT0_REPARSE	0x00002000	/* FS reparse point */
172eda14cbcSMatt Macy #define	XAT0_GEN	0x00004000	/* object generation number */
173eda14cbcSMatt Macy #define	XAT0_OFFLINE	0x00008000	/* offline */
174eda14cbcSMatt Macy #define	XAT0_SPARSE	0x00010000	/* sparse */
175eda14cbcSMatt Macy #define	XAT0_PROJINHERIT	0x00020000	/* Create with parent projid */
176eda14cbcSMatt Macy #define	XAT0_PROJID	0x00040000	/* Project ID */
177eda14cbcSMatt Macy 
178eda14cbcSMatt Macy #define	XAT0_ALL_ATTRS	(XAT0_CREATETIME|XAT0_ARCHIVE|XAT0_SYSTEM| \
179eda14cbcSMatt Macy     XAT0_READONLY|XAT0_HIDDEN|XAT0_NOUNLINK|XAT0_IMMUTABLE|XAT0_APPENDONLY| \
180eda14cbcSMatt Macy     XAT0_NODUMP|XAT0_OPAQUE|XAT0_AV_QUARANTINED|  XAT0_AV_MODIFIED| \
181eda14cbcSMatt Macy     XAT0_AV_SCANSTAMP|XAT0_REPARSE|XATO_GEN|XAT0_OFFLINE|XAT0_SPARSE| \
182eda14cbcSMatt Macy     XAT0_PROJINHERIT | XAT0_PROJID)
183eda14cbcSMatt Macy 
184eda14cbcSMatt Macy /* Support for XAT_* optional attributes */
185eda14cbcSMatt Macy #define	XVA_MASK		0xffffffff	/* Used to mask off 32 bits */
186eda14cbcSMatt Macy #define	XVA_SHFT		32		/* Used to shift index */
187eda14cbcSMatt Macy 
188eda14cbcSMatt Macy /*
189eda14cbcSMatt Macy  * Used to pry out the index and attribute bits from the XAT_* attributes
190eda14cbcSMatt Macy  * defined below.  Note that we're masking things down to 32 bits then
191eda14cbcSMatt Macy  * casting to uint32_t.
192eda14cbcSMatt Macy  */
193eda14cbcSMatt Macy #define	XVA_INDEX(attr)		((uint32_t)(((attr) >> XVA_SHFT) & XVA_MASK))
194eda14cbcSMatt Macy #define	XVA_ATTRBIT(attr)	((uint32_t)((attr) & XVA_MASK))
195eda14cbcSMatt Macy 
196eda14cbcSMatt Macy /*
197eda14cbcSMatt Macy  * The following defines present a "flat namespace" so that consumers don't
198eda14cbcSMatt Macy  * need to keep track of which element belongs to which bitmap entry.
199eda14cbcSMatt Macy  *
200eda14cbcSMatt Macy  * NOTE THAT THESE MUST NEVER BE OR-ed TOGETHER
201eda14cbcSMatt Macy  */
202eda14cbcSMatt Macy #define	XAT_CREATETIME		((XAT0_INDEX << XVA_SHFT) | XAT0_CREATETIME)
203eda14cbcSMatt Macy #define	XAT_ARCHIVE		((XAT0_INDEX << XVA_SHFT) | XAT0_ARCHIVE)
204eda14cbcSMatt Macy #define	XAT_SYSTEM		((XAT0_INDEX << XVA_SHFT) | XAT0_SYSTEM)
205eda14cbcSMatt Macy #define	XAT_READONLY		((XAT0_INDEX << XVA_SHFT) | XAT0_READONLY)
206eda14cbcSMatt Macy #define	XAT_HIDDEN		((XAT0_INDEX << XVA_SHFT) | XAT0_HIDDEN)
207eda14cbcSMatt Macy #define	XAT_NOUNLINK		((XAT0_INDEX << XVA_SHFT) | XAT0_NOUNLINK)
208eda14cbcSMatt Macy #define	XAT_IMMUTABLE		((XAT0_INDEX << XVA_SHFT) | XAT0_IMMUTABLE)
209eda14cbcSMatt Macy #define	XAT_APPENDONLY		((XAT0_INDEX << XVA_SHFT) | XAT0_APPENDONLY)
210eda14cbcSMatt Macy #define	XAT_NODUMP		((XAT0_INDEX << XVA_SHFT) | XAT0_NODUMP)
211eda14cbcSMatt Macy #define	XAT_OPAQUE		((XAT0_INDEX << XVA_SHFT) | XAT0_OPAQUE)
212eda14cbcSMatt Macy #define	XAT_AV_QUARANTINED	((XAT0_INDEX << XVA_SHFT) | XAT0_AV_QUARANTINED)
213eda14cbcSMatt Macy #define	XAT_AV_MODIFIED		((XAT0_INDEX << XVA_SHFT) | XAT0_AV_MODIFIED)
214eda14cbcSMatt Macy #define	XAT_AV_SCANSTAMP	((XAT0_INDEX << XVA_SHFT) | XAT0_AV_SCANSTAMP)
215eda14cbcSMatt Macy #define	XAT_REPARSE		((XAT0_INDEX << XVA_SHFT) | XAT0_REPARSE)
216eda14cbcSMatt Macy #define	XAT_GEN			((XAT0_INDEX << XVA_SHFT) | XAT0_GEN)
217eda14cbcSMatt Macy #define	XAT_OFFLINE		((XAT0_INDEX << XVA_SHFT) | XAT0_OFFLINE)
218eda14cbcSMatt Macy #define	XAT_SPARSE		((XAT0_INDEX << XVA_SHFT) | XAT0_SPARSE)
219eda14cbcSMatt Macy #define	XAT_PROJINHERIT		((XAT0_INDEX << XVA_SHFT) | XAT0_PROJINHERIT)
220eda14cbcSMatt Macy #define	XAT_PROJID		((XAT0_INDEX << XVA_SHFT) | XAT0_PROJID)
221eda14cbcSMatt Macy 
222eda14cbcSMatt Macy /*
223eda14cbcSMatt Macy  * The returned attribute map array (xva_rtnattrmap[]) is located past the
224eda14cbcSMatt Macy  * requested attribute map array (xva_reqattrmap[]).  Its location changes
225eda14cbcSMatt Macy  * when the array sizes change.  We use a separate pointer in a known location
226eda14cbcSMatt Macy  * (xva_rtnattrmapp) to hold the location of xva_rtnattrmap[].  This is
227eda14cbcSMatt Macy  * set in xva_init()
228eda14cbcSMatt Macy  */
229eda14cbcSMatt Macy #define	XVA_RTNATTRMAP(xvap)	((xvap)->xva_rtnattrmapp)
230eda14cbcSMatt Macy 
231eda14cbcSMatt Macy /*
232eda14cbcSMatt Macy  * XVA_SET_REQ() sets an attribute bit in the proper element in the bitmap
233eda14cbcSMatt Macy  * of requested attributes (xva_reqattrmap[]).
234eda14cbcSMatt Macy  */
235eda14cbcSMatt Macy #define	XVA_SET_REQ(xvap, attr)					\
236eda14cbcSMatt Macy 	ASSERT((xvap)->xva_vattr.va_mask & AT_XVATTR);		\
237eda14cbcSMatt Macy 	ASSERT((xvap)->xva_magic == XVA_MAGIC);			\
238eda14cbcSMatt Macy 	(xvap)->xva_reqattrmap[XVA_INDEX(attr)] |= XVA_ATTRBIT(attr)
239eda14cbcSMatt Macy /*
240eda14cbcSMatt Macy  * XVA_CLR_REQ() clears an attribute bit in the proper element in the bitmap
241eda14cbcSMatt Macy  * of requested attributes (xva_reqattrmap[]).
242eda14cbcSMatt Macy  */
243eda14cbcSMatt Macy #define	XVA_CLR_REQ(xvap, attr)					\
244eda14cbcSMatt Macy 	ASSERT((xvap)->xva_vattr.va_mask & AT_XVATTR);		\
245eda14cbcSMatt Macy 	ASSERT((xvap)->xva_magic == XVA_MAGIC);			\
246eda14cbcSMatt Macy 	(xvap)->xva_reqattrmap[XVA_INDEX(attr)] &= ~XVA_ATTRBIT(attr)
247eda14cbcSMatt Macy 
248eda14cbcSMatt Macy /*
249eda14cbcSMatt Macy  * XVA_SET_RTN() sets an attribute bit in the proper element in the bitmap
250eda14cbcSMatt Macy  * of returned attributes (xva_rtnattrmap[]).
251eda14cbcSMatt Macy  */
252eda14cbcSMatt Macy #define	XVA_SET_RTN(xvap, attr)					\
253eda14cbcSMatt Macy 	ASSERT((xvap)->xva_vattr.va_mask & AT_XVATTR);		\
254eda14cbcSMatt Macy 	ASSERT((xvap)->xva_magic == XVA_MAGIC);			\
255eda14cbcSMatt Macy 	(XVA_RTNATTRMAP(xvap))[XVA_INDEX(attr)] |= XVA_ATTRBIT(attr)
256eda14cbcSMatt Macy 
257eda14cbcSMatt Macy /*
258eda14cbcSMatt Macy  * XVA_ISSET_REQ() checks the requested attribute bitmap (xva_reqattrmap[])
259eda14cbcSMatt Macy  * to see of the corresponding attribute bit is set.  If so, returns non-zero.
260eda14cbcSMatt Macy  */
261eda14cbcSMatt Macy #define	XVA_ISSET_REQ(xvap, attr)					\
262eda14cbcSMatt Macy 	((((xvap)->xva_vattr.va_mask & AT_XVATTR) &&			\
263eda14cbcSMatt Macy 		((xvap)->xva_magic == XVA_MAGIC) &&			\
264eda14cbcSMatt Macy 		((xvap)->xva_mapsize > XVA_INDEX(attr))) ?		\
265eda14cbcSMatt Macy 	((xvap)->xva_reqattrmap[XVA_INDEX(attr)] & XVA_ATTRBIT(attr)) :	0)
266eda14cbcSMatt Macy 
267eda14cbcSMatt Macy /*
268eda14cbcSMatt Macy  * XVA_ISSET_RTN() checks the returned attribute bitmap (xva_rtnattrmap[])
269eda14cbcSMatt Macy  * to see of the corresponding attribute bit is set.  If so, returns non-zero.
270eda14cbcSMatt Macy  */
271eda14cbcSMatt Macy #define	XVA_ISSET_RTN(xvap, attr)					\
272eda14cbcSMatt Macy 	((((xvap)->xva_vattr.va_mask & AT_XVATTR) &&			\
273eda14cbcSMatt Macy 		((xvap)->xva_magic == XVA_MAGIC) &&			\
274eda14cbcSMatt Macy 		((xvap)->xva_mapsize > XVA_INDEX(attr))) ?		\
275eda14cbcSMatt Macy 	((XVA_RTNATTRMAP(xvap))[XVA_INDEX(attr)] & XVA_ATTRBIT(attr)) : 0)
276eda14cbcSMatt Macy 
277eda14cbcSMatt Macy /*
278eda14cbcSMatt Macy  * Zero out the structure, set the size of the requested/returned bitmaps,
279eda14cbcSMatt Macy  * set AT_XVATTR in the embedded vattr_t's va_mask, and set up the pointer
280eda14cbcSMatt Macy  * to the returned attributes array.
281eda14cbcSMatt Macy  */
282eda14cbcSMatt Macy static inline void
xva_init(xvattr_t * xvap)283eda14cbcSMatt Macy xva_init(xvattr_t *xvap)
284eda14cbcSMatt Macy {
285da5137abSMartin Matuska 	memset(xvap, 0, sizeof (xvattr_t));
286eda14cbcSMatt Macy 	xvap->xva_mapsize = XVA_MAPSIZE;
287eda14cbcSMatt Macy 	xvap->xva_magic = XVA_MAGIC;
288eda14cbcSMatt Macy 	xvap->xva_vattr.va_mask = ATTR_XVATTR;
289eda14cbcSMatt Macy 	xvap->xva_rtnattrmapp = &(xvap->xva_rtnattrmap)[0];
290eda14cbcSMatt Macy }
291eda14cbcSMatt Macy 
292eda14cbcSMatt Macy /*
293eda14cbcSMatt Macy  * If AT_XVATTR is set, returns a pointer to the embedded xoptattr_t
294eda14cbcSMatt Macy  * structure.  Otherwise, returns NULL.
295eda14cbcSMatt Macy  */
296eda14cbcSMatt Macy static inline xoptattr_t *
xva_getxoptattr(xvattr_t * xvap)297eda14cbcSMatt Macy xva_getxoptattr(xvattr_t *xvap)
298eda14cbcSMatt Macy {
299eda14cbcSMatt Macy 	xoptattr_t *xoap = NULL;
300eda14cbcSMatt Macy 	if (xvap->xva_vattr.va_mask & AT_XVATTR)
301eda14cbcSMatt Macy 			xoap = &xvap->xva_xoptattrs;
302eda14cbcSMatt Macy 	return (xoap);
303eda14cbcSMatt Macy }
304eda14cbcSMatt Macy 
305eda14cbcSMatt Macy #define	MODEMASK	07777		/* mode bits plus permission bits */
306eda14cbcSMatt Macy #define	PERMMASK	00777		/* permission bits */
307eda14cbcSMatt Macy 
308eda14cbcSMatt Macy /*
309eda14cbcSMatt Macy  * VOP_ACCESS flags
310eda14cbcSMatt Macy  */
311eda14cbcSMatt Macy #define	V_ACE_MASK	0x1	/* mask represents  NFSv4 ACE permissions */
312eda14cbcSMatt Macy #define	V_APPEND	0x2	/* want to do append only check */
313eda14cbcSMatt Macy 
314eda14cbcSMatt Macy /*
315eda14cbcSMatt Macy  * Structure used on VOP_GETSECATTR and VOP_SETSECATTR operations
316eda14cbcSMatt Macy  */
317eda14cbcSMatt Macy 
318eda14cbcSMatt Macy typedef struct vsecattr {
319eda14cbcSMatt Macy 	uint_t		vsa_mask;	/* See below */
320eda14cbcSMatt Macy 	int		vsa_aclcnt;	/* ACL entry count */
321eda14cbcSMatt Macy 	void		*vsa_aclentp;	/* pointer to ACL entries */
322eda14cbcSMatt Macy 	int		vsa_dfaclcnt;	/* default ACL entry count */
323eda14cbcSMatt Macy 	void		*vsa_dfaclentp;	/* pointer to default ACL entries */
324eda14cbcSMatt Macy 	size_t		vsa_aclentsz;	/* ACE size in bytes of vsa_aclentp */
325eda14cbcSMatt Macy 	uint_t		vsa_aclflags;	/* ACE ACL flags */
326eda14cbcSMatt Macy } vsecattr_t;
327eda14cbcSMatt Macy 
328eda14cbcSMatt Macy /* vsa_mask values */
329eda14cbcSMatt Macy #define	VSA_ACL			0x0001
330eda14cbcSMatt Macy #define	VSA_ACLCNT		0x0002
331eda14cbcSMatt Macy #define	VSA_DFACL		0x0004
332eda14cbcSMatt Macy #define	VSA_DFACLCNT		0x0008
333eda14cbcSMatt Macy #define	VSA_ACE			0x0010
334eda14cbcSMatt Macy #define	VSA_ACECNT		0x0020
335eda14cbcSMatt Macy #define	VSA_ACE_ALLTYPES	0x0040
336eda14cbcSMatt Macy #define	VSA_ACE_ACLFLAGS	0x0080	/* get/set ACE ACL flags */
337eda14cbcSMatt Macy 
338eda14cbcSMatt Macy #endif /* _SYS_XVATTR_H */
339