FreeBSD: Fix ZFS so that snapshots under .zfs/snapshot are NFS visible
[zfs.git] / include / os / freebsd / spl / sys / vnode_impl.h
blob4e04b5e80a062f3ecb9d4c3fe2271dc5304a132f
1 /*
2 * CDDL HEADER START
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 https://opensource.org/licenses/CDDL-1.0.
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]
19 * CDDL HEADER END
23 * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2017 RackTop Systems.
27 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
33 * All Rights Reserved
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
37 * contributors.
40 #ifndef _SYS_VNODE_IMPL_H
41 #define _SYS_VNODE_IMPL_H
44 #define IS_DEVVP(vp) \
45 ((vp)->v_type == VCHR || (vp)->v_type == VBLK || (vp)->v_type == VFIFO)
47 #define AV_SCANSTAMP_SZ 32 /* length of anti-virus scanstamp */
50 * The xvattr structure is really a variable length structure that
51 * is made up of:
52 * - The classic vattr_t (xva_vattr)
53 * - a 32 bit quantity (xva_mapsize) that specifies the size of the
54 * attribute bitmaps in 32 bit words.
55 * - A pointer to the returned attribute bitmap (needed because the
56 * previous element, the requested attribute bitmap) is variable length.
57 * - The requested attribute bitmap, which is an array of 32 bit words.
58 * Callers use the XVA_SET_REQ() macro to set the bits corresponding to
59 * the attributes that are being requested.
60 * - The returned attribute bitmap, which is an array of 32 bit words.
61 * File systems that support optional attributes use the XVA_SET_RTN()
62 * macro to set the bits corresponding to the attributes that are being
63 * returned.
64 * - The xoptattr_t structure which contains the attribute values
66 * xva_mapsize determines how many words in the attribute bitmaps.
67 * Immediately following the attribute bitmaps is the xoptattr_t.
68 * xva_getxoptattr() is used to get the pointer to the xoptattr_t
69 * section.
72 #define XVA_MAPSIZE 3 /* Size of attr bitmaps */
73 #define XVA_MAGIC 0x78766174 /* Magic # for verification */
76 * The xvattr structure is an extensible structure which permits optional
77 * attributes to be requested/returned. File systems may or may not support
78 * optional attributes. They do so at their own discretion but if they do
79 * support optional attributes, they must register the VFSFT_XVATTR feature
80 * so that the optional attributes can be set/retrieved.
82 * The fields of the xvattr structure are:
84 * xva_vattr - The first element of an xvattr is a legacy vattr structure
85 * which includes the common attributes. If AT_XVATTR is set in the va_mask
86 * then the entire structure is treated as an xvattr. If AT_XVATTR is not
87 * set, then only the xva_vattr structure can be used.
89 * xva_magic - 0x78766174 (hex for "xvat"). Magic number for verification.
91 * xva_mapsize - Size of requested and returned attribute bitmaps.
93 * xva_rtnattrmapp - Pointer to xva_rtnattrmap[]. We need this since the
94 * size of the array before it, xva_reqattrmap[], could change which means
95 * the location of xva_rtnattrmap[] could change. This will allow unbundled
96 * file systems to find the location of xva_rtnattrmap[] when the sizes change.
98 * xva_reqattrmap[] - Array of requested attributes. Attributes are
99 * represented by a specific bit in a specific element of the attribute
100 * map array. Callers set the bits corresponding to the attributes
101 * that the caller wants to get/set.
103 * xva_rtnattrmap[] - Array of attributes that the file system was able to
104 * process. Not all file systems support all optional attributes. This map
105 * informs the caller which attributes the underlying file system was able
106 * to set/get. (Same structure as the requested attributes array in terms
107 * of each attribute corresponding to specific bits and array elements.)
109 * xva_xoptattrs - Structure containing values of optional attributes.
110 * These values are only valid if the corresponding bits in xva_reqattrmap
111 * are set and the underlying file system supports those attributes.
117 * Attribute bits used in the extensible attribute's (xva's) attribute
118 * bitmaps. Note that the bitmaps are made up of a variable length number
119 * of 32-bit words. The convention is to use XAT{n}_{attrname} where "n"
120 * is the element in the bitmap (starting at 1). This convention is for
121 * the convenience of the maintainer to keep track of which element each
122 * attribute belongs to.
124 * NOTE THAT CONSUMERS MUST *NOT* USE THE XATn_* DEFINES DIRECTLY. CONSUMERS
125 * MUST USE THE XAT_* DEFINES.
127 #define XAT0_INDEX 0LL /* Index into bitmap for XAT0 attrs */
128 #define XAT0_CREATETIME 0x00000001 /* Create time of file */
129 #define XAT0_ARCHIVE 0x00000002 /* Archive */
130 #define XAT0_SYSTEM 0x00000004 /* System */
131 #define XAT0_READONLY 0x00000008 /* Readonly */
132 #define XAT0_HIDDEN 0x00000010 /* Hidden */
133 #define XAT0_NOUNLINK 0x00000020 /* Nounlink */
134 #define XAT0_IMMUTABLE 0x00000040 /* immutable */
135 #define XAT0_APPENDONLY 0x00000080 /* appendonly */
136 #define XAT0_NODUMP 0x00000100 /* nodump */
137 #define XAT0_OPAQUE 0x00000200 /* opaque */
138 #define XAT0_AV_QUARANTINED 0x00000400 /* anti-virus quarantine */
139 #define XAT0_AV_MODIFIED 0x00000800 /* anti-virus modified */
140 #define XAT0_AV_SCANSTAMP 0x00001000 /* anti-virus scanstamp */
141 #define XAT0_REPARSE 0x00002000 /* FS reparse point */
142 #define XAT0_GEN 0x00004000 /* object generation number */
143 #define XAT0_OFFLINE 0x00008000 /* offline */
144 #define XAT0_SPARSE 0x00010000 /* sparse */
146 /* Support for XAT_* optional attributes */
147 #define XVA_MASK 0xffffffff /* Used to mask off 32 bits */
148 #define XVA_SHFT 32 /* Used to shift index */
151 * Used to pry out the index and attribute bits from the XAT_* attributes
152 * defined below. Note that we're masking things down to 32 bits then
153 * casting to uint32_t.
155 #define XVA_INDEX(attr) ((uint32_t)(((attr) >> XVA_SHFT) & XVA_MASK))
156 #define XVA_ATTRBIT(attr) ((uint32_t)((attr) & XVA_MASK))
159 * The following defines present a "flat namespace" so that consumers don't
160 * need to keep track of which element belongs to which bitmap entry.
162 * NOTE THAT THESE MUST NEVER BE OR-ed TOGETHER
164 #define XAT_CREATETIME ((XAT0_INDEX << XVA_SHFT) | XAT0_CREATETIME)
165 #define XAT_ARCHIVE ((XAT0_INDEX << XVA_SHFT) | XAT0_ARCHIVE)
166 #define XAT_SYSTEM ((XAT0_INDEX << XVA_SHFT) | XAT0_SYSTEM)
167 #define XAT_READONLY ((XAT0_INDEX << XVA_SHFT) | XAT0_READONLY)
168 #define XAT_HIDDEN ((XAT0_INDEX << XVA_SHFT) | XAT0_HIDDEN)
169 #define XAT_NOUNLINK ((XAT0_INDEX << XVA_SHFT) | XAT0_NOUNLINK)
170 #define XAT_IMMUTABLE ((XAT0_INDEX << XVA_SHFT) | XAT0_IMMUTABLE)
171 #define XAT_APPENDONLY ((XAT0_INDEX << XVA_SHFT) | XAT0_APPENDONLY)
172 #define XAT_NODUMP ((XAT0_INDEX << XVA_SHFT) | XAT0_NODUMP)
173 #define XAT_OPAQUE ((XAT0_INDEX << XVA_SHFT) | XAT0_OPAQUE)
174 #define XAT_AV_QUARANTINED ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_QUARANTINED)
175 #define XAT_AV_MODIFIED ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_MODIFIED)
176 #define XAT_AV_SCANSTAMP ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_SCANSTAMP)
177 #define XAT_REPARSE ((XAT0_INDEX << XVA_SHFT) | XAT0_REPARSE)
178 #define XAT_GEN ((XAT0_INDEX << XVA_SHFT) | XAT0_GEN)
179 #define XAT_OFFLINE ((XAT0_INDEX << XVA_SHFT) | XAT0_OFFLINE)
180 #define XAT_SPARSE ((XAT0_INDEX << XVA_SHFT) | XAT0_SPARSE)
183 * The returned attribute map array (xva_rtnattrmap[]) is located past the
184 * requested attribute map array (xva_reqattrmap[]). Its location changes
185 * when the array sizes change. We use a separate pointer in a known location
186 * (xva_rtnattrmapp) to hold the location of xva_rtnattrmap[]. This is
187 * set in xva_init()
189 #define XVA_RTNATTRMAP(xvap) ((xvap)->xva_rtnattrmapp)
191 #define MODEMASK 07777 /* mode bits plus permission bits */
192 #define PERMMASK 00777 /* permission bits */
195 * Flags for vnode operations.
197 enum rm { RMFILE, RMDIRECTORY }; /* rm or rmdir (remove) */
198 enum create { CRCREAT, CRMKNOD, CRMKDIR }; /* reason for create */
201 * Structure used by various vnode operations to determine
202 * the context (pid, host, identity) of a caller.
204 * The cc_caller_id is used to identify one or more callers who invoke
205 * operations, possibly on behalf of others. For example, the NFS
206 * server could have its own cc_caller_id which can be detected by
207 * vnode/vfs operations or (FEM) monitors on those operations. New
208 * caller IDs are generated by fs_new_caller_id().
210 typedef struct caller_context {
211 pid_t cc_pid; /* Process ID of the caller */
212 int cc_sysid; /* System ID, used for remote calls */
213 u_longlong_t cc_caller_id; /* Identifier for (set of) caller(s) */
214 ulong_t cc_flags;
215 } caller_context_t;
217 struct taskq;
220 * Flags for VOP_LOOKUP
222 * Defined in file.h, but also possible, FIGNORECASE and FSEARCH
225 #define LOOKUP_DIR 0x01 /* want parent dir vp */
226 #define LOOKUP_XATTR 0x02 /* lookup up extended attr dir */
227 #define CREATE_XATTR_DIR 0x04 /* Create extended attr dir */
228 #define LOOKUP_HAVE_SYSATTR_DIR 0x08 /* Already created virtual GFS dir */
231 * Public vnode manipulation functions.
234 void vn_rele_async(struct vnode *vp, struct taskq *taskq);
236 #define VN_RELE_ASYNC(vp, taskq) { \
237 vn_rele_async(vp, taskq); \
241 * Flags to VOP_SETATTR/VOP_GETATTR.
243 #define ATTR_UTIME 0x01 /* non-default utime(2) request */
244 #define ATTR_EXEC 0x02 /* invocation from exec(2) */
245 #define ATTR_COMM 0x04 /* yield common vp attributes */
246 #define ATTR_HINT 0x08 /* information returned will be `hint' */
247 #define ATTR_REAL 0x10 /* yield attributes of the real vp */
248 #define ATTR_NOACLCHECK 0x20 /* Don't check ACL when checking permissions */
249 #define ATTR_TRIGGER 0x40 /* Mount first if vnode is a trigger mount */
251 #ifdef __cplusplus
253 #endif
255 #endif /* _SYS_VNODE_H */