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