1*b819cea2SGordon Ross /* 2*b819cea2SGordon Ross * CDDL HEADER START 3*b819cea2SGordon Ross * 4*b819cea2SGordon Ross * The contents of this file are subject to the terms of the 5*b819cea2SGordon Ross * Common Development and Distribution License (the "License"). 6*b819cea2SGordon Ross * You may not use this file except in compliance with the License. 7*b819cea2SGordon Ross * 8*b819cea2SGordon Ross * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*b819cea2SGordon Ross * or http://www.opensolaris.org/os/licensing. 10*b819cea2SGordon Ross * See the License for the specific language governing permissions 11*b819cea2SGordon Ross * and limitations under the License. 12*b819cea2SGordon Ross * 13*b819cea2SGordon Ross * When distributing Covered Code, include this CDDL HEADER in each 14*b819cea2SGordon Ross * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*b819cea2SGordon Ross * If applicable, add the following below this CDDL HEADER, with the 16*b819cea2SGordon Ross * fields enclosed by brackets "[]" replaced with your own identifying 17*b819cea2SGordon Ross * information: Portions Copyright [yyyy] [name of copyright owner] 18*b819cea2SGordon Ross * 19*b819cea2SGordon Ross * CDDL HEADER END 20*b819cea2SGordon Ross */ 21*b819cea2SGordon Ross 22*b819cea2SGordon Ross /* 23*b819cea2SGordon Ross * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. 24*b819cea2SGordon Ross * Copyright (c) 2013, Joyent, Inc. All rights reserved. 25*b819cea2SGordon Ross */ 26*b819cea2SGordon Ross 27*b819cea2SGordon Ross /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 28*b819cea2SGordon Ross /* All Rights Reserved */ 29*b819cea2SGordon Ross 30*b819cea2SGordon Ross /* 31*b819cea2SGordon Ross * University Copyright- Copyright (c) 1982, 1986, 1988 32*b819cea2SGordon Ross * The Regents of the University of California 33*b819cea2SGordon Ross * All Rights Reserved 34*b819cea2SGordon Ross * 35*b819cea2SGordon Ross * University Acknowledgment- Portions of this document are derived from 36*b819cea2SGordon Ross * software developed by the University of California, Berkeley, and its 37*b819cea2SGordon Ross * contributors. 38*b819cea2SGordon Ross */ 39*b819cea2SGordon Ross 40*b819cea2SGordon Ross #ifndef _SYS_VNODE_H 41*b819cea2SGordon Ross #define _SYS_VNODE_H 42*b819cea2SGordon Ross 43*b819cea2SGordon Ross #include <sys/types.h> 44*b819cea2SGordon Ross #include <sys/t_lock.h> 45*b819cea2SGordon Ross #include <sys/time_impl.h> 46*b819cea2SGordon Ross #include <sys/cred.h> 47*b819cea2SGordon Ross #include <sys/uio.h> 48*b819cea2SGordon Ross #include <sys/resource.h> 49*b819cea2SGordon Ross #include <vm/seg_enum.h> 50*b819cea2SGordon Ross #include <sys/kstat.h> 51*b819cea2SGordon Ross #include <sys/kmem.h> 52*b819cea2SGordon Ross #include <sys/list.h> 53*b819cea2SGordon Ross #include <sys/avl.h> 54*b819cea2SGordon Ross #ifdef _KERNEL 55*b819cea2SGordon Ross #include <sys/rwstlock.h> 56*b819cea2SGordon Ross #include <sys/buf.h> 57*b819cea2SGordon Ross #endif /* _KERNEL */ 58*b819cea2SGordon Ross 59*b819cea2SGordon Ross #ifdef __cplusplus 60*b819cea2SGordon Ross extern "C" { 61*b819cea2SGordon Ross #endif 62*b819cea2SGordon Ross 63*b819cea2SGordon Ross /* 64*b819cea2SGordon Ross * Statistics for all vnode operations. 65*b819cea2SGordon Ross * All operations record number of ops (since boot/mount/zero'ed). 66*b819cea2SGordon Ross * Certain I/O operations (read, write, readdir) also record number 67*b819cea2SGordon Ross * of bytes transferred. 68*b819cea2SGordon Ross * This appears in two places in the system: one is embedded in each 69*b819cea2SGordon Ross * vfs_t. There is also an array of vopstats_t structures allocated 70*b819cea2SGordon Ross * on a per-fstype basis. 71*b819cea2SGordon Ross */ 72*b819cea2SGordon Ross 73*b819cea2SGordon Ross #define VOPSTATS_STR "vopstats_" /* Initial string for vopstat kstats */ 74*b819cea2SGordon Ross 75*b819cea2SGordon Ross typedef struct vopstats { 76*b819cea2SGordon Ross kstat_named_t nopen; /* VOP_OPEN */ 77*b819cea2SGordon Ross kstat_named_t nclose; /* VOP_CLOSE */ 78*b819cea2SGordon Ross kstat_named_t nread; /* VOP_READ */ 79*b819cea2SGordon Ross kstat_named_t read_bytes; 80*b819cea2SGordon Ross kstat_named_t nwrite; /* VOP_WRITE */ 81*b819cea2SGordon Ross kstat_named_t write_bytes; 82*b819cea2SGordon Ross kstat_named_t nioctl; /* VOP_IOCTL */ 83*b819cea2SGordon Ross kstat_named_t nsetfl; /* VOP_SETFL */ 84*b819cea2SGordon Ross kstat_named_t ngetattr; /* VOP_GETATTR */ 85*b819cea2SGordon Ross kstat_named_t nsetattr; /* VOP_SETATTR */ 86*b819cea2SGordon Ross kstat_named_t naccess; /* VOP_ACCESS */ 87*b819cea2SGordon Ross kstat_named_t nlookup; /* VOP_LOOKUP */ 88*b819cea2SGordon Ross kstat_named_t ncreate; /* VOP_CREATE */ 89*b819cea2SGordon Ross kstat_named_t nremove; /* VOP_REMOVE */ 90*b819cea2SGordon Ross kstat_named_t nlink; /* VOP_LINK */ 91*b819cea2SGordon Ross kstat_named_t nrename; /* VOP_RENAME */ 92*b819cea2SGordon Ross kstat_named_t nmkdir; /* VOP_MKDIR */ 93*b819cea2SGordon Ross kstat_named_t nrmdir; /* VOP_RMDIR */ 94*b819cea2SGordon Ross kstat_named_t nreaddir; /* VOP_READDIR */ 95*b819cea2SGordon Ross kstat_named_t readdir_bytes; 96*b819cea2SGordon Ross kstat_named_t nsymlink; /* VOP_SYMLINK */ 97*b819cea2SGordon Ross kstat_named_t nreadlink; /* VOP_READLINK */ 98*b819cea2SGordon Ross kstat_named_t nfsync; /* VOP_FSYNC */ 99*b819cea2SGordon Ross kstat_named_t ninactive; /* VOP_INACTIVE */ 100*b819cea2SGordon Ross kstat_named_t nfid; /* VOP_FID */ 101*b819cea2SGordon Ross kstat_named_t nrwlock; /* VOP_RWLOCK */ 102*b819cea2SGordon Ross kstat_named_t nrwunlock; /* VOP_RWUNLOCK */ 103*b819cea2SGordon Ross kstat_named_t nseek; /* VOP_SEEK */ 104*b819cea2SGordon Ross kstat_named_t ncmp; /* VOP_CMP */ 105*b819cea2SGordon Ross kstat_named_t nfrlock; /* VOP_FRLOCK */ 106*b819cea2SGordon Ross kstat_named_t nspace; /* VOP_SPACE */ 107*b819cea2SGordon Ross kstat_named_t nrealvp; /* VOP_REALVP */ 108*b819cea2SGordon Ross kstat_named_t ngetpage; /* VOP_GETPAGE */ 109*b819cea2SGordon Ross kstat_named_t nputpage; /* VOP_PUTPAGE */ 110*b819cea2SGordon Ross kstat_named_t nmap; /* VOP_MAP */ 111*b819cea2SGordon Ross kstat_named_t naddmap; /* VOP_ADDMAP */ 112*b819cea2SGordon Ross kstat_named_t ndelmap; /* VOP_DELMAP */ 113*b819cea2SGordon Ross kstat_named_t npoll; /* VOP_POLL */ 114*b819cea2SGordon Ross kstat_named_t ndump; /* VOP_DUMP */ 115*b819cea2SGordon Ross kstat_named_t npathconf; /* VOP_PATHCONF */ 116*b819cea2SGordon Ross kstat_named_t npageio; /* VOP_PAGEIO */ 117*b819cea2SGordon Ross kstat_named_t ndumpctl; /* VOP_DUMPCTL */ 118*b819cea2SGordon Ross kstat_named_t ndispose; /* VOP_DISPOSE */ 119*b819cea2SGordon Ross kstat_named_t nsetsecattr; /* VOP_SETSECATTR */ 120*b819cea2SGordon Ross kstat_named_t ngetsecattr; /* VOP_GETSECATTR */ 121*b819cea2SGordon Ross kstat_named_t nshrlock; /* VOP_SHRLOCK */ 122*b819cea2SGordon Ross kstat_named_t nvnevent; /* VOP_VNEVENT */ 123*b819cea2SGordon Ross kstat_named_t nreqzcbuf; /* VOP_REQZCBUF */ 124*b819cea2SGordon Ross kstat_named_t nretzcbuf; /* VOP_RETZCBUF */ 125*b819cea2SGordon Ross } vopstats_t; 126*b819cea2SGordon Ross 127*b819cea2SGordon Ross /* 128*b819cea2SGordon Ross * The vnode is the focus of all file activity in UNIX. 129*b819cea2SGordon Ross * A vnode is allocated for each active file, each current 130*b819cea2SGordon Ross * directory, each mounted-on file, and the root. 131*b819cea2SGordon Ross * 132*b819cea2SGordon Ross * Each vnode is usually associated with a file-system-specific node (for 133*b819cea2SGordon Ross * UFS, this is the in-memory inode). Generally, a vnode and an fs-node 134*b819cea2SGordon Ross * should be created and destroyed together as a pair. 135*b819cea2SGordon Ross * 136*b819cea2SGordon Ross * If a vnode is reused for a new file, it should be reinitialized by calling 137*b819cea2SGordon Ross * either vn_reinit() or vn_recycle(). 138*b819cea2SGordon Ross * 139*b819cea2SGordon Ross * vn_reinit() resets the entire vnode as if it was returned by vn_alloc(). 140*b819cea2SGordon Ross * The caller is responsible for setting up the entire vnode after calling 141*b819cea2SGordon Ross * vn_reinit(). This is important when using kmem caching where the vnode is 142*b819cea2SGordon Ross * allocated by a constructor, for instance. 143*b819cea2SGordon Ross * 144*b819cea2SGordon Ross * vn_recycle() is used when the file system keeps some state around in both 145*b819cea2SGordon Ross * the vnode and the associated FS-node. In UFS, for example, the inode of 146*b819cea2SGordon Ross * a deleted file can be reused immediately. The v_data, v_vfsp, v_op, etc. 147*b819cea2SGordon Ross * remains the same but certain fields related to the previous instance need 148*b819cea2SGordon Ross * to be reset. In particular: 149*b819cea2SGordon Ross * v_femhead 150*b819cea2SGordon Ross * v_path 151*b819cea2SGordon Ross * v_rdcnt, v_wrcnt 152*b819cea2SGordon Ross * v_mmap_read, v_mmap_write 153*b819cea2SGordon Ross */ 154*b819cea2SGordon Ross 155*b819cea2SGordon Ross /* 156*b819cea2SGordon Ross * vnode types. VNON means no type. These values are unrelated to 157*b819cea2SGordon Ross * values in on-disk inodes. 158*b819cea2SGordon Ross */ 159*b819cea2SGordon Ross typedef enum vtype { 160*b819cea2SGordon Ross VNON = 0, 161*b819cea2SGordon Ross VREG = 1, 162*b819cea2SGordon Ross VDIR = 2, 163*b819cea2SGordon Ross VBLK = 3, 164*b819cea2SGordon Ross VCHR = 4, 165*b819cea2SGordon Ross VLNK = 5, 166*b819cea2SGordon Ross VFIFO = 6, 167*b819cea2SGordon Ross VDOOR = 7, 168*b819cea2SGordon Ross VPROC = 8, 169*b819cea2SGordon Ross VSOCK = 9, 170*b819cea2SGordon Ross VPORT = 10, 171*b819cea2SGordon Ross VBAD = 11 172*b819cea2SGordon Ross } vtype_t; 173*b819cea2SGordon Ross 174*b819cea2SGordon Ross /* 175*b819cea2SGordon Ross * VSD - Vnode Specific Data 176*b819cea2SGordon Ross * Used to associate additional private data with a vnode. 177*b819cea2SGordon Ross */ 178*b819cea2SGordon Ross struct vsd_node { 179*b819cea2SGordon Ross list_node_t vs_nodes; /* list of all VSD nodes */ 180*b819cea2SGordon Ross uint_t vs_nkeys; /* entries in value array */ 181*b819cea2SGordon Ross void **vs_value; /* array of value/key */ 182*b819cea2SGordon Ross }; 183*b819cea2SGordon Ross 184*b819cea2SGordon Ross /* 185*b819cea2SGordon Ross * Many of the fields in the vnode are read-only once they are initialized 186*b819cea2SGordon Ross * at vnode creation time. Other fields are protected by locks. 187*b819cea2SGordon Ross * 188*b819cea2SGordon Ross * IMPORTANT: vnodes should be created ONLY by calls to vn_alloc(). They 189*b819cea2SGordon Ross * may not be embedded into the file-system specific node (inode). The 190*b819cea2SGordon Ross * size of vnodes may change. 191*b819cea2SGordon Ross * 192*b819cea2SGordon Ross * The v_lock protects: 193*b819cea2SGordon Ross * v_flag 194*b819cea2SGordon Ross * v_stream 195*b819cea2SGordon Ross * v_count 196*b819cea2SGordon Ross * v_shrlocks 197*b819cea2SGordon Ross * v_path 198*b819cea2SGordon Ross * v_vsd 199*b819cea2SGordon Ross * v_xattrdir 200*b819cea2SGordon Ross * 201*b819cea2SGordon Ross * A special lock (implemented by vn_vfswlock in vnode.c) protects: 202*b819cea2SGordon Ross * v_vfsmountedhere 203*b819cea2SGordon Ross * 204*b819cea2SGordon Ross * The global flock_lock mutex (in flock.c) protects: 205*b819cea2SGordon Ross * v_filocks 206*b819cea2SGordon Ross * 207*b819cea2SGordon Ross * IMPORTANT NOTE: 208*b819cea2SGordon Ross * 209*b819cea2SGordon Ross * The following vnode fields are considered public and may safely be 210*b819cea2SGordon Ross * accessed by file systems or other consumers: 211*b819cea2SGordon Ross * 212*b819cea2SGordon Ross * v_lock 213*b819cea2SGordon Ross * v_flag 214*b819cea2SGordon Ross * v_count 215*b819cea2SGordon Ross * v_data 216*b819cea2SGordon Ross * v_vfsp 217*b819cea2SGordon Ross * v_stream 218*b819cea2SGordon Ross * v_type 219*b819cea2SGordon Ross * v_rdev 220*b819cea2SGordon Ross * 221*b819cea2SGordon Ross * ALL OTHER FIELDS SHOULD BE ACCESSED ONLY BY THE OWNER OF THAT FIELD. 222*b819cea2SGordon Ross * In particular, file systems should not access other fields; they may 223*b819cea2SGordon Ross * change or even be removed. The functionality which was once provided 224*b819cea2SGordon Ross * by these fields is available through vn_* functions. 225*b819cea2SGordon Ross */ 226*b819cea2SGordon Ross 227*b819cea2SGordon Ross struct fem_head; /* from fem.h */ 228*b819cea2SGordon Ross 229*b819cea2SGordon Ross typedef struct vnode { 230*b819cea2SGordon Ross kmutex_t v_lock; /* protects vnode fields */ 231*b819cea2SGordon Ross uint_t v_flag; /* vnode flags (see below) */ 232*b819cea2SGordon Ross uint_t v_count; /* reference count */ 233*b819cea2SGordon Ross void *v_data; /* private data for fs */ 234*b819cea2SGordon Ross struct vfs *v_vfsp; /* ptr to containing VFS */ 235*b819cea2SGordon Ross struct stdata *v_stream; /* associated stream */ 236*b819cea2SGordon Ross enum vtype v_type; /* vnode type */ 237*b819cea2SGordon Ross dev_t v_rdev; /* device (VCHR, VBLK) */ 238*b819cea2SGordon Ross 239*b819cea2SGordon Ross /* PRIVATE FIELDS BELOW - DO NOT USE */ 240*b819cea2SGordon Ross 241*b819cea2SGordon Ross krwlock_t v_nbllock; /* sync for NBMAND locks */ 242*b819cea2SGordon Ross char *v_path; /* cached path */ 243*b819cea2SGordon Ross uint_t v_rdcnt; /* open for read count (VREG only) */ 244*b819cea2SGordon Ross uint_t v_wrcnt; /* open for write count (VREG only) */ 245*b819cea2SGordon Ross struct vnode *v_xattrdir; /* unnamed extended attr dir (GFS) */ 246*b819cea2SGordon Ross 247*b819cea2SGordon Ross /* Private to the fake vnode impl. */ 248*b819cea2SGordon Ross 249*b819cea2SGordon Ross int v_fd; 250*b819cea2SGordon Ross dev_t v_st_dev; 251*b819cea2SGordon Ross ino_t v_st_ino; 252*b819cea2SGordon Ross avl_node_t v_avl_node; 253*b819cea2SGordon Ross } vnode_t; 254*b819cea2SGordon Ross 255*b819cea2SGordon Ross #define IS_DEVVP(vp) \ 256*b819cea2SGordon Ross ((vp)->v_type == VCHR || (vp)->v_type == VBLK || (vp)->v_type == VFIFO) 257*b819cea2SGordon Ross 258*b819cea2SGordon Ross #define VNODE_ALIGN 64 259*b819cea2SGordon Ross /* Count of low-order 0 bits in a vnode *, based on size and alignment. */ 260*b819cea2SGordon Ross #if defined(_LP64) 261*b819cea2SGordon Ross #define VNODE_ALIGN_LOG2 8 262*b819cea2SGordon Ross #else 263*b819cea2SGordon Ross #define VNODE_ALIGN_LOG2 7 264*b819cea2SGordon Ross #endif 265*b819cea2SGordon Ross 266*b819cea2SGordon Ross /* 267*b819cea2SGordon Ross * vnode flags. 268*b819cea2SGordon Ross */ 269*b819cea2SGordon Ross #define VROOT 0x01 /* root of its file system */ 270*b819cea2SGordon Ross #define VNOCACHE 0x02 /* don't keep cache pages on vnode */ 271*b819cea2SGordon Ross #define VNOMAP 0x04 /* file cannot be mapped/faulted */ 272*b819cea2SGordon Ross #define VDUP 0x08 /* file should be dup'ed rather then opened */ 273*b819cea2SGordon Ross #define VNOSWAP 0x10 /* file cannot be used as virtual swap device */ 274*b819cea2SGordon Ross #define VNOMOUNT 0x20 /* file cannot be covered by mount */ 275*b819cea2SGordon Ross #define VISSWAP 0x40 /* vnode is being used for swap */ 276*b819cea2SGordon Ross #define VSWAPLIKE 0x80 /* vnode acts like swap (but may not be) */ 277*b819cea2SGordon Ross 278*b819cea2SGordon Ross #define IS_SWAPVP(vp) (((vp)->v_flag & (VISSWAP | VSWAPLIKE)) != 0) 279*b819cea2SGordon Ross 280*b819cea2SGordon Ross #if defined(_KERNEL) 281*b819cea2SGordon Ross typedef struct vn_vfslocks_entry { 282*b819cea2SGordon Ross rwstlock_t ve_lock; 283*b819cea2SGordon Ross void *ve_vpvfs; 284*b819cea2SGordon Ross struct vn_vfslocks_entry *ve_next; 285*b819cea2SGordon Ross uint32_t ve_refcnt; 286*b819cea2SGordon Ross char pad[64 - sizeof (rwstlock_t) - 2 * sizeof (void *) - \ 287*b819cea2SGordon Ross sizeof (uint32_t)]; 288*b819cea2SGordon Ross } vn_vfslocks_entry_t; 289*b819cea2SGordon Ross #endif /* _KERNEL */ 290*b819cea2SGordon Ross 291*b819cea2SGordon Ross /* 292*b819cea2SGordon Ross * The following two flags are used to lock the v_vfsmountedhere field 293*b819cea2SGordon Ross */ 294*b819cea2SGordon Ross #define VVFSLOCK 0x100 295*b819cea2SGordon Ross #define VVFSWAIT 0x200 296*b819cea2SGordon Ross 297*b819cea2SGordon Ross /* 298*b819cea2SGordon Ross * Used to serialize VM operations on a vnode 299*b819cea2SGordon Ross */ 300*b819cea2SGordon Ross #define VVMLOCK 0x400 301*b819cea2SGordon Ross 302*b819cea2SGordon Ross /* 303*b819cea2SGordon Ross * Tell vn_open() not to fail a directory open for writing but 304*b819cea2SGordon Ross * to go ahead and call VOP_OPEN() to let the filesystem check. 305*b819cea2SGordon Ross */ 306*b819cea2SGordon Ross #define VDIROPEN 0x800 307*b819cea2SGordon Ross 308*b819cea2SGordon Ross /* 309*b819cea2SGordon Ross * Flag to let the VM system know that this file is most likely a binary 310*b819cea2SGordon Ross * or shared library since it has been mmap()ed EXEC at some time. 311*b819cea2SGordon Ross */ 312*b819cea2SGordon Ross #define VVMEXEC 0x1000 313*b819cea2SGordon Ross 314*b819cea2SGordon Ross #define VPXFS 0x2000 /* clustering: global fs proxy vnode */ 315*b819cea2SGordon Ross 316*b819cea2SGordon Ross #define IS_PXFSVP(vp) ((vp)->v_flag & VPXFS) 317*b819cea2SGordon Ross 318*b819cea2SGordon Ross #define V_XATTRDIR 0x4000 /* attribute unnamed directory */ 319*b819cea2SGordon Ross 320*b819cea2SGordon Ross #define IS_XATTRDIR(vp) ((vp)->v_flag & V_XATTRDIR) 321*b819cea2SGordon Ross 322*b819cea2SGordon Ross #define V_LOCALITY 0x8000 /* whether locality aware */ 323*b819cea2SGordon Ross 324*b819cea2SGordon Ross /* 325*b819cea2SGordon Ross * Flag that indicates the VM should maintain the v_pages list with all modified 326*b819cea2SGordon Ross * pages on one end and unmodified pages at the other. This makes finding dirty 327*b819cea2SGordon Ross * pages to write back to disk much faster at the expense of taking a minor 328*b819cea2SGordon Ross * fault on the first store instruction which touches a writable page. 329*b819cea2SGordon Ross */ 330*b819cea2SGordon Ross #define VMODSORT (0x10000) 331*b819cea2SGordon Ross #define IS_VMODSORT(vp) \ 332*b819cea2SGordon Ross (pvn_vmodsort_supported != 0 && ((vp)->v_flag & VMODSORT) != 0) 333*b819cea2SGordon Ross 334*b819cea2SGordon Ross #define VISSWAPFS 0x20000 /* vnode is being used for swapfs */ 335*b819cea2SGordon Ross 336*b819cea2SGordon Ross /* 337*b819cea2SGordon Ross * The mdb memstat command assumes that IS_SWAPFSVP only uses the 338*b819cea2SGordon Ross * vnode's v_flag field. If this changes, cache the additional 339*b819cea2SGordon Ross * fields in mdb; see vn_get in mdb/common/modules/genunix/memory.c 340*b819cea2SGordon Ross */ 341*b819cea2SGordon Ross #define IS_SWAPFSVP(vp) (((vp)->v_flag & VISSWAPFS) != 0) 342*b819cea2SGordon Ross 343*b819cea2SGordon Ross #define V_SYSATTR 0x40000 /* vnode is a GFS system attribute */ 344*b819cea2SGordon Ross 345*b819cea2SGordon Ross /* 346*b819cea2SGordon Ross * Vnode attributes. A bit-mask is supplied as part of the 347*b819cea2SGordon Ross * structure to indicate the attributes the caller wants to 348*b819cea2SGordon Ross * set (setattr) or extract (getattr). 349*b819cea2SGordon Ross */ 350*b819cea2SGordon Ross 351*b819cea2SGordon Ross /* 352*b819cea2SGordon Ross * Note that va_nodeid and va_nblocks are 64bit data type. 353*b819cea2SGordon Ross * We support large files over NFSV3. With Solaris client and 354*b819cea2SGordon Ross * Server that generates 64bit ino's and sizes these fields 355*b819cea2SGordon Ross * will overflow if they are 32 bit sizes. 356*b819cea2SGordon Ross */ 357*b819cea2SGordon Ross 358*b819cea2SGordon Ross typedef struct vattr { 359*b819cea2SGordon Ross uint_t va_mask; /* bit-mask of attributes */ 360*b819cea2SGordon Ross vtype_t va_type; /* vnode type (for create) */ 361*b819cea2SGordon Ross mode_t va_mode; /* file access mode */ 362*b819cea2SGordon Ross uid_t va_uid; /* owner user id */ 363*b819cea2SGordon Ross gid_t va_gid; /* owner group id */ 364*b819cea2SGordon Ross dev_t va_fsid; /* file system id (dev for now) */ 365*b819cea2SGordon Ross u_longlong_t va_nodeid; /* node id */ 366*b819cea2SGordon Ross nlink_t va_nlink; /* number of references to file */ 367*b819cea2SGordon Ross u_offset_t va_size; /* file size in bytes */ 368*b819cea2SGordon Ross timestruc_t va_atime; /* time of last access */ 369*b819cea2SGordon Ross timestruc_t va_mtime; /* time of last modification */ 370*b819cea2SGordon Ross timestruc_t va_ctime; /* time of last status change */ 371*b819cea2SGordon Ross dev_t va_rdev; /* device the file represents */ 372*b819cea2SGordon Ross uint_t va_blksize; /* fundamental block size */ 373*b819cea2SGordon Ross u_longlong_t va_nblocks; /* # of blocks allocated */ 374*b819cea2SGordon Ross uint_t va_seq; /* sequence number */ 375*b819cea2SGordon Ross } vattr_t; 376*b819cea2SGordon Ross 377*b819cea2SGordon Ross #define AV_SCANSTAMP_SZ 32 /* length of anti-virus scanstamp */ 378*b819cea2SGordon Ross 379*b819cea2SGordon Ross /* 380*b819cea2SGordon Ross * Structure of all optional attributes. 381*b819cea2SGordon Ross */ 382*b819cea2SGordon Ross typedef struct xoptattr { 383*b819cea2SGordon Ross timestruc_t xoa_createtime; /* Create time of file */ 384*b819cea2SGordon Ross uint8_t xoa_archive; 385*b819cea2SGordon Ross uint8_t xoa_system; 386*b819cea2SGordon Ross uint8_t xoa_readonly; 387*b819cea2SGordon Ross uint8_t xoa_hidden; 388*b819cea2SGordon Ross uint8_t xoa_nounlink; 389*b819cea2SGordon Ross uint8_t xoa_immutable; 390*b819cea2SGordon Ross uint8_t xoa_appendonly; 391*b819cea2SGordon Ross uint8_t xoa_nodump; 392*b819cea2SGordon Ross uint8_t xoa_opaque; 393*b819cea2SGordon Ross uint8_t xoa_av_quarantined; 394*b819cea2SGordon Ross uint8_t xoa_av_modified; 395*b819cea2SGordon Ross uint8_t xoa_av_scanstamp[AV_SCANSTAMP_SZ]; 396*b819cea2SGordon Ross uint8_t xoa_reparse; 397*b819cea2SGordon Ross uint64_t xoa_generation; 398*b819cea2SGordon Ross uint8_t xoa_offline; 399*b819cea2SGordon Ross uint8_t xoa_sparse; 400*b819cea2SGordon Ross } xoptattr_t; 401*b819cea2SGordon Ross 402*b819cea2SGordon Ross /* 403*b819cea2SGordon Ross * The xvattr structure is really a variable length structure that 404*b819cea2SGordon Ross * is made up of: 405*b819cea2SGordon Ross * - The classic vattr_t (xva_vattr) 406*b819cea2SGordon Ross * - a 32 bit quantity (xva_mapsize) that specifies the size of the 407*b819cea2SGordon Ross * attribute bitmaps in 32 bit words. 408*b819cea2SGordon Ross * - A pointer to the returned attribute bitmap (needed because the 409*b819cea2SGordon Ross * previous element, the requested attribute bitmap) is variable lenth. 410*b819cea2SGordon Ross * - The requested attribute bitmap, which is an array of 32 bit words. 411*b819cea2SGordon Ross * Callers use the XVA_SET_REQ() macro to set the bits corresponding to 412*b819cea2SGordon Ross * the attributes that are being requested. 413*b819cea2SGordon Ross * - The returned attribute bitmap, which is an array of 32 bit words. 414*b819cea2SGordon Ross * File systems that support optional attributes use the XVA_SET_RTN() 415*b819cea2SGordon Ross * macro to set the bits corresponding to the attributes that are being 416*b819cea2SGordon Ross * returned. 417*b819cea2SGordon Ross * - The xoptattr_t structure which contains the attribute values 418*b819cea2SGordon Ross * 419*b819cea2SGordon Ross * xva_mapsize determines how many words in the attribute bitmaps. 420*b819cea2SGordon Ross * Immediately following the attribute bitmaps is the xoptattr_t. 421*b819cea2SGordon Ross * xva_getxoptattr() is used to get the pointer to the xoptattr_t 422*b819cea2SGordon Ross * section. 423*b819cea2SGordon Ross */ 424*b819cea2SGordon Ross 425*b819cea2SGordon Ross #define XVA_MAPSIZE 3 /* Size of attr bitmaps */ 426*b819cea2SGordon Ross #define XVA_MAGIC 0x78766174 /* Magic # for verification */ 427*b819cea2SGordon Ross 428*b819cea2SGordon Ross /* 429*b819cea2SGordon Ross * The xvattr structure is an extensible structure which permits optional 430*b819cea2SGordon Ross * attributes to be requested/returned. File systems may or may not support 431*b819cea2SGordon Ross * optional attributes. They do so at their own discretion but if they do 432*b819cea2SGordon Ross * support optional attributes, they must register the VFSFT_XVATTR feature 433*b819cea2SGordon Ross * so that the optional attributes can be set/retrived. 434*b819cea2SGordon Ross * 435*b819cea2SGordon Ross * The fields of the xvattr structure are: 436*b819cea2SGordon Ross * 437*b819cea2SGordon Ross * xva_vattr - The first element of an xvattr is a legacy vattr structure 438*b819cea2SGordon Ross * which includes the common attributes. If AT_XVATTR is set in the va_mask 439*b819cea2SGordon Ross * then the entire structure is treated as an xvattr. If AT_XVATTR is not 440*b819cea2SGordon Ross * set, then only the xva_vattr structure can be used. 441*b819cea2SGordon Ross * 442*b819cea2SGordon Ross * xva_magic - 0x78766174 (hex for "xvat"). Magic number for verification. 443*b819cea2SGordon Ross * 444*b819cea2SGordon Ross * xva_mapsize - Size of requested and returned attribute bitmaps. 445*b819cea2SGordon Ross * 446*b819cea2SGordon Ross * xva_rtnattrmapp - Pointer to xva_rtnattrmap[]. We need this since the 447*b819cea2SGordon Ross * size of the array before it, xva_reqattrmap[], could change which means 448*b819cea2SGordon Ross * the location of xva_rtnattrmap[] could change. This will allow unbundled 449*b819cea2SGordon Ross * file systems to find the location of xva_rtnattrmap[] when the sizes change. 450*b819cea2SGordon Ross * 451*b819cea2SGordon Ross * xva_reqattrmap[] - Array of requested attributes. Attributes are 452*b819cea2SGordon Ross * represented by a specific bit in a specific element of the attribute 453*b819cea2SGordon Ross * map array. Callers set the bits corresponding to the attributes 454*b819cea2SGordon Ross * that the caller wants to get/set. 455*b819cea2SGordon Ross * 456*b819cea2SGordon Ross * xva_rtnattrmap[] - Array of attributes that the file system was able to 457*b819cea2SGordon Ross * process. Not all file systems support all optional attributes. This map 458*b819cea2SGordon Ross * informs the caller which attributes the underlying file system was able 459*b819cea2SGordon Ross * to set/get. (Same structure as the requested attributes array in terms 460*b819cea2SGordon Ross * of each attribute corresponding to specific bits and array elements.) 461*b819cea2SGordon Ross * 462*b819cea2SGordon Ross * xva_xoptattrs - Structure containing values of optional attributes. 463*b819cea2SGordon Ross * These values are only valid if the corresponding bits in xva_reqattrmap 464*b819cea2SGordon Ross * are set and the underlying file system supports those attributes. 465*b819cea2SGordon Ross */ 466*b819cea2SGordon Ross typedef struct xvattr { 467*b819cea2SGordon Ross vattr_t xva_vattr; /* Embedded vattr structure */ 468*b819cea2SGordon Ross uint32_t xva_magic; /* Magic Number */ 469*b819cea2SGordon Ross uint32_t xva_mapsize; /* Size of attr bitmap (32-bit words) */ 470*b819cea2SGordon Ross uint32_t *xva_rtnattrmapp; /* Ptr to xva_rtnattrmap[] */ 471*b819cea2SGordon Ross uint32_t xva_reqattrmap[XVA_MAPSIZE]; /* Requested attrs */ 472*b819cea2SGordon Ross uint32_t xva_rtnattrmap[XVA_MAPSIZE]; /* Returned attrs */ 473*b819cea2SGordon Ross xoptattr_t xva_xoptattrs; /* Optional attributes */ 474*b819cea2SGordon Ross } xvattr_t; 475*b819cea2SGordon Ross 476*b819cea2SGordon Ross #ifdef _SYSCALL32 477*b819cea2SGordon Ross /* 478*b819cea2SGordon Ross * For bigtypes time_t changed to 64 bit on the 64-bit kernel. 479*b819cea2SGordon Ross * Define an old version for user/kernel interface 480*b819cea2SGordon Ross */ 481*b819cea2SGordon Ross 482*b819cea2SGordon Ross #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 483*b819cea2SGordon Ross #pragma pack(4) 484*b819cea2SGordon Ross #endif 485*b819cea2SGordon Ross 486*b819cea2SGordon Ross typedef struct vattr32 { 487*b819cea2SGordon Ross uint32_t va_mask; /* bit-mask of attributes */ 488*b819cea2SGordon Ross vtype_t va_type; /* vnode type (for create) */ 489*b819cea2SGordon Ross mode32_t va_mode; /* file access mode */ 490*b819cea2SGordon Ross uid32_t va_uid; /* owner user id */ 491*b819cea2SGordon Ross gid32_t va_gid; /* owner group id */ 492*b819cea2SGordon Ross dev32_t va_fsid; /* file system id (dev for now) */ 493*b819cea2SGordon Ross u_longlong_t va_nodeid; /* node id */ 494*b819cea2SGordon Ross nlink_t va_nlink; /* number of references to file */ 495*b819cea2SGordon Ross u_offset_t va_size; /* file size in bytes */ 496*b819cea2SGordon Ross timestruc32_t va_atime; /* time of last access */ 497*b819cea2SGordon Ross timestruc32_t va_mtime; /* time of last modification */ 498*b819cea2SGordon Ross timestruc32_t va_ctime; /* time of last status change */ 499*b819cea2SGordon Ross dev32_t va_rdev; /* device the file represents */ 500*b819cea2SGordon Ross uint32_t va_blksize; /* fundamental block size */ 501*b819cea2SGordon Ross u_longlong_t va_nblocks; /* # of blocks allocated */ 502*b819cea2SGordon Ross uint32_t va_seq; /* sequence number */ 503*b819cea2SGordon Ross } vattr32_t; 504*b819cea2SGordon Ross 505*b819cea2SGordon Ross #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 506*b819cea2SGordon Ross #pragma pack() 507*b819cea2SGordon Ross #endif 508*b819cea2SGordon Ross 509*b819cea2SGordon Ross #else /* not _SYSCALL32 */ 510*b819cea2SGordon Ross #define vattr32 vattr 511*b819cea2SGordon Ross typedef vattr_t vattr32_t; 512*b819cea2SGordon Ross #endif /* _SYSCALL32 */ 513*b819cea2SGordon Ross 514*b819cea2SGordon Ross /* 515*b819cea2SGordon Ross * Attributes of interest to the caller of setattr or getattr. 516*b819cea2SGordon Ross */ 517*b819cea2SGordon Ross #define AT_TYPE 0x00001 518*b819cea2SGordon Ross #define AT_MODE 0x00002 519*b819cea2SGordon Ross #define AT_UID 0x00004 520*b819cea2SGordon Ross #define AT_GID 0x00008 521*b819cea2SGordon Ross #define AT_FSID 0x00010 522*b819cea2SGordon Ross #define AT_NODEID 0x00020 523*b819cea2SGordon Ross #define AT_NLINK 0x00040 524*b819cea2SGordon Ross #define AT_SIZE 0x00080 525*b819cea2SGordon Ross #define AT_ATIME 0x00100 526*b819cea2SGordon Ross #define AT_MTIME 0x00200 527*b819cea2SGordon Ross #define AT_CTIME 0x00400 528*b819cea2SGordon Ross #define AT_RDEV 0x00800 529*b819cea2SGordon Ross #define AT_BLKSIZE 0x01000 530*b819cea2SGordon Ross #define AT_NBLOCKS 0x02000 531*b819cea2SGordon Ross /* 0x04000 */ /* unused */ 532*b819cea2SGordon Ross #define AT_SEQ 0x08000 533*b819cea2SGordon Ross /* 534*b819cea2SGordon Ross * If AT_XVATTR is set then there are additional bits to process in 535*b819cea2SGordon Ross * the xvattr_t's attribute bitmap. If this is not set then the bitmap 536*b819cea2SGordon Ross * MUST be ignored. Note that this bit must be set/cleared explicitly. 537*b819cea2SGordon Ross * That is, setting AT_ALL will NOT set AT_XVATTR. 538*b819cea2SGordon Ross */ 539*b819cea2SGordon Ross #define AT_XVATTR 0x10000 540*b819cea2SGordon Ross 541*b819cea2SGordon Ross #define AT_ALL (AT_TYPE|AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|\ 542*b819cea2SGordon Ross AT_NLINK|AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|\ 543*b819cea2SGordon Ross AT_RDEV|AT_BLKSIZE|AT_NBLOCKS|AT_SEQ) 544*b819cea2SGordon Ross 545*b819cea2SGordon Ross #define AT_STAT (AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|AT_NLINK|\ 546*b819cea2SGordon Ross AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|AT_RDEV|AT_TYPE) 547*b819cea2SGordon Ross 548*b819cea2SGordon Ross #define AT_TIMES (AT_ATIME|AT_MTIME|AT_CTIME) 549*b819cea2SGordon Ross 550*b819cea2SGordon Ross #define AT_NOSET (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\ 551*b819cea2SGordon Ross AT_BLKSIZE|AT_NBLOCKS|AT_SEQ) 552*b819cea2SGordon Ross 553*b819cea2SGordon Ross /* 554*b819cea2SGordon Ross * Attribute bits used in the extensible attribute's (xva's) attribute 555*b819cea2SGordon Ross * bitmaps. Note that the bitmaps are made up of a variable length number 556*b819cea2SGordon Ross * of 32-bit words. The convention is to use XAT{n}_{attrname} where "n" 557*b819cea2SGordon Ross * is the element in the bitmap (starting at 1). This convention is for 558*b819cea2SGordon Ross * the convenience of the maintainer to keep track of which element each 559*b819cea2SGordon Ross * attribute belongs to. 560*b819cea2SGordon Ross * 561*b819cea2SGordon Ross * NOTE THAT CONSUMERS MUST *NOT* USE THE XATn_* DEFINES DIRECTLY. CONSUMERS 562*b819cea2SGordon Ross * MUST USE THE XAT_* DEFINES. 563*b819cea2SGordon Ross */ 564*b819cea2SGordon Ross #define XAT0_INDEX 0LL /* Index into bitmap for XAT0 attrs */ 565*b819cea2SGordon Ross #define XAT0_CREATETIME 0x00000001 /* Create time of file */ 566*b819cea2SGordon Ross #define XAT0_ARCHIVE 0x00000002 /* Archive */ 567*b819cea2SGordon Ross #define XAT0_SYSTEM 0x00000004 /* System */ 568*b819cea2SGordon Ross #define XAT0_READONLY 0x00000008 /* Readonly */ 569*b819cea2SGordon Ross #define XAT0_HIDDEN 0x00000010 /* Hidden */ 570*b819cea2SGordon Ross #define XAT0_NOUNLINK 0x00000020 /* Nounlink */ 571*b819cea2SGordon Ross #define XAT0_IMMUTABLE 0x00000040 /* immutable */ 572*b819cea2SGordon Ross #define XAT0_APPENDONLY 0x00000080 /* appendonly */ 573*b819cea2SGordon Ross #define XAT0_NODUMP 0x00000100 /* nodump */ 574*b819cea2SGordon Ross #define XAT0_OPAQUE 0x00000200 /* opaque */ 575*b819cea2SGordon Ross #define XAT0_AV_QUARANTINED 0x00000400 /* anti-virus quarantine */ 576*b819cea2SGordon Ross #define XAT0_AV_MODIFIED 0x00000800 /* anti-virus modified */ 577*b819cea2SGordon Ross #define XAT0_AV_SCANSTAMP 0x00001000 /* anti-virus scanstamp */ 578*b819cea2SGordon Ross #define XAT0_REPARSE 0x00002000 /* FS reparse point */ 579*b819cea2SGordon Ross #define XAT0_GEN 0x00004000 /* object generation number */ 580*b819cea2SGordon Ross #define XAT0_OFFLINE 0x00008000 /* offline */ 581*b819cea2SGordon Ross #define XAT0_SPARSE 0x00010000 /* sparse */ 582*b819cea2SGordon Ross 583*b819cea2SGordon Ross #define XAT0_ALL_ATTRS (XAT0_CREATETIME|XAT0_ARCHIVE|XAT0_SYSTEM| \ 584*b819cea2SGordon Ross XAT0_READONLY|XAT0_HIDDEN|XAT0_NOUNLINK|XAT0_IMMUTABLE|XAT0_APPENDONLY| \ 585*b819cea2SGordon Ross XAT0_NODUMP|XAT0_OPAQUE|XAT0_AV_QUARANTINED| XAT0_AV_MODIFIED| \ 586*b819cea2SGordon Ross XAT0_AV_SCANSTAMP|XAT0_REPARSE|XATO_GEN|XAT0_OFFLINE|XAT0_SPARSE) 587*b819cea2SGordon Ross 588*b819cea2SGordon Ross /* Support for XAT_* optional attributes */ 589*b819cea2SGordon Ross #define XVA_MASK 0xffffffff /* Used to mask off 32 bits */ 590*b819cea2SGordon Ross #define XVA_SHFT 32 /* Used to shift index */ 591*b819cea2SGordon Ross 592*b819cea2SGordon Ross /* 593*b819cea2SGordon Ross * Used to pry out the index and attribute bits from the XAT_* attributes 594*b819cea2SGordon Ross * defined below. Note that we're masking things down to 32 bits then 595*b819cea2SGordon Ross * casting to uint32_t. 596*b819cea2SGordon Ross */ 597*b819cea2SGordon Ross #define XVA_INDEX(attr) ((uint32_t)(((attr) >> XVA_SHFT) & XVA_MASK)) 598*b819cea2SGordon Ross #define XVA_ATTRBIT(attr) ((uint32_t)((attr) & XVA_MASK)) 599*b819cea2SGordon Ross 600*b819cea2SGordon Ross /* 601*b819cea2SGordon Ross * The following defines present a "flat namespace" so that consumers don't 602*b819cea2SGordon Ross * need to keep track of which element belongs to which bitmap entry. 603*b819cea2SGordon Ross * 604*b819cea2SGordon Ross * NOTE THAT THESE MUST NEVER BE OR-ed TOGETHER 605*b819cea2SGordon Ross */ 606*b819cea2SGordon Ross #define XAT_CREATETIME ((XAT0_INDEX << XVA_SHFT) | XAT0_CREATETIME) 607*b819cea2SGordon Ross #define XAT_ARCHIVE ((XAT0_INDEX << XVA_SHFT) | XAT0_ARCHIVE) 608*b819cea2SGordon Ross #define XAT_SYSTEM ((XAT0_INDEX << XVA_SHFT) | XAT0_SYSTEM) 609*b819cea2SGordon Ross #define XAT_READONLY ((XAT0_INDEX << XVA_SHFT) | XAT0_READONLY) 610*b819cea2SGordon Ross #define XAT_HIDDEN ((XAT0_INDEX << XVA_SHFT) | XAT0_HIDDEN) 611*b819cea2SGordon Ross #define XAT_NOUNLINK ((XAT0_INDEX << XVA_SHFT) | XAT0_NOUNLINK) 612*b819cea2SGordon Ross #define XAT_IMMUTABLE ((XAT0_INDEX << XVA_SHFT) | XAT0_IMMUTABLE) 613*b819cea2SGordon Ross #define XAT_APPENDONLY ((XAT0_INDEX << XVA_SHFT) | XAT0_APPENDONLY) 614*b819cea2SGordon Ross #define XAT_NODUMP ((XAT0_INDEX << XVA_SHFT) | XAT0_NODUMP) 615*b819cea2SGordon Ross #define XAT_OPAQUE ((XAT0_INDEX << XVA_SHFT) | XAT0_OPAQUE) 616*b819cea2SGordon Ross #define XAT_AV_QUARANTINED ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_QUARANTINED) 617*b819cea2SGordon Ross #define XAT_AV_MODIFIED ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_MODIFIED) 618*b819cea2SGordon Ross #define XAT_AV_SCANSTAMP ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_SCANSTAMP) 619*b819cea2SGordon Ross #define XAT_REPARSE ((XAT0_INDEX << XVA_SHFT) | XAT0_REPARSE) 620*b819cea2SGordon Ross #define XAT_GEN ((XAT0_INDEX << XVA_SHFT) | XAT0_GEN) 621*b819cea2SGordon Ross #define XAT_OFFLINE ((XAT0_INDEX << XVA_SHFT) | XAT0_OFFLINE) 622*b819cea2SGordon Ross #define XAT_SPARSE ((XAT0_INDEX << XVA_SHFT) | XAT0_SPARSE) 623*b819cea2SGordon Ross 624*b819cea2SGordon Ross /* 625*b819cea2SGordon Ross * The returned attribute map array (xva_rtnattrmap[]) is located past the 626*b819cea2SGordon Ross * requested attribute map array (xva_reqattrmap[]). Its location changes 627*b819cea2SGordon Ross * when the array sizes change. We use a separate pointer in a known location 628*b819cea2SGordon Ross * (xva_rtnattrmapp) to hold the location of xva_rtnattrmap[]. This is 629*b819cea2SGordon Ross * set in xva_init() 630*b819cea2SGordon Ross */ 631*b819cea2SGordon Ross #define XVA_RTNATTRMAP(xvap) ((xvap)->xva_rtnattrmapp) 632*b819cea2SGordon Ross 633*b819cea2SGordon Ross /* 634*b819cea2SGordon Ross * XVA_SET_REQ() sets an attribute bit in the proper element in the bitmap 635*b819cea2SGordon Ross * of requested attributes (xva_reqattrmap[]). 636*b819cea2SGordon Ross */ 637*b819cea2SGordon Ross #define XVA_SET_REQ(xvap, attr) \ 638*b819cea2SGordon Ross ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR); \ 639*b819cea2SGordon Ross ASSERT((xvap)->xva_magic == XVA_MAGIC); \ 640*b819cea2SGordon Ross (xvap)->xva_reqattrmap[XVA_INDEX(attr)] |= XVA_ATTRBIT(attr) 641*b819cea2SGordon Ross /* 642*b819cea2SGordon Ross * XVA_CLR_REQ() clears an attribute bit in the proper element in the bitmap 643*b819cea2SGordon Ross * of requested attributes (xva_reqattrmap[]). 644*b819cea2SGordon Ross */ 645*b819cea2SGordon Ross #define XVA_CLR_REQ(xvap, attr) \ 646*b819cea2SGordon Ross ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR); \ 647*b819cea2SGordon Ross ASSERT((xvap)->xva_magic == XVA_MAGIC); \ 648*b819cea2SGordon Ross (xvap)->xva_reqattrmap[XVA_INDEX(attr)] &= ~XVA_ATTRBIT(attr) 649*b819cea2SGordon Ross 650*b819cea2SGordon Ross /* 651*b819cea2SGordon Ross * XVA_SET_RTN() sets an attribute bit in the proper element in the bitmap 652*b819cea2SGordon Ross * of returned attributes (xva_rtnattrmap[]). 653*b819cea2SGordon Ross */ 654*b819cea2SGordon Ross #define XVA_SET_RTN(xvap, attr) \ 655*b819cea2SGordon Ross ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR); \ 656*b819cea2SGordon Ross ASSERT((xvap)->xva_magic == XVA_MAGIC); \ 657*b819cea2SGordon Ross (XVA_RTNATTRMAP(xvap))[XVA_INDEX(attr)] |= XVA_ATTRBIT(attr) 658*b819cea2SGordon Ross 659*b819cea2SGordon Ross /* 660*b819cea2SGordon Ross * XVA_ISSET_REQ() checks the requested attribute bitmap (xva_reqattrmap[]) 661*b819cea2SGordon Ross * to see of the corresponding attribute bit is set. If so, returns non-zero. 662*b819cea2SGordon Ross */ 663*b819cea2SGordon Ross #define XVA_ISSET_REQ(xvap, attr) \ 664*b819cea2SGordon Ross ((((xvap)->xva_vattr.va_mask | AT_XVATTR) && \ 665*b819cea2SGordon Ross ((xvap)->xva_magic == XVA_MAGIC) && \ 666*b819cea2SGordon Ross ((xvap)->xva_mapsize > XVA_INDEX(attr))) ? \ 667*b819cea2SGordon Ross ((xvap)->xva_reqattrmap[XVA_INDEX(attr)] & XVA_ATTRBIT(attr)) : 0) 668*b819cea2SGordon Ross 669*b819cea2SGordon Ross /* 670*b819cea2SGordon Ross * XVA_ISSET_RTN() checks the returned attribute bitmap (xva_rtnattrmap[]) 671*b819cea2SGordon Ross * to see of the corresponding attribute bit is set. If so, returns non-zero. 672*b819cea2SGordon Ross */ 673*b819cea2SGordon Ross #define XVA_ISSET_RTN(xvap, attr) \ 674*b819cea2SGordon Ross ((((xvap)->xva_vattr.va_mask | AT_XVATTR) && \ 675*b819cea2SGordon Ross ((xvap)->xva_magic == XVA_MAGIC) && \ 676*b819cea2SGordon Ross ((xvap)->xva_mapsize > XVA_INDEX(attr))) ? \ 677*b819cea2SGordon Ross ((XVA_RTNATTRMAP(xvap))[XVA_INDEX(attr)] & XVA_ATTRBIT(attr)) : 0) 678*b819cea2SGordon Ross 679*b819cea2SGordon Ross /* 680*b819cea2SGordon Ross * Modes. Some values same as S_xxx entries from stat.h for convenience. 681*b819cea2SGordon Ross */ 682*b819cea2SGordon Ross #define VSUID 04000 /* set user id on execution */ 683*b819cea2SGordon Ross #define VSGID 02000 /* set group id on execution */ 684*b819cea2SGordon Ross #define VSVTX 01000 /* save swapped text even after use */ 685*b819cea2SGordon Ross 686*b819cea2SGordon Ross /* 687*b819cea2SGordon Ross * Permissions. 688*b819cea2SGordon Ross */ 689*b819cea2SGordon Ross #define VREAD 00400 690*b819cea2SGordon Ross #define VWRITE 00200 691*b819cea2SGordon Ross #define VEXEC 00100 692*b819cea2SGordon Ross 693*b819cea2SGordon Ross #define MODEMASK 07777 /* mode bits plus permission bits */ 694*b819cea2SGordon Ross #define PERMMASK 00777 /* permission bits */ 695*b819cea2SGordon Ross 696*b819cea2SGordon Ross /* 697*b819cea2SGordon Ross * VOP_ACCESS flags 698*b819cea2SGordon Ross */ 699*b819cea2SGordon Ross #define V_ACE_MASK 0x1 /* mask represents NFSv4 ACE permissions */ 700*b819cea2SGordon Ross #define V_APPEND 0x2 /* want to do append only check */ 701*b819cea2SGordon Ross 702*b819cea2SGordon Ross /* 703*b819cea2SGordon Ross * Check whether mandatory file locking is enabled. 704*b819cea2SGordon Ross */ 705*b819cea2SGordon Ross 706*b819cea2SGordon Ross #define MANDMODE(mode) (((mode) & (VSGID|(VEXEC>>3))) == VSGID) 707*b819cea2SGordon Ross #define MANDLOCK(vp, mode) ((vp)->v_type == VREG && MANDMODE(mode)) 708*b819cea2SGordon Ross 709*b819cea2SGordon Ross /* 710*b819cea2SGordon Ross * Flags for vnode operations. 711*b819cea2SGordon Ross */ 712*b819cea2SGordon Ross enum rm { RMFILE, RMDIRECTORY }; /* rm or rmdir (remove) */ 713*b819cea2SGordon Ross enum symfollow { NO_FOLLOW, FOLLOW }; /* follow symlinks (or not) */ 714*b819cea2SGordon Ross enum vcexcl { NONEXCL, EXCL }; /* (non)excl create */ 715*b819cea2SGordon Ross enum create { CRCREAT, CRMKNOD, CRMKDIR }; /* reason for create */ 716*b819cea2SGordon Ross 717*b819cea2SGordon Ross typedef enum rm rm_t; 718*b819cea2SGordon Ross typedef enum symfollow symfollow_t; 719*b819cea2SGordon Ross typedef enum vcexcl vcexcl_t; 720*b819cea2SGordon Ross typedef enum create create_t; 721*b819cea2SGordon Ross 722*b819cea2SGordon Ross /* Vnode Events - Used by VOP_VNEVENT */ 723*b819cea2SGordon Ross typedef enum vnevent { 724*b819cea2SGordon Ross VE_SUPPORT = 0, /* Query */ 725*b819cea2SGordon Ross VE_RENAME_SRC = 1, /* Rename, with vnode as source */ 726*b819cea2SGordon Ross VE_RENAME_DEST = 2, /* Rename, with vnode as target/destination */ 727*b819cea2SGordon Ross VE_REMOVE = 3, /* Remove of vnode's name */ 728*b819cea2SGordon Ross VE_RMDIR = 4, /* Remove of directory vnode's name */ 729*b819cea2SGordon Ross VE_CREATE = 5, /* Create with vnode's name which exists */ 730*b819cea2SGordon Ross VE_LINK = 6, /* Link with vnode's name as source */ 731*b819cea2SGordon Ross VE_RENAME_DEST_DIR = 7, /* Rename with vnode as target dir */ 732*b819cea2SGordon Ross VE_MOUNTEDOVER = 8, /* File or Filesystem got mounted over vnode */ 733*b819cea2SGordon Ross VE_TRUNCATE = 9 /* Truncate */ 734*b819cea2SGordon Ross } vnevent_t; 735*b819cea2SGordon Ross 736*b819cea2SGordon Ross /* 737*b819cea2SGordon Ross * Values for checking vnode open and map counts 738*b819cea2SGordon Ross */ 739*b819cea2SGordon Ross enum v_mode { V_READ, V_WRITE, V_RDORWR, V_RDANDWR }; 740*b819cea2SGordon Ross 741*b819cea2SGordon Ross typedef enum v_mode v_mode_t; 742*b819cea2SGordon Ross 743*b819cea2SGordon Ross #define V_TRUE 1 744*b819cea2SGordon Ross #define V_FALSE 0 745*b819cea2SGordon Ross 746*b819cea2SGordon Ross /* 747*b819cea2SGordon Ross * Structure used on VOP_GETSECATTR and VOP_SETSECATTR operations 748*b819cea2SGordon Ross */ 749*b819cea2SGordon Ross 750*b819cea2SGordon Ross typedef struct vsecattr { 751*b819cea2SGordon Ross uint_t vsa_mask; /* See below */ 752*b819cea2SGordon Ross int vsa_aclcnt; /* ACL entry count */ 753*b819cea2SGordon Ross void *vsa_aclentp; /* pointer to ACL entries */ 754*b819cea2SGordon Ross int vsa_dfaclcnt; /* default ACL entry count */ 755*b819cea2SGordon Ross void *vsa_dfaclentp; /* pointer to default ACL entries */ 756*b819cea2SGordon Ross size_t vsa_aclentsz; /* ACE size in bytes of vsa_aclentp */ 757*b819cea2SGordon Ross uint_t vsa_aclflags; /* ACE ACL flags */ 758*b819cea2SGordon Ross } vsecattr_t; 759*b819cea2SGordon Ross 760*b819cea2SGordon Ross /* vsa_mask values */ 761*b819cea2SGordon Ross #define VSA_ACL 0x0001 762*b819cea2SGordon Ross #define VSA_ACLCNT 0x0002 763*b819cea2SGordon Ross #define VSA_DFACL 0x0004 764*b819cea2SGordon Ross #define VSA_DFACLCNT 0x0008 765*b819cea2SGordon Ross #define VSA_ACE 0x0010 766*b819cea2SGordon Ross #define VSA_ACECNT 0x0020 767*b819cea2SGordon Ross #define VSA_ACE_ALLTYPES 0x0040 768*b819cea2SGordon Ross #define VSA_ACE_ACLFLAGS 0x0080 /* get/set ACE ACL flags */ 769*b819cea2SGordon Ross 770*b819cea2SGordon Ross /* 771*b819cea2SGordon Ross * Structure used by various vnode operations to determine 772*b819cea2SGordon Ross * the context (pid, host, identity) of a caller. 773*b819cea2SGordon Ross * 774*b819cea2SGordon Ross * The cc_caller_id is used to identify one or more callers who invoke 775*b819cea2SGordon Ross * operations, possibly on behalf of others. For example, the NFS 776*b819cea2SGordon Ross * server could have it's own cc_caller_id which can be detected by 777*b819cea2SGordon Ross * vnode/vfs operations or (FEM) monitors on those operations. New 778*b819cea2SGordon Ross * caller IDs are generated by fs_new_caller_id(). 779*b819cea2SGordon Ross */ 780*b819cea2SGordon Ross typedef struct caller_context { 781*b819cea2SGordon Ross pid_t cc_pid; /* Process ID of the caller */ 782*b819cea2SGordon Ross int cc_sysid; /* System ID, used for remote calls */ 783*b819cea2SGordon Ross u_longlong_t cc_caller_id; /* Identifier for (set of) caller(s) */ 784*b819cea2SGordon Ross ulong_t cc_flags; 785*b819cea2SGordon Ross } caller_context_t; 786*b819cea2SGordon Ross 787*b819cea2SGordon Ross /* 788*b819cea2SGordon Ross * Flags for caller context. The caller sets CC_DONTBLOCK if it does not 789*b819cea2SGordon Ross * want to block inside of a FEM monitor. The monitor will set CC_WOULDBLOCK 790*b819cea2SGordon Ross * and return EAGAIN if the operation would have blocked. 791*b819cea2SGordon Ross */ 792*b819cea2SGordon Ross #define CC_WOULDBLOCK 0x01 793*b819cea2SGordon Ross #define CC_DONTBLOCK 0x02 794*b819cea2SGordon Ross 795*b819cea2SGordon Ross /* 796*b819cea2SGordon Ross * Structure tags for function prototypes, defined elsewhere. 797*b819cea2SGordon Ross */ 798*b819cea2SGordon Ross struct pathname; 799*b819cea2SGordon Ross struct fid; 800*b819cea2SGordon Ross struct flock64; 801*b819cea2SGordon Ross struct flk_callback; 802*b819cea2SGordon Ross struct shrlock; 803*b819cea2SGordon Ross struct page; 804*b819cea2SGordon Ross struct seg; 805*b819cea2SGordon Ross struct as; 806*b819cea2SGordon Ross struct pollhead; 807*b819cea2SGordon Ross struct taskq; 808*b819cea2SGordon Ross 809*b819cea2SGordon Ross #if defined(_KERNEL) || defined(_FAKE_KERNEL) 810*b819cea2SGordon Ross 811*b819cea2SGordon Ross /* 812*b819cea2SGordon Ross * VNODE_OPS defines all the vnode operations. It is used to define 813*b819cea2SGordon Ross * the vnodeops structure (below) and the fs_func_p union (vfs_opreg.h). 814*b819cea2SGordon Ross */ 815*b819cea2SGordon Ross #define VNODE_OPS \ 816*b819cea2SGordon Ross int (*vop_open)(vnode_t **, int, cred_t *, \ 817*b819cea2SGordon Ross caller_context_t *); \ 818*b819cea2SGordon Ross int (*vop_close)(vnode_t *, int, int, offset_t, cred_t *, \ 819*b819cea2SGordon Ross caller_context_t *); \ 820*b819cea2SGordon Ross int (*vop_read)(vnode_t *, uio_t *, int, cred_t *, \ 821*b819cea2SGordon Ross caller_context_t *); \ 822*b819cea2SGordon Ross int (*vop_write)(vnode_t *, uio_t *, int, cred_t *, \ 823*b819cea2SGordon Ross caller_context_t *); \ 824*b819cea2SGordon Ross int (*vop_ioctl)(vnode_t *, int, intptr_t, int, cred_t *, \ 825*b819cea2SGordon Ross int *, caller_context_t *); \ 826*b819cea2SGordon Ross int (*vop_setfl)(vnode_t *, int, int, cred_t *, \ 827*b819cea2SGordon Ross caller_context_t *); \ 828*b819cea2SGordon Ross int (*vop_getattr)(vnode_t *, vattr_t *, int, cred_t *, \ 829*b819cea2SGordon Ross caller_context_t *); \ 830*b819cea2SGordon Ross int (*vop_setattr)(vnode_t *, vattr_t *, int, cred_t *, \ 831*b819cea2SGordon Ross caller_context_t *); \ 832*b819cea2SGordon Ross int (*vop_access)(vnode_t *, int, int, cred_t *, \ 833*b819cea2SGordon Ross caller_context_t *); \ 834*b819cea2SGordon Ross int (*vop_lookup)(vnode_t *, char *, vnode_t **, \ 835*b819cea2SGordon Ross struct pathname *, \ 836*b819cea2SGordon Ross int, vnode_t *, cred_t *, \ 837*b819cea2SGordon Ross caller_context_t *, int *, \ 838*b819cea2SGordon Ross struct pathname *); \ 839*b819cea2SGordon Ross int (*vop_create)(vnode_t *, char *, vattr_t *, vcexcl_t, \ 840*b819cea2SGordon Ross int, vnode_t **, cred_t *, int, \ 841*b819cea2SGordon Ross caller_context_t *, vsecattr_t *); \ 842*b819cea2SGordon Ross int (*vop_remove)(vnode_t *, char *, cred_t *, \ 843*b819cea2SGordon Ross caller_context_t *, int); \ 844*b819cea2SGordon Ross int (*vop_link)(vnode_t *, vnode_t *, char *, cred_t *, \ 845*b819cea2SGordon Ross caller_context_t *, int); \ 846*b819cea2SGordon Ross int (*vop_rename)(vnode_t *, char *, vnode_t *, char *, \ 847*b819cea2SGordon Ross cred_t *, caller_context_t *, int); \ 848*b819cea2SGordon Ross int (*vop_mkdir)(vnode_t *, char *, vattr_t *, vnode_t **, \ 849*b819cea2SGordon Ross cred_t *, caller_context_t *, int, \ 850*b819cea2SGordon Ross vsecattr_t *); \ 851*b819cea2SGordon Ross int (*vop_rmdir)(vnode_t *, char *, vnode_t *, cred_t *, \ 852*b819cea2SGordon Ross caller_context_t *, int); \ 853*b819cea2SGordon Ross int (*vop_readdir)(vnode_t *, uio_t *, cred_t *, int *, \ 854*b819cea2SGordon Ross caller_context_t *, int); \ 855*b819cea2SGordon Ross int (*vop_symlink)(vnode_t *, char *, vattr_t *, char *, \ 856*b819cea2SGordon Ross cred_t *, caller_context_t *, int); \ 857*b819cea2SGordon Ross int (*vop_readlink)(vnode_t *, uio_t *, cred_t *, \ 858*b819cea2SGordon Ross caller_context_t *); \ 859*b819cea2SGordon Ross int (*vop_fsync)(vnode_t *, int, cred_t *, \ 860*b819cea2SGordon Ross caller_context_t *); \ 861*b819cea2SGordon Ross void (*vop_inactive)(vnode_t *, cred_t *, \ 862*b819cea2SGordon Ross caller_context_t *); \ 863*b819cea2SGordon Ross int (*vop_fid)(vnode_t *, struct fid *, \ 864*b819cea2SGordon Ross caller_context_t *); \ 865*b819cea2SGordon Ross int (*vop_rwlock)(vnode_t *, int, caller_context_t *); \ 866*b819cea2SGordon Ross void (*vop_rwunlock)(vnode_t *, int, caller_context_t *); \ 867*b819cea2SGordon Ross int (*vop_seek)(vnode_t *, offset_t, offset_t *, \ 868*b819cea2SGordon Ross caller_context_t *); \ 869*b819cea2SGordon Ross int (*vop_cmp)(vnode_t *, vnode_t *, caller_context_t *); \ 870*b819cea2SGordon Ross int (*vop_frlock)(vnode_t *, int, struct flock64 *, \ 871*b819cea2SGordon Ross int, offset_t, \ 872*b819cea2SGordon Ross struct flk_callback *, cred_t *, \ 873*b819cea2SGordon Ross caller_context_t *); \ 874*b819cea2SGordon Ross int (*vop_space)(vnode_t *, int, struct flock64 *, \ 875*b819cea2SGordon Ross int, offset_t, \ 876*b819cea2SGordon Ross cred_t *, caller_context_t *); \ 877*b819cea2SGordon Ross int (*vop_realvp)(vnode_t *, vnode_t **, \ 878*b819cea2SGordon Ross caller_context_t *); \ 879*b819cea2SGordon Ross int (*vop_getpage)(vnode_t *, offset_t, size_t, uint_t *, \ 880*b819cea2SGordon Ross struct page **, size_t, struct seg *, \ 881*b819cea2SGordon Ross caddr_t, enum seg_rw, cred_t *, \ 882*b819cea2SGordon Ross caller_context_t *); \ 883*b819cea2SGordon Ross int (*vop_putpage)(vnode_t *, offset_t, size_t, \ 884*b819cea2SGordon Ross int, cred_t *, caller_context_t *); \ 885*b819cea2SGordon Ross int (*vop_map)(vnode_t *, offset_t, struct as *, \ 886*b819cea2SGordon Ross caddr_t *, size_t, \ 887*b819cea2SGordon Ross uchar_t, uchar_t, uint_t, cred_t *, \ 888*b819cea2SGordon Ross caller_context_t *); \ 889*b819cea2SGordon Ross int (*vop_addmap)(vnode_t *, offset_t, struct as *, \ 890*b819cea2SGordon Ross caddr_t, size_t, \ 891*b819cea2SGordon Ross uchar_t, uchar_t, uint_t, cred_t *, \ 892*b819cea2SGordon Ross caller_context_t *); \ 893*b819cea2SGordon Ross int (*vop_delmap)(vnode_t *, offset_t, struct as *, \ 894*b819cea2SGordon Ross caddr_t, size_t, \ 895*b819cea2SGordon Ross uint_t, uint_t, uint_t, cred_t *, \ 896*b819cea2SGordon Ross caller_context_t *); \ 897*b819cea2SGordon Ross int (*vop_poll)(vnode_t *, short, int, short *, \ 898*b819cea2SGordon Ross struct pollhead **, \ 899*b819cea2SGordon Ross caller_context_t *); \ 900*b819cea2SGordon Ross int (*vop_dump)(vnode_t *, caddr_t, offset_t, offset_t, \ 901*b819cea2SGordon Ross caller_context_t *); \ 902*b819cea2SGordon Ross int (*vop_pathconf)(vnode_t *, int, ulong_t *, cred_t *, \ 903*b819cea2SGordon Ross caller_context_t *); \ 904*b819cea2SGordon Ross int (*vop_pageio)(vnode_t *, struct page *, \ 905*b819cea2SGordon Ross u_offset_t, size_t, int, cred_t *, \ 906*b819cea2SGordon Ross caller_context_t *); \ 907*b819cea2SGordon Ross int (*vop_dumpctl)(vnode_t *, int, offset_t *, \ 908*b819cea2SGordon Ross caller_context_t *); \ 909*b819cea2SGordon Ross void (*vop_dispose)(vnode_t *, struct page *, \ 910*b819cea2SGordon Ross int, int, cred_t *, \ 911*b819cea2SGordon Ross caller_context_t *); \ 912*b819cea2SGordon Ross int (*vop_setsecattr)(vnode_t *, vsecattr_t *, \ 913*b819cea2SGordon Ross int, cred_t *, caller_context_t *); \ 914*b819cea2SGordon Ross int (*vop_getsecattr)(vnode_t *, vsecattr_t *, \ 915*b819cea2SGordon Ross int, cred_t *, caller_context_t *); \ 916*b819cea2SGordon Ross int (*vop_shrlock)(vnode_t *, int, struct shrlock *, \ 917*b819cea2SGordon Ross int, cred_t *, caller_context_t *); \ 918*b819cea2SGordon Ross int (*vop_vnevent)(vnode_t *, vnevent_t, vnode_t *, \ 919*b819cea2SGordon Ross char *, caller_context_t *); \ 920*b819cea2SGordon Ross int (*vop_reqzcbuf)(vnode_t *, enum uio_rw, xuio_t *, \ 921*b819cea2SGordon Ross cred_t *, caller_context_t *); \ 922*b819cea2SGordon Ross int (*vop_retzcbuf)(vnode_t *, xuio_t *, cred_t *, \ 923*b819cea2SGordon Ross caller_context_t *) 924*b819cea2SGordon Ross /* NB: No ";" */ 925*b819cea2SGordon Ross 926*b819cea2SGordon Ross /* 927*b819cea2SGordon Ross * Operations on vnodes. Note: File systems must never operate directly 928*b819cea2SGordon Ross * on a 'vnodeops' structure -- it WILL change in future releases! They 929*b819cea2SGordon Ross * must use vn_make_ops() to create the structure. 930*b819cea2SGordon Ross */ 931*b819cea2SGordon Ross typedef struct vnodeops { 932*b819cea2SGordon Ross const char *vnop_name; 933*b819cea2SGordon Ross VNODE_OPS; /* Signatures of all vnode operations (vops) */ 934*b819cea2SGordon Ross } vnodeops_t; 935*b819cea2SGordon Ross 936*b819cea2SGordon Ross typedef int (*fs_generic_func_p) (); /* Generic vop/vfsop/femop/fsemop ptr */ 937*b819cea2SGordon Ross 938*b819cea2SGordon Ross extern int fop_open(vnode_t **, int, cred_t *, caller_context_t *); 939*b819cea2SGordon Ross extern int fop_close(vnode_t *, int, int, offset_t, cred_t *, 940*b819cea2SGordon Ross caller_context_t *); 941*b819cea2SGordon Ross extern int fop_read(vnode_t *, uio_t *, int, cred_t *, caller_context_t *); 942*b819cea2SGordon Ross extern int fop_write(vnode_t *, uio_t *, int, cred_t *, 943*b819cea2SGordon Ross caller_context_t *); 944*b819cea2SGordon Ross extern int fop_ioctl(vnode_t *, int, intptr_t, int, cred_t *, int *, 945*b819cea2SGordon Ross caller_context_t *); 946*b819cea2SGordon Ross extern int fop_setfl(vnode_t *, int, int, cred_t *, caller_context_t *); 947*b819cea2SGordon Ross extern int fop_getattr(vnode_t *, vattr_t *, int, cred_t *, 948*b819cea2SGordon Ross caller_context_t *); 949*b819cea2SGordon Ross extern int fop_setattr(vnode_t *, vattr_t *, int, cred_t *, 950*b819cea2SGordon Ross caller_context_t *); 951*b819cea2SGordon Ross extern int fop_access(vnode_t *, int, int, cred_t *, caller_context_t *); 952*b819cea2SGordon Ross extern int fop_lookup(vnode_t *, char *, vnode_t **, struct pathname *, 953*b819cea2SGordon Ross int, vnode_t *, cred_t *, caller_context_t *, 954*b819cea2SGordon Ross int *, struct pathname *); 955*b819cea2SGordon Ross extern int fop_create(vnode_t *, char *, vattr_t *, vcexcl_t, int, 956*b819cea2SGordon Ross vnode_t **, cred_t *, int, caller_context_t *, 957*b819cea2SGordon Ross vsecattr_t *); 958*b819cea2SGordon Ross extern int fop_remove(vnode_t *vp, char *, cred_t *, caller_context_t *, 959*b819cea2SGordon Ross int); 960*b819cea2SGordon Ross extern int fop_link(vnode_t *, vnode_t *, char *, cred_t *, 961*b819cea2SGordon Ross caller_context_t *, int); 962*b819cea2SGordon Ross extern int fop_rename(vnode_t *, char *, vnode_t *, char *, cred_t *, 963*b819cea2SGordon Ross caller_context_t *, int); 964*b819cea2SGordon Ross extern int fop_mkdir(vnode_t *, char *, vattr_t *, vnode_t **, cred_t *, 965*b819cea2SGordon Ross caller_context_t *, int, vsecattr_t *); 966*b819cea2SGordon Ross extern int fop_rmdir(vnode_t *, char *, vnode_t *, cred_t *, 967*b819cea2SGordon Ross caller_context_t *, int); 968*b819cea2SGordon Ross extern int fop_readdir(vnode_t *, uio_t *, cred_t *, int *, 969*b819cea2SGordon Ross caller_context_t *, int); 970*b819cea2SGordon Ross extern int fop_symlink(vnode_t *, char *, vattr_t *, char *, cred_t *, 971*b819cea2SGordon Ross caller_context_t *, int); 972*b819cea2SGordon Ross extern int fop_readlink(vnode_t *, uio_t *, cred_t *, caller_context_t *); 973*b819cea2SGordon Ross extern int fop_fsync(vnode_t *, int, cred_t *, caller_context_t *); 974*b819cea2SGordon Ross extern void fop_inactive(vnode_t *, cred_t *, caller_context_t *); 975*b819cea2SGordon Ross extern int fop_fid(vnode_t *, struct fid *, caller_context_t *); 976*b819cea2SGordon Ross extern int fop_rwlock(vnode_t *, int, caller_context_t *); 977*b819cea2SGordon Ross extern void fop_rwunlock(vnode_t *, int, caller_context_t *); 978*b819cea2SGordon Ross extern int fop_seek(vnode_t *, offset_t, offset_t *, caller_context_t *); 979*b819cea2SGordon Ross extern int fop_cmp(vnode_t *, vnode_t *, caller_context_t *); 980*b819cea2SGordon Ross extern int fop_frlock(vnode_t *, int, struct flock64 *, int, offset_t, 981*b819cea2SGordon Ross struct flk_callback *, cred_t *, 982*b819cea2SGordon Ross caller_context_t *); 983*b819cea2SGordon Ross extern int fop_space(vnode_t *, int, struct flock64 *, int, offset_t, 984*b819cea2SGordon Ross cred_t *, caller_context_t *); 985*b819cea2SGordon Ross extern int fop_realvp(vnode_t *, vnode_t **, caller_context_t *); 986*b819cea2SGordon Ross extern int fop_getpage(vnode_t *, offset_t, size_t, uint_t *, 987*b819cea2SGordon Ross struct page **, size_t, struct seg *, 988*b819cea2SGordon Ross caddr_t, enum seg_rw, cred_t *, 989*b819cea2SGordon Ross caller_context_t *); 990*b819cea2SGordon Ross extern int fop_putpage(vnode_t *, offset_t, size_t, int, cred_t *, 991*b819cea2SGordon Ross caller_context_t *); 992*b819cea2SGordon Ross extern int fop_map(vnode_t *, offset_t, struct as *, caddr_t *, size_t, 993*b819cea2SGordon Ross uchar_t, uchar_t, uint_t, cred_t *cr, 994*b819cea2SGordon Ross caller_context_t *); 995*b819cea2SGordon Ross extern int fop_addmap(vnode_t *, offset_t, struct as *, caddr_t, size_t, 996*b819cea2SGordon Ross uchar_t, uchar_t, uint_t, cred_t *, 997*b819cea2SGordon Ross caller_context_t *); 998*b819cea2SGordon Ross extern int fop_delmap(vnode_t *, offset_t, struct as *, caddr_t, size_t, 999*b819cea2SGordon Ross uint_t, uint_t, uint_t, cred_t *, 1000*b819cea2SGordon Ross caller_context_t *); 1001*b819cea2SGordon Ross extern int fop_poll(vnode_t *, short, int, short *, struct pollhead **, 1002*b819cea2SGordon Ross caller_context_t *); 1003*b819cea2SGordon Ross extern int fop_dump(vnode_t *, caddr_t, offset_t, offset_t, 1004*b819cea2SGordon Ross caller_context_t *); 1005*b819cea2SGordon Ross extern int fop_pathconf(vnode_t *, int, ulong_t *, cred_t *, 1006*b819cea2SGordon Ross caller_context_t *); 1007*b819cea2SGordon Ross extern int fop_pageio(vnode_t *, struct page *, u_offset_t, size_t, int, 1008*b819cea2SGordon Ross cred_t *, caller_context_t *); 1009*b819cea2SGordon Ross extern int fop_dumpctl(vnode_t *, int, offset_t *, caller_context_t *); 1010*b819cea2SGordon Ross extern void fop_dispose(vnode_t *, struct page *, int, int, cred_t *, 1011*b819cea2SGordon Ross caller_context_t *); 1012*b819cea2SGordon Ross extern int fop_setsecattr(vnode_t *, vsecattr_t *, int, cred_t *, 1013*b819cea2SGordon Ross caller_context_t *); 1014*b819cea2SGordon Ross extern int fop_getsecattr(vnode_t *, vsecattr_t *, int, cred_t *, 1015*b819cea2SGordon Ross caller_context_t *); 1016*b819cea2SGordon Ross extern int fop_shrlock(vnode_t *, int, struct shrlock *, int, cred_t *, 1017*b819cea2SGordon Ross caller_context_t *); 1018*b819cea2SGordon Ross extern int fop_vnevent(vnode_t *, vnevent_t, vnode_t *, char *, 1019*b819cea2SGordon Ross caller_context_t *); 1020*b819cea2SGordon Ross extern int fop_reqzcbuf(vnode_t *, enum uio_rw, xuio_t *, cred_t *, 1021*b819cea2SGordon Ross caller_context_t *); 1022*b819cea2SGordon Ross extern int fop_retzcbuf(vnode_t *, xuio_t *, cred_t *, caller_context_t *); 1023*b819cea2SGordon Ross 1024*b819cea2SGordon Ross #endif /* _KERNEL */ 1025*b819cea2SGordon Ross 1026*b819cea2SGordon Ross #define VOP_OPEN(vpp, mode, cr, ct) \ 1027*b819cea2SGordon Ross fop_open(vpp, mode, cr, ct) 1028*b819cea2SGordon Ross #define VOP_CLOSE(vp, f, c, o, cr, ct) \ 1029*b819cea2SGordon Ross fop_close(vp, f, c, o, cr, ct) 1030*b819cea2SGordon Ross #define VOP_READ(vp, uiop, iof, cr, ct) \ 1031*b819cea2SGordon Ross fop_read(vp, uiop, iof, cr, ct) 1032*b819cea2SGordon Ross #define VOP_WRITE(vp, uiop, iof, cr, ct) \ 1033*b819cea2SGordon Ross fop_write(vp, uiop, iof, cr, ct) 1034*b819cea2SGordon Ross #define VOP_IOCTL(vp, cmd, a, f, cr, rvp, ct) \ 1035*b819cea2SGordon Ross fop_ioctl(vp, cmd, a, f, cr, rvp, ct) 1036*b819cea2SGordon Ross #define VOP_SETFL(vp, f, a, cr, ct) \ 1037*b819cea2SGordon Ross fop_setfl(vp, f, a, cr, ct) 1038*b819cea2SGordon Ross #define VOP_GETATTR(vp, vap, f, cr, ct) \ 1039*b819cea2SGordon Ross fop_getattr(vp, vap, f, cr, ct) 1040*b819cea2SGordon Ross #define VOP_SETATTR(vp, vap, f, cr, ct) \ 1041*b819cea2SGordon Ross fop_setattr(vp, vap, f, cr, ct) 1042*b819cea2SGordon Ross #define VOP_ACCESS(vp, mode, f, cr, ct) \ 1043*b819cea2SGordon Ross fop_access(vp, mode, f, cr, ct) 1044*b819cea2SGordon Ross #define VOP_LOOKUP(vp, cp, vpp, pnp, f, rdir, cr, ct, defp, rpnp) \ 1045*b819cea2SGordon Ross fop_lookup(vp, cp, vpp, pnp, f, rdir, cr, ct, defp, rpnp) 1046*b819cea2SGordon Ross #define VOP_CREATE(dvp, p, vap, ex, mode, vpp, cr, flag, ct, vsap) \ 1047*b819cea2SGordon Ross fop_create(dvp, p, vap, ex, mode, vpp, cr, flag, ct, vsap) 1048*b819cea2SGordon Ross #define VOP_REMOVE(dvp, p, cr, ct, f) \ 1049*b819cea2SGordon Ross fop_remove(dvp, p, cr, ct, f) 1050*b819cea2SGordon Ross #define VOP_LINK(tdvp, fvp, p, cr, ct, f) \ 1051*b819cea2SGordon Ross fop_link(tdvp, fvp, p, cr, ct, f) 1052*b819cea2SGordon Ross #define VOP_RENAME(fvp, fnm, tdvp, tnm, cr, ct, f) \ 1053*b819cea2SGordon Ross fop_rename(fvp, fnm, tdvp, tnm, cr, ct, f) 1054*b819cea2SGordon Ross #define VOP_MKDIR(dp, p, vap, vpp, cr, ct, f, vsap) \ 1055*b819cea2SGordon Ross fop_mkdir(dp, p, vap, vpp, cr, ct, f, vsap) 1056*b819cea2SGordon Ross #define VOP_RMDIR(dp, p, cdir, cr, ct, f) \ 1057*b819cea2SGordon Ross fop_rmdir(dp, p, cdir, cr, ct, f) 1058*b819cea2SGordon Ross #define VOP_READDIR(vp, uiop, cr, eofp, ct, f) \ 1059*b819cea2SGordon Ross fop_readdir(vp, uiop, cr, eofp, ct, f) 1060*b819cea2SGordon Ross #define VOP_SYMLINK(dvp, lnm, vap, tnm, cr, ct, f) \ 1061*b819cea2SGordon Ross fop_symlink(dvp, lnm, vap, tnm, cr, ct, f) 1062*b819cea2SGordon Ross #define VOP_READLINK(vp, uiop, cr, ct) \ 1063*b819cea2SGordon Ross fop_readlink(vp, uiop, cr, ct) 1064*b819cea2SGordon Ross #define VOP_FSYNC(vp, syncflag, cr, ct) \ 1065*b819cea2SGordon Ross fop_fsync(vp, syncflag, cr, ct) 1066*b819cea2SGordon Ross #define VOP_INACTIVE(vp, cr, ct) \ 1067*b819cea2SGordon Ross fop_inactive(vp, cr, ct) 1068*b819cea2SGordon Ross #define VOP_FID(vp, fidp, ct) \ 1069*b819cea2SGordon Ross fop_fid(vp, fidp, ct) 1070*b819cea2SGordon Ross #define VOP_RWLOCK(vp, w, ct) \ 1071*b819cea2SGordon Ross fop_rwlock(vp, w, ct) 1072*b819cea2SGordon Ross #define VOP_RWUNLOCK(vp, w, ct) \ 1073*b819cea2SGordon Ross fop_rwunlock(vp, w, ct) 1074*b819cea2SGordon Ross #define VOP_SEEK(vp, ooff, noffp, ct) \ 1075*b819cea2SGordon Ross fop_seek(vp, ooff, noffp, ct) 1076*b819cea2SGordon Ross #define VOP_CMP(vp1, vp2, ct) \ 1077*b819cea2SGordon Ross fop_cmp(vp1, vp2, ct) 1078*b819cea2SGordon Ross #define VOP_FRLOCK(vp, cmd, a, f, o, cb, cr, ct) \ 1079*b819cea2SGordon Ross fop_frlock(vp, cmd, a, f, o, cb, cr, ct) 1080*b819cea2SGordon Ross #define VOP_SPACE(vp, cmd, a, f, o, cr, ct) \ 1081*b819cea2SGordon Ross fop_space(vp, cmd, a, f, o, cr, ct) 1082*b819cea2SGordon Ross #define VOP_REALVP(vp1, vp2, ct) \ 1083*b819cea2SGordon Ross fop_realvp(vp1, vp2, ct) 1084*b819cea2SGordon Ross #define VOP_GETPAGE(vp, of, sz, pr, pl, ps, sg, a, rw, cr, ct) \ 1085*b819cea2SGordon Ross fop_getpage(vp, of, sz, pr, pl, ps, sg, a, rw, cr, ct) 1086*b819cea2SGordon Ross #define VOP_PUTPAGE(vp, of, sz, fl, cr, ct) \ 1087*b819cea2SGordon Ross fop_putpage(vp, of, sz, fl, cr, ct) 1088*b819cea2SGordon Ross #define VOP_MAP(vp, of, as, a, sz, p, mp, fl, cr, ct) \ 1089*b819cea2SGordon Ross fop_map(vp, of, as, a, sz, p, mp, fl, cr, ct) 1090*b819cea2SGordon Ross #define VOP_ADDMAP(vp, of, as, a, sz, p, mp, fl, cr, ct) \ 1091*b819cea2SGordon Ross fop_addmap(vp, of, as, a, sz, p, mp, fl, cr, ct) 1092*b819cea2SGordon Ross #define VOP_DELMAP(vp, of, as, a, sz, p, mp, fl, cr, ct) \ 1093*b819cea2SGordon Ross fop_delmap(vp, of, as, a, sz, p, mp, fl, cr, ct) 1094*b819cea2SGordon Ross #define VOP_POLL(vp, events, anyyet, reventsp, phpp, ct) \ 1095*b819cea2SGordon Ross fop_poll(vp, events, anyyet, reventsp, phpp, ct) 1096*b819cea2SGordon Ross #define VOP_DUMP(vp, addr, bn, count, ct) \ 1097*b819cea2SGordon Ross fop_dump(vp, addr, bn, count, ct) 1098*b819cea2SGordon Ross #define VOP_PATHCONF(vp, cmd, valp, cr, ct) \ 1099*b819cea2SGordon Ross fop_pathconf(vp, cmd, valp, cr, ct) 1100*b819cea2SGordon Ross #define VOP_PAGEIO(vp, pp, io_off, io_len, flags, cr, ct) \ 1101*b819cea2SGordon Ross fop_pageio(vp, pp, io_off, io_len, flags, cr, ct) 1102*b819cea2SGordon Ross #define VOP_DUMPCTL(vp, action, blkp, ct) \ 1103*b819cea2SGordon Ross fop_dumpctl(vp, action, blkp, ct) 1104*b819cea2SGordon Ross #define VOP_DISPOSE(vp, pp, flag, dn, cr, ct) \ 1105*b819cea2SGordon Ross fop_dispose(vp, pp, flag, dn, cr, ct) 1106*b819cea2SGordon Ross #define VOP_GETSECATTR(vp, vsap, f, cr, ct) \ 1107*b819cea2SGordon Ross fop_getsecattr(vp, vsap, f, cr, ct) 1108*b819cea2SGordon Ross #define VOP_SETSECATTR(vp, vsap, f, cr, ct) \ 1109*b819cea2SGordon Ross fop_setsecattr(vp, vsap, f, cr, ct) 1110*b819cea2SGordon Ross #define VOP_SHRLOCK(vp, cmd, shr, f, cr, ct) \ 1111*b819cea2SGordon Ross fop_shrlock(vp, cmd, shr, f, cr, ct) 1112*b819cea2SGordon Ross #define VOP_VNEVENT(vp, vnevent, dvp, fnm, ct) \ 1113*b819cea2SGordon Ross fop_vnevent(vp, vnevent, dvp, fnm, ct) 1114*b819cea2SGordon Ross #define VOP_REQZCBUF(vp, rwflag, xuiop, cr, ct) \ 1115*b819cea2SGordon Ross fop_reqzcbuf(vp, rwflag, xuiop, cr, ct) 1116*b819cea2SGordon Ross #define VOP_RETZCBUF(vp, xuiop, cr, ct) \ 1117*b819cea2SGordon Ross fop_retzcbuf(vp, xuiop, cr, ct) 1118*b819cea2SGordon Ross 1119*b819cea2SGordon Ross #define VOPNAME_OPEN "open" 1120*b819cea2SGordon Ross #define VOPNAME_CLOSE "close" 1121*b819cea2SGordon Ross #define VOPNAME_READ "read" 1122*b819cea2SGordon Ross #define VOPNAME_WRITE "write" 1123*b819cea2SGordon Ross #define VOPNAME_IOCTL "ioctl" 1124*b819cea2SGordon Ross #define VOPNAME_SETFL "setfl" 1125*b819cea2SGordon Ross #define VOPNAME_GETATTR "getattr" 1126*b819cea2SGordon Ross #define VOPNAME_SETATTR "setattr" 1127*b819cea2SGordon Ross #define VOPNAME_ACCESS "access" 1128*b819cea2SGordon Ross #define VOPNAME_LOOKUP "lookup" 1129*b819cea2SGordon Ross #define VOPNAME_CREATE "create" 1130*b819cea2SGordon Ross #define VOPNAME_REMOVE "remove" 1131*b819cea2SGordon Ross #define VOPNAME_LINK "link" 1132*b819cea2SGordon Ross #define VOPNAME_RENAME "rename" 1133*b819cea2SGordon Ross #define VOPNAME_MKDIR "mkdir" 1134*b819cea2SGordon Ross #define VOPNAME_RMDIR "rmdir" 1135*b819cea2SGordon Ross #define VOPNAME_READDIR "readdir" 1136*b819cea2SGordon Ross #define VOPNAME_SYMLINK "symlink" 1137*b819cea2SGordon Ross #define VOPNAME_READLINK "readlink" 1138*b819cea2SGordon Ross #define VOPNAME_FSYNC "fsync" 1139*b819cea2SGordon Ross #define VOPNAME_INACTIVE "inactive" 1140*b819cea2SGordon Ross #define VOPNAME_FID "fid" 1141*b819cea2SGordon Ross #define VOPNAME_RWLOCK "rwlock" 1142*b819cea2SGordon Ross #define VOPNAME_RWUNLOCK "rwunlock" 1143*b819cea2SGordon Ross #define VOPNAME_SEEK "seek" 1144*b819cea2SGordon Ross #define VOPNAME_CMP "cmp" 1145*b819cea2SGordon Ross #define VOPNAME_FRLOCK "frlock" 1146*b819cea2SGordon Ross #define VOPNAME_SPACE "space" 1147*b819cea2SGordon Ross #define VOPNAME_REALVP "realvp" 1148*b819cea2SGordon Ross #define VOPNAME_GETPAGE "getpage" 1149*b819cea2SGordon Ross #define VOPNAME_PUTPAGE "putpage" 1150*b819cea2SGordon Ross #define VOPNAME_MAP "map" 1151*b819cea2SGordon Ross #define VOPNAME_ADDMAP "addmap" 1152*b819cea2SGordon Ross #define VOPNAME_DELMAP "delmap" 1153*b819cea2SGordon Ross #define VOPNAME_POLL "poll" 1154*b819cea2SGordon Ross #define VOPNAME_DUMP "dump" 1155*b819cea2SGordon Ross #define VOPNAME_PATHCONF "pathconf" 1156*b819cea2SGordon Ross #define VOPNAME_PAGEIO "pageio" 1157*b819cea2SGordon Ross #define VOPNAME_DUMPCTL "dumpctl" 1158*b819cea2SGordon Ross #define VOPNAME_DISPOSE "dispose" 1159*b819cea2SGordon Ross #define VOPNAME_GETSECATTR "getsecattr" 1160*b819cea2SGordon Ross #define VOPNAME_SETSECATTR "setsecattr" 1161*b819cea2SGordon Ross #define VOPNAME_SHRLOCK "shrlock" 1162*b819cea2SGordon Ross #define VOPNAME_VNEVENT "vnevent" 1163*b819cea2SGordon Ross #define VOPNAME_REQZCBUF "reqzcbuf" 1164*b819cea2SGordon Ross #define VOPNAME_RETZCBUF "retzcbuf" 1165*b819cea2SGordon Ross 1166*b819cea2SGordon Ross /* 1167*b819cea2SGordon Ross * Flags for VOP_LOOKUP 1168*b819cea2SGordon Ross * 1169*b819cea2SGordon Ross * Defined in file.h, but also possible, FIGNORECASE and FSEARCH 1170*b819cea2SGordon Ross * 1171*b819cea2SGordon Ross */ 1172*b819cea2SGordon Ross #define LOOKUP_DIR 0x01 /* want parent dir vp */ 1173*b819cea2SGordon Ross #define LOOKUP_XATTR 0x02 /* lookup up extended attr dir */ 1174*b819cea2SGordon Ross #define CREATE_XATTR_DIR 0x04 /* Create extended attr dir */ 1175*b819cea2SGordon Ross #define LOOKUP_HAVE_SYSATTR_DIR 0x08 /* Already created virtual GFS dir */ 1176*b819cea2SGordon Ross 1177*b819cea2SGordon Ross /* 1178*b819cea2SGordon Ross * Flags for VOP_READDIR 1179*b819cea2SGordon Ross */ 1180*b819cea2SGordon Ross #define V_RDDIR_ENTFLAGS 0x01 /* request dirent flags */ 1181*b819cea2SGordon Ross #define V_RDDIR_ACCFILTER 0x02 /* filter out inaccessible dirents */ 1182*b819cea2SGordon Ross 1183*b819cea2SGordon Ross /* 1184*b819cea2SGordon Ross * Flags for VOP_RWLOCK/VOP_RWUNLOCK 1185*b819cea2SGordon Ross * VOP_RWLOCK will return the flag that was actually set, or -1 if none. 1186*b819cea2SGordon Ross */ 1187*b819cea2SGordon Ross #define V_WRITELOCK_TRUE (1) /* Request write-lock on the vnode */ 1188*b819cea2SGordon Ross #define V_WRITELOCK_FALSE (0) /* Request read-lock on the vnode */ 1189*b819cea2SGordon Ross 1190*b819cea2SGordon Ross /* 1191*b819cea2SGordon Ross * Flags for VOP_DUMPCTL 1192*b819cea2SGordon Ross */ 1193*b819cea2SGordon Ross #define DUMP_ALLOC 0 1194*b819cea2SGordon Ross #define DUMP_FREE 1 1195*b819cea2SGordon Ross #define DUMP_SCAN 2 1196*b819cea2SGordon Ross 1197*b819cea2SGordon Ross /* 1198*b819cea2SGordon Ross * Public vnode manipulation functions. 1199*b819cea2SGordon Ross */ 1200*b819cea2SGordon Ross #if defined(_KERNEL) || defined(_FAKE_KERNEL) 1201*b819cea2SGordon Ross 1202*b819cea2SGordon Ross vnode_t *vn_alloc(int); 1203*b819cea2SGordon Ross void vn_reinit(vnode_t *); 1204*b819cea2SGordon Ross void vn_recycle(vnode_t *); 1205*b819cea2SGordon Ross void vn_free(vnode_t *); 1206*b819cea2SGordon Ross 1207*b819cea2SGordon Ross int vn_is_readonly(vnode_t *); 1208*b819cea2SGordon Ross int vn_is_opened(vnode_t *, v_mode_t); 1209*b819cea2SGordon Ross int vn_is_mapped(vnode_t *, v_mode_t); 1210*b819cea2SGordon Ross int vn_has_other_opens(vnode_t *, v_mode_t); 1211*b819cea2SGordon Ross void vn_open_upgrade(vnode_t *, int); 1212*b819cea2SGordon Ross void vn_open_downgrade(vnode_t *, int); 1213*b819cea2SGordon Ross 1214*b819cea2SGordon Ross int vn_can_change_zones(vnode_t *vp); 1215*b819cea2SGordon Ross 1216*b819cea2SGordon Ross int vn_has_flocks(vnode_t *); 1217*b819cea2SGordon Ross int vn_has_mandatory_locks(vnode_t *, int); 1218*b819cea2SGordon Ross int vn_has_cached_data(vnode_t *); 1219*b819cea2SGordon Ross 1220*b819cea2SGordon Ross void vn_setops(vnode_t *, vnodeops_t *); 1221*b819cea2SGordon Ross vnodeops_t *vn_getops(vnode_t *); 1222*b819cea2SGordon Ross int vn_matchops(vnode_t *, vnodeops_t *); 1223*b819cea2SGordon Ross int vn_matchopval(vnode_t *, char *, fs_generic_func_p); 1224*b819cea2SGordon Ross int vn_ismntpt(vnode_t *); 1225*b819cea2SGordon Ross 1226*b819cea2SGordon Ross struct vfs *vn_mountedvfs(vnode_t *); 1227*b819cea2SGordon Ross 1228*b819cea2SGordon Ross int vn_in_dnlc(vnode_t *); 1229*b819cea2SGordon Ross 1230*b819cea2SGordon Ross void vn_create_cache(void); 1231*b819cea2SGordon Ross void vn_destroy_cache(void); 1232*b819cea2SGordon Ross 1233*b819cea2SGordon Ross void vn_freevnodeops(vnodeops_t *); 1234*b819cea2SGordon Ross 1235*b819cea2SGordon Ross int vn_open(char *pnamep, enum uio_seg seg, int filemode, int createmode, 1236*b819cea2SGordon Ross struct vnode **vpp, enum create crwhy, mode_t umask); 1237*b819cea2SGordon Ross int vn_openat(char *pnamep, enum uio_seg seg, int filemode, int createmode, 1238*b819cea2SGordon Ross struct vnode **vpp, enum create crwhy, 1239*b819cea2SGordon Ross mode_t umask, struct vnode *startvp, int fd); 1240*b819cea2SGordon Ross int vn_create(char *pnamep, enum uio_seg seg, struct vattr *vap, 1241*b819cea2SGordon Ross enum vcexcl excl, int mode, struct vnode **vpp, 1242*b819cea2SGordon Ross enum create why, int flag, mode_t umask); 1243*b819cea2SGordon Ross int vn_createat(char *pnamep, enum uio_seg seg, struct vattr *vap, 1244*b819cea2SGordon Ross enum vcexcl excl, int mode, struct vnode **vpp, 1245*b819cea2SGordon Ross enum create why, int flag, mode_t umask, struct vnode *startvp); 1246*b819cea2SGordon Ross int vn_rdwr(enum uio_rw rw, struct vnode *vp, caddr_t base, ssize_t len, 1247*b819cea2SGordon Ross offset_t offset, enum uio_seg seg, int ioflag, rlim64_t ulimit, 1248*b819cea2SGordon Ross cred_t *cr, ssize_t *residp); 1249*b819cea2SGordon Ross 1250*b819cea2SGordon Ross void vn_hold(struct vnode *vp); 1251*b819cea2SGordon Ross void vn_rele(struct vnode *vp); 1252*b819cea2SGordon Ross void vn_rele_async(struct vnode *vp, struct taskq *taskq); 1253*b819cea2SGordon Ross void vn_rele_dnlc(struct vnode *vp); 1254*b819cea2SGordon Ross void vn_rele_stream(struct vnode *vp); 1255*b819cea2SGordon Ross int vn_link(char *from, char *to, enum uio_seg seg); 1256*b819cea2SGordon Ross int vn_linkat(vnode_t *fstartvp, char *from, enum symfollow follow, 1257*b819cea2SGordon Ross vnode_t *tstartvp, char *to, enum uio_seg seg); 1258*b819cea2SGordon Ross int vn_rename(char *from, char *to, enum uio_seg seg); 1259*b819cea2SGordon Ross int vn_renameat(vnode_t *fdvp, char *fname, vnode_t *tdvp, char *tname, 1260*b819cea2SGordon Ross enum uio_seg seg); 1261*b819cea2SGordon Ross int vn_remove(char *fnamep, enum uio_seg seg, enum rm dirflag); 1262*b819cea2SGordon Ross int vn_removeat(vnode_t *startvp, char *fnamep, enum uio_seg seg, 1263*b819cea2SGordon Ross enum rm dirflag); 1264*b819cea2SGordon Ross int vn_compare(vnode_t *vp1, vnode_t *vp2); 1265*b819cea2SGordon Ross int vn_vfswlock(struct vnode *vp); 1266*b819cea2SGordon Ross int vn_vfswlock_wait(struct vnode *vp); 1267*b819cea2SGordon Ross int vn_vfsrlock(struct vnode *vp); 1268*b819cea2SGordon Ross int vn_vfsrlock_wait(struct vnode *vp); 1269*b819cea2SGordon Ross void vn_vfsunlock(struct vnode *vp); 1270*b819cea2SGordon Ross int vn_vfswlock_held(struct vnode *vp); 1271*b819cea2SGordon Ross vnode_t *specvp(struct vnode *vp, dev_t dev, vtype_t type, struct cred *cr); 1272*b819cea2SGordon Ross vnode_t *makespecvp(dev_t dev, vtype_t type); 1273*b819cea2SGordon Ross 1274*b819cea2SGordon Ross #if defined(_KERNEL) 1275*b819cea2SGordon Ross vn_vfslocks_entry_t *vn_vfslocks_getlock(void *); 1276*b819cea2SGordon Ross void vn_vfslocks_rele(vn_vfslocks_entry_t *); 1277*b819cea2SGordon Ross #endif 1278*b819cea2SGordon Ross 1279*b819cea2SGordon Ross boolean_t vn_is_reparse(vnode_t *, cred_t *, caller_context_t *); 1280*b819cea2SGordon Ross 1281*b819cea2SGordon Ross void vn_copypath(struct vnode *src, struct vnode *dst); 1282*b819cea2SGordon Ross void vn_setpath_str(struct vnode *vp, const char *str, size_t len); 1283*b819cea2SGordon Ross void vn_setpath(vnode_t *rootvp, struct vnode *startvp, struct vnode *vp, 1284*b819cea2SGordon Ross const char *path, size_t plen); 1285*b819cea2SGordon Ross void vn_renamepath(vnode_t *dvp, vnode_t *vp, const char *nm, size_t len); 1286*b819cea2SGordon Ross 1287*b819cea2SGordon Ross /* Vnode event notification */ 1288*b819cea2SGordon Ross void vnevent_rename_src(vnode_t *, vnode_t *, char *, caller_context_t *); 1289*b819cea2SGordon Ross void vnevent_rename_dest(vnode_t *, vnode_t *, char *, caller_context_t *); 1290*b819cea2SGordon Ross void vnevent_remove(vnode_t *, vnode_t *, char *, caller_context_t *); 1291*b819cea2SGordon Ross void vnevent_rmdir(vnode_t *, vnode_t *, char *, caller_context_t *); 1292*b819cea2SGordon Ross void vnevent_create(vnode_t *, caller_context_t *); 1293*b819cea2SGordon Ross void vnevent_link(vnode_t *, caller_context_t *); 1294*b819cea2SGordon Ross void vnevent_rename_dest_dir(vnode_t *, caller_context_t *ct); 1295*b819cea2SGordon Ross void vnevent_mountedover(vnode_t *, caller_context_t *); 1296*b819cea2SGordon Ross void vnevent_truncate(vnode_t *, caller_context_t *); 1297*b819cea2SGordon Ross int vnevent_support(vnode_t *, caller_context_t *); 1298*b819cea2SGordon Ross 1299*b819cea2SGordon Ross /* Vnode specific data */ 1300*b819cea2SGordon Ross void vsd_create(uint_t *, void (*)(void *)); 1301*b819cea2SGordon Ross void vsd_destroy(uint_t *); 1302*b819cea2SGordon Ross void *vsd_get(vnode_t *, uint_t); 1303*b819cea2SGordon Ross int vsd_set(vnode_t *, uint_t, void *); 1304*b819cea2SGordon Ross void vsd_free(vnode_t *); 1305*b819cea2SGordon Ross 1306*b819cea2SGordon Ross /* 1307*b819cea2SGordon Ross * Extensible vnode attribute (xva) routines: 1308*b819cea2SGordon Ross * xva_init() initializes an xvattr_t (zero struct, init mapsize, set AT_XATTR) 1309*b819cea2SGordon Ross * xva_getxoptattr() returns a ponter to the xoptattr_t section of xvattr_t 1310*b819cea2SGordon Ross */ 1311*b819cea2SGordon Ross void xva_init(xvattr_t *); 1312*b819cea2SGordon Ross xoptattr_t *xva_getxoptattr(xvattr_t *); /* Get ptr to xoptattr_t */ 1313*b819cea2SGordon Ross 1314*b819cea2SGordon Ross void xattr_init(void); /* Initialize vnodeops for xattrs */ 1315*b819cea2SGordon Ross 1316*b819cea2SGordon Ross /* GFS tunnel for xattrs */ 1317*b819cea2SGordon Ross int xattr_dir_lookup(vnode_t *, vnode_t **, int, cred_t *); 1318*b819cea2SGordon Ross 1319*b819cea2SGordon Ross /* Reparse Point */ 1320*b819cea2SGordon Ross void reparse_point_init(void); 1321*b819cea2SGordon Ross 1322*b819cea2SGordon Ross /* Context identification */ 1323*b819cea2SGordon Ross u_longlong_t fs_new_caller_id(); 1324*b819cea2SGordon Ross 1325*b819cea2SGordon Ross int vn_vmpss_usepageio(vnode_t *); 1326*b819cea2SGordon Ross 1327*b819cea2SGordon Ross /* 1328*b819cea2SGordon Ross * Needed for use of IS_VMODSORT() in kernel. 1329*b819cea2SGordon Ross */ 1330*b819cea2SGordon Ross extern uint_t pvn_vmodsort_supported; 1331*b819cea2SGordon Ross 1332*b819cea2SGordon Ross #define VN_HOLD(vp) { \ 1333*b819cea2SGordon Ross vn_hold(vp); \ 1334*b819cea2SGordon Ross } 1335*b819cea2SGordon Ross 1336*b819cea2SGordon Ross #define VN_RELE(vp) { \ 1337*b819cea2SGordon Ross vn_rele(vp); \ 1338*b819cea2SGordon Ross } 1339*b819cea2SGordon Ross 1340*b819cea2SGordon Ross #define VN_RELE_ASYNC(vp, taskq) { \ 1341*b819cea2SGordon Ross vn_rele_async(vp, taskq); \ 1342*b819cea2SGordon Ross } 1343*b819cea2SGordon Ross 1344*b819cea2SGordon Ross #define VN_SET_VFS_TYPE_DEV(vp, vfsp, type, dev) { \ 1345*b819cea2SGordon Ross (vp)->v_vfsp = (vfsp); \ 1346*b819cea2SGordon Ross (vp)->v_type = (type); \ 1347*b819cea2SGordon Ross (vp)->v_rdev = (dev); \ 1348*b819cea2SGordon Ross } 1349*b819cea2SGordon Ross 1350*b819cea2SGordon Ross /* 1351*b819cea2SGordon Ross * Compare two vnodes for equality. In general this macro should be used 1352*b819cea2SGordon Ross * in preference to calling VOP_CMP directly. 1353*b819cea2SGordon Ross */ 1354*b819cea2SGordon Ross #if defined(_FAKE_KERNEL) 1355*b819cea2SGordon Ross #define VN_CMP(VP1, VP2) \ 1356*b819cea2SGordon Ross (((VP1) == (VP2)) ? 1 : VOP_CMP(VP1, VP2, NULL)) 1357*b819cea2SGordon Ross #else 1358*b819cea2SGordon Ross #define VN_CMP(VP1, VP2) ((VP1) == (VP2) ? 1 : \ 1359*b819cea2SGordon Ross ((VP1) && (VP2) && (vn_getops(VP1) == vn_getops(VP2)) ? \ 1360*b819cea2SGordon Ross VOP_CMP(VP1, VP2, NULL) : 0)) 1361*b819cea2SGordon Ross #endif 1362*b819cea2SGordon Ross 1363*b819cea2SGordon Ross /* 1364*b819cea2SGordon Ross * Some well-known global vnodes used by the VM system to name pages. 1365*b819cea2SGordon Ross */ 1366*b819cea2SGordon Ross extern struct vnode kvps[]; 1367*b819cea2SGordon Ross 1368*b819cea2SGordon Ross typedef enum { 1369*b819cea2SGordon Ross KV_KVP, /* vnode for all segkmem pages */ 1370*b819cea2SGordon Ross KV_ZVP, /* vnode for all ZFS pages */ 1371*b819cea2SGordon Ross #if defined(__sparc) 1372*b819cea2SGordon Ross KV_MPVP, /* vnode for all page_t meta-pages */ 1373*b819cea2SGordon Ross KV_PROMVP, /* vnode for all PROM pages */ 1374*b819cea2SGordon Ross #endif /* __sparc */ 1375*b819cea2SGordon Ross KV_MAX /* total number of vnodes in kvps[] */ 1376*b819cea2SGordon Ross } kvps_index_t; 1377*b819cea2SGordon Ross 1378*b819cea2SGordon Ross #define VN_ISKAS(vp) ((vp) >= &kvps[0] && (vp) < &kvps[KV_MAX]) 1379*b819cea2SGordon Ross 1380*b819cea2SGordon Ross #endif /* _KERNEL */ 1381*b819cea2SGordon Ross 1382*b819cea2SGordon Ross /* 1383*b819cea2SGordon Ross * Flags to VOP_SETATTR/VOP_GETATTR. 1384*b819cea2SGordon Ross */ 1385*b819cea2SGordon Ross #define ATTR_UTIME 0x01 /* non-default utime(2) request */ 1386*b819cea2SGordon Ross #define ATTR_EXEC 0x02 /* invocation from exec(2) */ 1387*b819cea2SGordon Ross #define ATTR_COMM 0x04 /* yield common vp attributes */ 1388*b819cea2SGordon Ross #define ATTR_HINT 0x08 /* information returned will be `hint' */ 1389*b819cea2SGordon Ross #define ATTR_REAL 0x10 /* yield attributes of the real vp */ 1390*b819cea2SGordon Ross #define ATTR_NOACLCHECK 0x20 /* Don't check ACL when checking permissions */ 1391*b819cea2SGordon Ross #define ATTR_TRIGGER 0x40 /* Mount first if vnode is a trigger mount */ 1392*b819cea2SGordon Ross /* 1393*b819cea2SGordon Ross * Generally useful macros. 1394*b819cea2SGordon Ross */ 1395*b819cea2SGordon Ross #define VBSIZE(vp) ((vp)->v_vfsp->vfs_bsize) 1396*b819cea2SGordon Ross 1397*b819cea2SGordon Ross #define VTOZONE(vp) ((vp)->v_vfsp->vfs_zone) 1398*b819cea2SGordon Ross 1399*b819cea2SGordon Ross #define NULLVP ((struct vnode *)0) 1400*b819cea2SGordon Ross #define NULLVPP ((struct vnode **)0) 1401*b819cea2SGordon Ross 1402*b819cea2SGordon Ross #ifdef _KERNEL 1403*b819cea2SGordon Ross 1404*b819cea2SGordon Ross /* 1405*b819cea2SGordon Ross * Structure used while handling asynchronous VOP_PUTPAGE operations. 1406*b819cea2SGordon Ross */ 1407*b819cea2SGordon Ross struct async_reqs { 1408*b819cea2SGordon Ross struct async_reqs *a_next; /* pointer to next arg struct */ 1409*b819cea2SGordon Ross struct vnode *a_vp; /* vnode pointer */ 1410*b819cea2SGordon Ross u_offset_t a_off; /* offset in file */ 1411*b819cea2SGordon Ross uint_t a_len; /* size of i/o request */ 1412*b819cea2SGordon Ross int a_flags; /* flags to indicate operation type */ 1413*b819cea2SGordon Ross struct cred *a_cred; /* cred pointer */ 1414*b819cea2SGordon Ross ushort_t a_prealloced; /* set if struct is pre-allocated */ 1415*b819cea2SGordon Ross }; 1416*b819cea2SGordon Ross 1417*b819cea2SGordon Ross /* 1418*b819cea2SGordon Ross * VN_DISPOSE() -- given a page pointer, safely invoke VOP_DISPOSE(). 1419*b819cea2SGordon Ross * Note that there is no guarantee that the page passed in will be 1420*b819cea2SGordon Ross * freed. If that is required, then a check after calling VN_DISPOSE would 1421*b819cea2SGordon Ross * be necessary to ensure the page was freed. 1422*b819cea2SGordon Ross */ 1423*b819cea2SGordon Ross #define VN_DISPOSE(pp, flag, dn, cr) { \ 1424*b819cea2SGordon Ross if ((pp)->p_vnode != NULL && !VN_ISKAS((pp)->p_vnode)) \ 1425*b819cea2SGordon Ross VOP_DISPOSE((pp)->p_vnode, (pp), (flag), (dn), (cr), NULL); \ 1426*b819cea2SGordon Ross else if ((flag) == B_FREE) \ 1427*b819cea2SGordon Ross page_free((pp), (dn)); \ 1428*b819cea2SGordon Ross else \ 1429*b819cea2SGordon Ross page_destroy((pp), (dn)); \ 1430*b819cea2SGordon Ross } 1431*b819cea2SGordon Ross 1432*b819cea2SGordon Ross #endif /* _KERNEL */ 1433*b819cea2SGordon Ross 1434*b819cea2SGordon Ross #ifdef __cplusplus 1435*b819cea2SGordon Ross } 1436*b819cea2SGordon Ross #endif 1437*b819cea2SGordon Ross 1438*b819cea2SGordon Ross #endif /* _SYS_VNODE_H */ 1439