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.
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.
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]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
27 /* All Rights Reserved */
30 * University Copyright- Copyright (c) 1982, 1986, 1988
31 * The Regents of the University of California
34 * University Acknowledgment- Portions of this document are derived from
35 * software developed by the University of California, Berkeley, and its
42 #pragma ident "%Z%%M% %I% %E% SMI"
44 #include_next <sys/vnode.h>
50 #define IS_DEVVP(vp) \
51 ((vp)->v_type == VCHR || (vp)->v_type == VBLK || (vp)->v_type == VFIFO)
53 #define V_XATTRDIR 0x0000 /* attribute unnamed directory */
55 #define AV_SCANSTAMP_SZ 32 /* length of anti-virus scanstamp */
58 * Structure of all optional attributes.
60 typedef struct xoptattr {
61 timestruc_t xoa_createtime; /* Create time of file */
67 uint8_t xoa_immutable;
68 uint8_t xoa_appendonly;
71 uint8_t xoa_av_quarantined;
72 uint8_t xoa_av_modified;
73 uint8_t xoa_av_scanstamp[AV_SCANSTAMP_SZ];
77 * The xvattr structure is really a variable length structure that
79 * - The classic vattr_t (xva_vattr)
80 * - a 32 bit quantity (xva_mapsize) that specifies the size of the
81 * attribute bitmaps in 32 bit words.
82 * - A pointer to the returned attribute bitmap (needed because the
83 * previous element, the requested attribute bitmap) is variable lenth.
84 * - The requested attribute bitmap, which is an array of 32 bit words.
85 * Callers use the XVA_SET_REQ() macro to set the bits corresponding to
86 * the attributes that are being requested.
87 * - The returned attribute bitmap, which is an array of 32 bit words.
88 * File systems that support optional attributes use the XVA_SET_RTN()
89 * macro to set the bits corresponding to the attributes that are being
91 * - The xoptattr_t structure which contains the attribute values
93 * xva_mapsize determines how many words in the attribute bitmaps.
94 * Immediately following the attribute bitmaps is the xoptattr_t.
95 * xva_getxoptattr() is used to get the pointer to the xoptattr_t
99 #define XVA_MAPSIZE 3 /* Size of attr bitmaps */
100 #define XVA_MAGIC 0x78766174 /* Magic # for verification */
103 * The xvattr structure is an extensible structure which permits optional
104 * attributes to be requested/returned. File systems may or may not support
105 * optional attributes. They do so at their own discretion but if they do
106 * support optional attributes, they must register the VFSFT_XVATTR feature
107 * so that the optional attributes can be set/retrived.
109 * The fields of the xvattr structure are:
111 * xva_vattr - The first element of an xvattr is a legacy vattr structure
112 * which includes the common attributes. If AT_XVATTR is set in the va_mask
113 * then the entire structure is treated as an xvattr. If AT_XVATTR is not
114 * set, then only the xva_vattr structure can be used.
116 * xva_magic - 0x78766174 (hex for "xvat"). Magic number for verification.
118 * xva_mapsize - Size of requested and returned attribute bitmaps.
120 * xva_rtnattrmapp - Pointer to xva_rtnattrmap[]. We need this since the
121 * size of the array before it, xva_reqattrmap[], could change which means
122 * the location of xva_rtnattrmap[] could change. This will allow unbundled
123 * file systems to find the location of xva_rtnattrmap[] when the sizes change.
125 * xva_reqattrmap[] - Array of requested attributes. Attributes are
126 * represented by a specific bit in a specific element of the attribute
127 * map array. Callers set the bits corresponding to the attributes
128 * that the caller wants to get/set.
130 * xva_rtnattrmap[] - Array of attributes that the file system was able to
131 * process. Not all file systems support all optional attributes. This map
132 * informs the caller which attributes the underlying file system was able
133 * to set/get. (Same structure as the requested attributes array in terms
134 * of each attribute corresponding to specific bits and array elements.)
136 * xva_xoptattrs - Structure containing values of optional attributes.
137 * These values are only valid if the corresponding bits in xva_reqattrmap
138 * are set and the underlying file system supports those attributes.
140 typedef struct xvattr {
141 vattr_t xva_vattr; /* Embedded vattr structure */
142 uint32_t xva_magic; /* Magic Number */
143 uint32_t xva_mapsize; /* Size of attr bitmap (32-bit words) */
144 uint32_t *xva_rtnattrmapp; /* Ptr to xva_rtnattrmap[] */
145 uint32_t xva_reqattrmap[XVA_MAPSIZE]; /* Requested attrs */
146 uint32_t xva_rtnattrmap[XVA_MAPSIZE]; /* Returned attrs */
147 xoptattr_t xva_xoptattrs; /* Optional attributes */
151 * Attributes of interest to the caller of setattr or getattr.
153 #define AT_TYPE 0x00001
154 #define AT_MODE 0x00002
155 #define AT_UID 0x00004
156 #define AT_GID 0x00008
157 #define AT_FSID 0x00010
158 #define AT_NODEID 0x00020
159 #define AT_NLINK 0x00040
160 #define AT_SIZE 0x00080
161 #define AT_ATIME 0x00100
162 #define AT_MTIME 0x00200
163 #define AT_CTIME 0x00400
164 #define AT_RDEV 0x00800
165 #define AT_BLKSIZE 0x01000
166 #define AT_NBLOCKS 0x02000
167 /* 0x04000 */ /* unused */
168 #define AT_SEQ 0x08000
170 * If AT_XVATTR is set then there are additional bits to process in
171 * the xvattr_t's attribute bitmap. If this is not set then the bitmap
172 * MUST be ignored. Note that this bit must be set/cleared explicitly.
173 * That is, setting AT_ALL will NOT set AT_XVATTR.
175 #define AT_XVATTR 0x10000
177 #define AT_ALL (AT_TYPE|AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|\
178 AT_NLINK|AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|\
179 AT_RDEV|AT_BLKSIZE|AT_NBLOCKS|AT_SEQ)
181 #define AT_STAT (AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|AT_NLINK|\
182 AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|AT_RDEV|AT_TYPE)
184 #define AT_TIMES (AT_ATIME|AT_MTIME|AT_CTIME)
186 #define AT_NOSET (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\
187 AT_BLKSIZE|AT_NBLOCKS|AT_SEQ)
190 * Attribute bits used in the extensible attribute's (xva's) attribute
191 * bitmaps. Note that the bitmaps are made up of a variable length number
192 * of 32-bit words. The convention is to use XAT{n}_{attrname} where "n"
193 * is the element in the bitmap (starting at 1). This convention is for
194 * the convenience of the maintainer to keep track of which element each
195 * attribute belongs to.
197 * NOTE THAT CONSUMERS MUST *NOT* USE THE XATn_* DEFINES DIRECTLY. CONSUMERS
198 * MUST USE THE XAT_* DEFINES.
200 #define XAT0_INDEX 0LL /* Index into bitmap for XAT0 attrs */
201 #define XAT0_CREATETIME 0x00000001 /* Create time of file */
202 #define XAT0_ARCHIVE 0x00000002 /* Archive */
203 #define XAT0_SYSTEM 0x00000004 /* System */
204 #define XAT0_READONLY 0x00000008 /* Readonly */
205 #define XAT0_HIDDEN 0x00000010 /* Hidden */
206 #define XAT0_NOUNLINK 0x00000020 /* Nounlink */
207 #define XAT0_IMMUTABLE 0x00000040 /* immutable */
208 #define XAT0_APPENDONLY 0x00000080 /* appendonly */
209 #define XAT0_NODUMP 0x00000100 /* nodump */
210 #define XAT0_OPAQUE 0x00000200 /* opaque */
211 #define XAT0_AV_QUARANTINED 0x00000400 /* anti-virus quarantine */
212 #define XAT0_AV_MODIFIED 0x00000800 /* anti-virus modified */
213 #define XAT0_AV_SCANSTAMP 0x00001000 /* anti-virus scanstamp */
215 #define XAT0_ALL_ATTRS (XAT0_CREATETIME|XAT0_ARCHIVE|XAT0_SYSTEM| \
216 XAT0_READONLY|XAT0_HIDDEN|XAT0_NOUNLINK|XAT0_IMMUTABLE|XAT0_APPENDONLY| \
217 XAT0_NODUMP|XAT0_OPAQUE|XAT0_AV_QUARANTINED| \
218 XAT0_AV_MODIFIED|XAT0_AV_SCANSTAMP)
220 /* Support for XAT_* optional attributes */
221 #define XVA_MASK 0xffffffff /* Used to mask off 32 bits */
222 #define XVA_SHFT 32 /* Used to shift index */
225 * Used to pry out the index and attribute bits from the XAT_* attributes
226 * defined below. Note that we're masking things down to 32 bits then
227 * casting to uint32_t.
229 #define XVA_INDEX(attr) ((uint32_t)(((attr) >> XVA_SHFT) & XVA_MASK))
230 #define XVA_ATTRBIT(attr) ((uint32_t)((attr) & XVA_MASK))
233 * The following defines present a "flat namespace" so that consumers don't
234 * need to keep track of which element belongs to which bitmap entry.
236 * NOTE THAT THESE MUST NEVER BE OR-ed TOGETHER
238 #define XAT_CREATETIME ((XAT0_INDEX << XVA_SHFT) | XAT0_CREATETIME)
239 #define XAT_ARCHIVE ((XAT0_INDEX << XVA_SHFT) | XAT0_ARCHIVE)
240 #define XAT_SYSTEM ((XAT0_INDEX << XVA_SHFT) | XAT0_SYSTEM)
241 #define XAT_READONLY ((XAT0_INDEX << XVA_SHFT) | XAT0_READONLY)
242 #define XAT_HIDDEN ((XAT0_INDEX << XVA_SHFT) | XAT0_HIDDEN)
243 #define XAT_NOUNLINK ((XAT0_INDEX << XVA_SHFT) | XAT0_NOUNLINK)
244 #define XAT_IMMUTABLE ((XAT0_INDEX << XVA_SHFT) | XAT0_IMMUTABLE)
245 #define XAT_APPENDONLY ((XAT0_INDEX << XVA_SHFT) | XAT0_APPENDONLY)
246 #define XAT_NODUMP ((XAT0_INDEX << XVA_SHFT) | XAT0_NODUMP)
247 #define XAT_OPAQUE ((XAT0_INDEX << XVA_SHFT) | XAT0_OPAQUE)
248 #define XAT_AV_QUARANTINED ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_QUARANTINED)
249 #define XAT_AV_MODIFIED ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_MODIFIED)
250 #define XAT_AV_SCANSTAMP ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_SCANSTAMP)
253 * The returned attribute map array (xva_rtnattrmap[]) is located past the
254 * requested attribute map array (xva_reqattrmap[]). Its location changes
255 * when the array sizes change. We use a separate pointer in a known location
256 * (xva_rtnattrmapp) to hold the location of xva_rtnattrmap[]. This is
259 #define XVA_RTNATTRMAP(xvap) ((xvap)->xva_rtnattrmapp)
262 * XVA_SET_REQ() sets an attribute bit in the proper element in the bitmap
263 * of requested attributes (xva_reqattrmap[]).
265 #define XVA_SET_REQ(xvap, attr) \
266 ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR); \
267 ASSERT((xvap)->xva_magic == XVA_MAGIC); \
268 (xvap)->xva_reqattrmap[XVA_INDEX(attr)] |= XVA_ATTRBIT(attr)
271 * XVA_SET_RTN() sets an attribute bit in the proper element in the bitmap
272 * of returned attributes (xva_rtnattrmap[]).
274 #define XVA_SET_RTN(xvap, attr) \
275 ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR); \
276 ASSERT((xvap)->xva_magic == XVA_MAGIC); \
277 (XVA_RTNATTRMAP(xvap))[XVA_INDEX(attr)] |= XVA_ATTRBIT(attr)
280 * XVA_ISSET_REQ() checks the requested attribute bitmap (xva_reqattrmap[])
281 * to see of the corresponding attribute bit is set. If so, returns non-zero.
283 #define XVA_ISSET_REQ(xvap, attr) \
284 ((((xvap)->xva_vattr.va_mask | AT_XVATTR) && \
285 ((xvap)->xva_magic == XVA_MAGIC) && \
286 ((xvap)->xva_mapsize > XVA_INDEX(attr))) ? \
287 ((xvap)->xva_reqattrmap[XVA_INDEX(attr)] & XVA_ATTRBIT(attr)) : 0)
290 * XVA_ISSET_RTN() checks the returned attribute bitmap (xva_rtnattrmap[])
291 * to see of the corresponding attribute bit is set. If so, returns non-zero.
293 #define XVA_ISSET_RTN(xvap, attr) \
294 ((((xvap)->xva_vattr.va_mask | AT_XVATTR) && \
295 ((xvap)->xva_magic == XVA_MAGIC) && \
296 ((xvap)->xva_mapsize > XVA_INDEX(attr))) ? \
297 ((XVA_RTNATTRMAP(xvap))[XVA_INDEX(attr)] & XVA_ATTRBIT(attr)) : 0)
299 #define MODEMASK 07777 /* mode bits plus permission bits */
300 #define PERMMASK 00777 /* permission bits */
306 #define V_ACE_MASK 0x1 /* mask represents NFSv4 ACE permissions */
307 #define V_APPEND 0x2 /* want to do append only check */
310 * Flags for vnode operations.
312 enum rm { RMFILE, RMDIRECTORY }; /* rm or rmdir (remove) */
313 enum create { CRCREAT, CRMKNOD, CRMKDIR }; /* reason for create */
316 * Structure used on VOP_GETSECATTR and VOP_SETSECATTR operations
319 typedef struct vsecattr {
320 uint_t vsa_mask; /* See below */
321 int vsa_aclcnt; /* ACL entry count */
322 void *vsa_aclentp; /* pointer to ACL entries */
323 int vsa_dfaclcnt; /* default ACL entry count */
324 void *vsa_dfaclentp; /* pointer to default ACL entries */
325 size_t vsa_aclentsz; /* ACE size in bytes of vsa_aclentp */
326 uint_t vsa_aclflags; /* ACE ACL flags */
329 /* vsa_mask values */
330 #define VSA_ACL 0x0001
331 #define VSA_ACLCNT 0x0002
332 #define VSA_DFACL 0x0004
333 #define VSA_DFACLCNT 0x0008
334 #define VSA_ACE 0x0010
335 #define VSA_ACECNT 0x0020
336 #define VSA_ACE_ALLTYPES 0x0040
337 #define VSA_ACE_ACLFLAGS 0x0080 /* get/set ACE ACL flags */
340 * Structure used by various vnode operations to determine
341 * the context (pid, host, identity) of a caller.
343 * The cc_caller_id is used to identify one or more callers who invoke
344 * operations, possibly on behalf of others. For example, the NFS
345 * server could have it's own cc_caller_id which can be detected by
346 * vnode/vfs operations or (FEM) monitors on those operations. New
347 * caller IDs are generated by fs_new_caller_id().
349 typedef struct caller_context {
350 pid_t cc_pid; /* Process ID of the caller */
351 int cc_sysid; /* System ID, used for remote calls */
352 u_longlong_t cc_caller_id; /* Identifier for (set of) caller(s) */
357 * Flags for VOP_LOOKUP
359 * Defined in file.h, but also possible, FIGNORECASE
362 #define LOOKUP_DIR 0x01 /* want parent dir vp */
363 #define LOOKUP_XATTR 0x02 /* lookup up extended attr dir */
364 #define CREATE_XATTR_DIR 0x04 /* Create extended attr dir */
365 #define LOOKUP_HAVE_SYSATTR_DIR 0x08 /* Already created virtual GFS dir */
368 * Flags for VOP_READDIR
370 #define V_RDDIR_ENTFLAGS 0x01 /* request dirent flags */
373 * Extensible vnode attribute (xva) routines:
374 * xva_init() initializes an xvattr_t (zero struct, init mapsize, set AT_XATTR)
375 * xva_getxoptattr() returns a ponter to the xoptattr_t section of xvattr_t
377 void xva_init(xvattr_t *);
378 xoptattr_t *xva_getxoptattr(xvattr_t *); /* Get ptr to xoptattr_t */
381 void vn_rele_async(struct vnode *vp, struct taskq *taskq);
382 void vn_rele_async_fini(void);
385 * Flags to VOP_SETATTR/VOP_GETATTR.
387 #define ATTR_UTIME 0x01 /* non-default utime(2) request */
388 #define ATTR_EXEC 0x02 /* invocation from exec(2) */
389 #define ATTR_COMM 0x04 /* yield common vp attributes */
390 #define ATTR_HINT 0x08 /* information returned will be `hint' */
391 #define ATTR_REAL 0x10 /* yield attributes of the real vp */
392 #define ATTR_NOACLCHECK 0x20 /* Don't check ACL when checking permissions */
393 #define ATTR_TRIGGER 0x40 /* Mount first if vnode is a trigger mount */
399 #endif /* _SYS_VNODE_H */