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