1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 28*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate /* 31*7c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 32*7c478bd9Sstevel@tonic-gate * The Regents of the University of California 33*7c478bd9Sstevel@tonic-gate * All Rights Reserved 34*7c478bd9Sstevel@tonic-gate * 35*7c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 36*7c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 37*7c478bd9Sstevel@tonic-gate * contributors. 38*7c478bd9Sstevel@tonic-gate */ 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate #ifndef _SYS_VNODE_H 41*7c478bd9Sstevel@tonic-gate #define _SYS_VNODE_H 42*7c478bd9Sstevel@tonic-gate 43*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 46*7c478bd9Sstevel@tonic-gate #include <sys/t_lock.h> 47*7c478bd9Sstevel@tonic-gate #include <sys/rwstlock.h> 48*7c478bd9Sstevel@tonic-gate #include <sys/time_impl.h> 49*7c478bd9Sstevel@tonic-gate #include <sys/cred.h> 50*7c478bd9Sstevel@tonic-gate #include <sys/uio.h> 51*7c478bd9Sstevel@tonic-gate #include <sys/resource.h> 52*7c478bd9Sstevel@tonic-gate #include <vm/seg_enum.h> 53*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 54*7c478bd9Sstevel@tonic-gate #include <sys/buf.h> 55*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 56*7c478bd9Sstevel@tonic-gate 57*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 58*7c478bd9Sstevel@tonic-gate extern "C" { 59*7c478bd9Sstevel@tonic-gate #endif 60*7c478bd9Sstevel@tonic-gate 61*7c478bd9Sstevel@tonic-gate 62*7c478bd9Sstevel@tonic-gate typedef int (*fs_generic_func_p) (); 63*7c478bd9Sstevel@tonic-gate 64*7c478bd9Sstevel@tonic-gate /* 65*7c478bd9Sstevel@tonic-gate * File systems use arrays of fs_operation_def structures to form 66*7c478bd9Sstevel@tonic-gate * name/value pairs of operations. These arrays get passed to: 67*7c478bd9Sstevel@tonic-gate * 68*7c478bd9Sstevel@tonic-gate * - vn_make_ops() to create vnodeops 69*7c478bd9Sstevel@tonic-gate * - vfs_makefsops()/vfs_setfsops() to create vfsops. 70*7c478bd9Sstevel@tonic-gate */ 71*7c478bd9Sstevel@tonic-gate typedef struct fs_operation_def { 72*7c478bd9Sstevel@tonic-gate char *name; /* name of operation (NULL at end) */ 73*7c478bd9Sstevel@tonic-gate fs_generic_func_p func; /* function implementing operation */ 74*7c478bd9Sstevel@tonic-gate } fs_operation_def_t; 75*7c478bd9Sstevel@tonic-gate 76*7c478bd9Sstevel@tonic-gate /* 77*7c478bd9Sstevel@tonic-gate * The operation registration mechanism uses two master tables of operations: 78*7c478bd9Sstevel@tonic-gate * one for vnode operations (vn_ops_table[]) and one for vfs operations 79*7c478bd9Sstevel@tonic-gate * (vfs_ops_table[]). These tables are arrays of fs_operation_trans_def 80*7c478bd9Sstevel@tonic-gate * structures. They contain all of the information necessary for the system 81*7c478bd9Sstevel@tonic-gate * to populate an operations structure (e.g., vnodeops, vfsops). 82*7c478bd9Sstevel@tonic-gate * 83*7c478bd9Sstevel@tonic-gate * File systems call registration routines (vfs_setfsops(), vfs_makefsops(), 84*7c478bd9Sstevel@tonic-gate * and vn_make_ops()) and pass in their operations specification tables 85*7c478bd9Sstevel@tonic-gate * (arrays of fs_operation_def structures). These routines use the master 86*7c478bd9Sstevel@tonic-gate * table(s) of operations to build a vnodeops or vfsops structure. 87*7c478bd9Sstevel@tonic-gate */ 88*7c478bd9Sstevel@tonic-gate typedef struct fs_operation_trans_def { 89*7c478bd9Sstevel@tonic-gate char *name; /* name of operation (NULL at end) */ 90*7c478bd9Sstevel@tonic-gate int offset; /* byte offset within ops vector */ 91*7c478bd9Sstevel@tonic-gate fs_generic_func_p defaultFunc; /* default function */ 92*7c478bd9Sstevel@tonic-gate fs_generic_func_p errorFunc; /* error function */ 93*7c478bd9Sstevel@tonic-gate } fs_operation_trans_def_t; 94*7c478bd9Sstevel@tonic-gate 95*7c478bd9Sstevel@tonic-gate 96*7c478bd9Sstevel@tonic-gate /* 97*7c478bd9Sstevel@tonic-gate * The vnode is the focus of all file activity in UNIX. 98*7c478bd9Sstevel@tonic-gate * A vnode is allocated for each active file, each current 99*7c478bd9Sstevel@tonic-gate * directory, each mounted-on file, and the root. 100*7c478bd9Sstevel@tonic-gate * 101*7c478bd9Sstevel@tonic-gate * Each vnode is usually associated with a file-system-specific node (for 102*7c478bd9Sstevel@tonic-gate * UFS, this is the in-memory inode). Generally, a vnode and an fs-node 103*7c478bd9Sstevel@tonic-gate * should be created and destroyed together as a pair. 104*7c478bd9Sstevel@tonic-gate * 105*7c478bd9Sstevel@tonic-gate * If a vnode is reused for a new file, it should be reinitialized by calling 106*7c478bd9Sstevel@tonic-gate * either vn_reinit() or vn_recycle(). 107*7c478bd9Sstevel@tonic-gate * 108*7c478bd9Sstevel@tonic-gate * vn_reinit() resets the entire vnode as if it was returned by vn_alloc(). 109*7c478bd9Sstevel@tonic-gate * The caller is responsible for setting up the entire vnode after calling 110*7c478bd9Sstevel@tonic-gate * vn_reinit(). This is important when using kmem caching where the vnode is 111*7c478bd9Sstevel@tonic-gate * allocated by a constructor, for instance. 112*7c478bd9Sstevel@tonic-gate * 113*7c478bd9Sstevel@tonic-gate * vn_recycle() is used when the file system keeps some state around in both 114*7c478bd9Sstevel@tonic-gate * the vnode and the associated FS-node. In UFS, for example, the inode of 115*7c478bd9Sstevel@tonic-gate * a deleted file can be reused immediately. The v_data, v_vfsp, v_op, etc. 116*7c478bd9Sstevel@tonic-gate * remains the same but certain fields related to the previous instance need 117*7c478bd9Sstevel@tonic-gate * to be reset. In particular: 118*7c478bd9Sstevel@tonic-gate * v_femhead 119*7c478bd9Sstevel@tonic-gate * v_path 120*7c478bd9Sstevel@tonic-gate * v_rdcnt, v_wrcnt 121*7c478bd9Sstevel@tonic-gate * v_mmap_read, v_mmap_write 122*7c478bd9Sstevel@tonic-gate */ 123*7c478bd9Sstevel@tonic-gate 124*7c478bd9Sstevel@tonic-gate /* 125*7c478bd9Sstevel@tonic-gate * vnode types. VNON means no type. These values are unrelated to 126*7c478bd9Sstevel@tonic-gate * values in on-disk inodes. 127*7c478bd9Sstevel@tonic-gate */ 128*7c478bd9Sstevel@tonic-gate typedef enum vtype { 129*7c478bd9Sstevel@tonic-gate VNON = 0, 130*7c478bd9Sstevel@tonic-gate VREG = 1, 131*7c478bd9Sstevel@tonic-gate VDIR = 2, 132*7c478bd9Sstevel@tonic-gate VBLK = 3, 133*7c478bd9Sstevel@tonic-gate VCHR = 4, 134*7c478bd9Sstevel@tonic-gate VLNK = 5, 135*7c478bd9Sstevel@tonic-gate VFIFO = 6, 136*7c478bd9Sstevel@tonic-gate VDOOR = 7, 137*7c478bd9Sstevel@tonic-gate VPROC = 8, 138*7c478bd9Sstevel@tonic-gate VSOCK = 9, 139*7c478bd9Sstevel@tonic-gate VPORT = 10, 140*7c478bd9Sstevel@tonic-gate VBAD = 11 141*7c478bd9Sstevel@tonic-gate } vtype_t; 142*7c478bd9Sstevel@tonic-gate 143*7c478bd9Sstevel@tonic-gate /* 144*7c478bd9Sstevel@tonic-gate * Many of the fields in the vnode are read-only once they are initialized 145*7c478bd9Sstevel@tonic-gate * at vnode creation time. Other fields are protected by locks. 146*7c478bd9Sstevel@tonic-gate * 147*7c478bd9Sstevel@tonic-gate * IMPORTANT: vnodes should be created ONLY by calls to vn_alloc(). They 148*7c478bd9Sstevel@tonic-gate * may not be embedded into the file-system specific node (inode). The 149*7c478bd9Sstevel@tonic-gate * size of vnodes may change. 150*7c478bd9Sstevel@tonic-gate * 151*7c478bd9Sstevel@tonic-gate * The v_lock protects: 152*7c478bd9Sstevel@tonic-gate * v_flag 153*7c478bd9Sstevel@tonic-gate * v_stream 154*7c478bd9Sstevel@tonic-gate * v_count 155*7c478bd9Sstevel@tonic-gate * v_shrlocks 156*7c478bd9Sstevel@tonic-gate * v_path 157*7c478bd9Sstevel@tonic-gate * 158*7c478bd9Sstevel@tonic-gate * A special lock (implemented by vn_vfswlock in vnode.c) protects: 159*7c478bd9Sstevel@tonic-gate * v_vfsmountedhere 160*7c478bd9Sstevel@tonic-gate * 161*7c478bd9Sstevel@tonic-gate * The global flock_lock mutex (in flock.c) protects: 162*7c478bd9Sstevel@tonic-gate * v_filocks 163*7c478bd9Sstevel@tonic-gate * 164*7c478bd9Sstevel@tonic-gate * IMPORTANT NOTE: 165*7c478bd9Sstevel@tonic-gate * 166*7c478bd9Sstevel@tonic-gate * The following vnode fields are considered public and may safely be 167*7c478bd9Sstevel@tonic-gate * accessed by file systems or other consumers: 168*7c478bd9Sstevel@tonic-gate * 169*7c478bd9Sstevel@tonic-gate * v_lock 170*7c478bd9Sstevel@tonic-gate * v_flag 171*7c478bd9Sstevel@tonic-gate * v_count 172*7c478bd9Sstevel@tonic-gate * v_data 173*7c478bd9Sstevel@tonic-gate * v_vfsp 174*7c478bd9Sstevel@tonic-gate * v_stream 175*7c478bd9Sstevel@tonic-gate * v_type 176*7c478bd9Sstevel@tonic-gate * v_rdev 177*7c478bd9Sstevel@tonic-gate * 178*7c478bd9Sstevel@tonic-gate * ALL OTHER FIELDS SHOULD BE ACCESSED ONLY BY THE OWNER OF THAT FIELD. 179*7c478bd9Sstevel@tonic-gate * In particular, file systems should not access other fields; they may 180*7c478bd9Sstevel@tonic-gate * change or even be removed. The functionality which was once provided 181*7c478bd9Sstevel@tonic-gate * by these fields is available through vn_* functions. 182*7c478bd9Sstevel@tonic-gate */ 183*7c478bd9Sstevel@tonic-gate 184*7c478bd9Sstevel@tonic-gate struct fem_head; /* from fem.h */ 185*7c478bd9Sstevel@tonic-gate 186*7c478bd9Sstevel@tonic-gate typedef struct vnode { 187*7c478bd9Sstevel@tonic-gate kmutex_t v_lock; /* protects vnode fields */ 188*7c478bd9Sstevel@tonic-gate uint_t v_flag; /* vnode flags (see below) */ 189*7c478bd9Sstevel@tonic-gate uint_t v_count; /* reference count */ 190*7c478bd9Sstevel@tonic-gate void *v_data; /* private data for fs */ 191*7c478bd9Sstevel@tonic-gate struct vfs *v_vfsp; /* ptr to containing VFS */ 192*7c478bd9Sstevel@tonic-gate struct stdata *v_stream; /* associated stream */ 193*7c478bd9Sstevel@tonic-gate enum vtype v_type; /* vnode type */ 194*7c478bd9Sstevel@tonic-gate dev_t v_rdev; /* device (VCHR, VBLK) */ 195*7c478bd9Sstevel@tonic-gate 196*7c478bd9Sstevel@tonic-gate /* PRIVATE FIELDS BELOW - DO NOT USE */ 197*7c478bd9Sstevel@tonic-gate 198*7c478bd9Sstevel@tonic-gate struct vfs *v_vfsmountedhere; /* ptr to vfs mounted here */ 199*7c478bd9Sstevel@tonic-gate struct vnodeops *v_op; /* vnode operations */ 200*7c478bd9Sstevel@tonic-gate struct page *v_pages; /* vnode pages list */ 201*7c478bd9Sstevel@tonic-gate pgcnt_t v_npages; /* # pages on this vnode */ 202*7c478bd9Sstevel@tonic-gate pgcnt_t v_msnpages; /* # pages charged to v_mset */ 203*7c478bd9Sstevel@tonic-gate struct page *v_scanfront; /* scanner front hand */ 204*7c478bd9Sstevel@tonic-gate struct page *v_scanback; /* scanner back hand */ 205*7c478bd9Sstevel@tonic-gate struct filock *v_filocks; /* ptr to filock list */ 206*7c478bd9Sstevel@tonic-gate struct shrlocklist *v_shrlocks; /* ptr to shrlock list */ 207*7c478bd9Sstevel@tonic-gate krwlock_t v_nbllock; /* sync for NBMAND locks */ 208*7c478bd9Sstevel@tonic-gate kcondvar_t v_cv; /* synchronize locking */ 209*7c478bd9Sstevel@tonic-gate void *v_locality; /* hook for locality info */ 210*7c478bd9Sstevel@tonic-gate struct fem_head *v_femhead; /* fs monitoring */ 211*7c478bd9Sstevel@tonic-gate char *v_path; /* cached path */ 212*7c478bd9Sstevel@tonic-gate uint_t v_rdcnt; /* open for read count (VREG only) */ 213*7c478bd9Sstevel@tonic-gate uint_t v_wrcnt; /* open for write count (VREG only) */ 214*7c478bd9Sstevel@tonic-gate u_longlong_t v_mmap_read; /* mmap read count */ 215*7c478bd9Sstevel@tonic-gate u_longlong_t v_mmap_write; /* mmap write count */ 216*7c478bd9Sstevel@tonic-gate void *v_mpssdata; /* info for large page mappings */ 217*7c478bd9Sstevel@tonic-gate hrtime_t v_scantime; /* last time this vnode was scanned */ 218*7c478bd9Sstevel@tonic-gate ushort_t v_mset; /* memory set ID */ 219*7c478bd9Sstevel@tonic-gate uint_t v_msflags; /* memory set flags */ 220*7c478bd9Sstevel@tonic-gate struct vnode *v_msnext; /* list of vnodes on an mset */ 221*7c478bd9Sstevel@tonic-gate struct vnode *v_msprev; /* list of vnodes on an mset */ 222*7c478bd9Sstevel@tonic-gate krwlock_t v_mslock; /* protects v_mset */ 223*7c478bd9Sstevel@tonic-gate } vnode_t; 224*7c478bd9Sstevel@tonic-gate 225*7c478bd9Sstevel@tonic-gate #define IS_DEVVP(vp) \ 226*7c478bd9Sstevel@tonic-gate ((vp)->v_type == VCHR || (vp)->v_type == VBLK || (vp)->v_type == VFIFO) 227*7c478bd9Sstevel@tonic-gate 228*7c478bd9Sstevel@tonic-gate /* 229*7c478bd9Sstevel@tonic-gate * vnode flags. 230*7c478bd9Sstevel@tonic-gate */ 231*7c478bd9Sstevel@tonic-gate #define VROOT 0x01 /* root of its file system */ 232*7c478bd9Sstevel@tonic-gate #define VNOCACHE 0x02 /* don't keep cache pages on vnode */ 233*7c478bd9Sstevel@tonic-gate #define VNOMAP 0x04 /* file cannot be mapped/faulted */ 234*7c478bd9Sstevel@tonic-gate #define VDUP 0x08 /* file should be dup'ed rather then opened */ 235*7c478bd9Sstevel@tonic-gate #define VNOSWAP 0x10 /* file cannot be used as virtual swap device */ 236*7c478bd9Sstevel@tonic-gate #define VNOMOUNT 0x20 /* file cannot be covered by mount */ 237*7c478bd9Sstevel@tonic-gate #define VISSWAP 0x40 /* vnode is being used for swap */ 238*7c478bd9Sstevel@tonic-gate #define VSWAPLIKE 0x80 /* vnode acts like swap (but may not be) */ 239*7c478bd9Sstevel@tonic-gate 240*7c478bd9Sstevel@tonic-gate #define IS_SWAPVP(vp) (((vp)->v_flag & (VISSWAP | VSWAPLIKE)) != 0) 241*7c478bd9Sstevel@tonic-gate 242*7c478bd9Sstevel@tonic-gate typedef struct vn_vfslocks_entry { 243*7c478bd9Sstevel@tonic-gate rwstlock_t ve_lock; 244*7c478bd9Sstevel@tonic-gate void *ve_vpvfs; 245*7c478bd9Sstevel@tonic-gate struct vn_vfslocks_entry *ve_next; 246*7c478bd9Sstevel@tonic-gate uint32_t ve_refcnt; 247*7c478bd9Sstevel@tonic-gate char pad[64 - sizeof (rwstlock_t) - 2 * sizeof (void *) - \ 248*7c478bd9Sstevel@tonic-gate sizeof (uint32_t)]; 249*7c478bd9Sstevel@tonic-gate } vn_vfslocks_entry_t; 250*7c478bd9Sstevel@tonic-gate 251*7c478bd9Sstevel@tonic-gate /* 252*7c478bd9Sstevel@tonic-gate * The following two flags are used to lock the v_vfsmountedhere field 253*7c478bd9Sstevel@tonic-gate */ 254*7c478bd9Sstevel@tonic-gate #define VVFSLOCK 0x100 255*7c478bd9Sstevel@tonic-gate #define VVFSWAIT 0x200 256*7c478bd9Sstevel@tonic-gate 257*7c478bd9Sstevel@tonic-gate /* 258*7c478bd9Sstevel@tonic-gate * Used to serialize VM operations on a vnode 259*7c478bd9Sstevel@tonic-gate */ 260*7c478bd9Sstevel@tonic-gate #define VVMLOCK 0x400 261*7c478bd9Sstevel@tonic-gate 262*7c478bd9Sstevel@tonic-gate /* 263*7c478bd9Sstevel@tonic-gate * Tell vn_open() not to fail a directory open for writing but 264*7c478bd9Sstevel@tonic-gate * to go ahead and call VOP_OPEN() to let the filesystem check. 265*7c478bd9Sstevel@tonic-gate */ 266*7c478bd9Sstevel@tonic-gate #define VDIROPEN 0x800 267*7c478bd9Sstevel@tonic-gate 268*7c478bd9Sstevel@tonic-gate /* 269*7c478bd9Sstevel@tonic-gate * Flag to let the VM system know that this file is most likely a binary 270*7c478bd9Sstevel@tonic-gate * or shared library since it has been mmap()ed EXEC at some time. 271*7c478bd9Sstevel@tonic-gate */ 272*7c478bd9Sstevel@tonic-gate #define VVMEXEC 0x1000 273*7c478bd9Sstevel@tonic-gate 274*7c478bd9Sstevel@tonic-gate #define VPXFS 0x2000 /* clustering: global fs proxy vnode */ 275*7c478bd9Sstevel@tonic-gate 276*7c478bd9Sstevel@tonic-gate #define IS_PXFSVP(vp) ((vp)->v_flag & VPXFS) 277*7c478bd9Sstevel@tonic-gate 278*7c478bd9Sstevel@tonic-gate #define V_XATTRDIR 0x4000 /* attribute unnamed directory */ 279*7c478bd9Sstevel@tonic-gate 280*7c478bd9Sstevel@tonic-gate #define V_LOCALITY 0x8000 /* whether locality aware */ 281*7c478bd9Sstevel@tonic-gate 282*7c478bd9Sstevel@tonic-gate /* 283*7c478bd9Sstevel@tonic-gate * Flag that indicates the VM should maintain the v_pages list with all modified 284*7c478bd9Sstevel@tonic-gate * pages on one end and unmodified pages at the other. This makes finding dirty 285*7c478bd9Sstevel@tonic-gate * pages to write back to disk much faster at the expense of taking a minor 286*7c478bd9Sstevel@tonic-gate * fault on the first store instruction which touches a writable page. 287*7c478bd9Sstevel@tonic-gate */ 288*7c478bd9Sstevel@tonic-gate #define VMODSORT (0x10000) 289*7c478bd9Sstevel@tonic-gate #define IS_VMODSORT(vp) \ 290*7c478bd9Sstevel@tonic-gate (pvn_vmodsort_supported != 0 && ((vp)->v_flag & VMODSORT) != 0) 291*7c478bd9Sstevel@tonic-gate 292*7c478bd9Sstevel@tonic-gate #define VISSWAPFS 0x20000 /* vnode is being used for swapfs */ 293*7c478bd9Sstevel@tonic-gate #define IS_SWAPFSVP(vp) (((vp)->v_flag & VISSWAPFS) != 0) 294*7c478bd9Sstevel@tonic-gate 295*7c478bd9Sstevel@tonic-gate /* 296*7c478bd9Sstevel@tonic-gate * Vnode attributes. A bit-mask is supplied as part of the 297*7c478bd9Sstevel@tonic-gate * structure to indicate the attributes the caller wants to 298*7c478bd9Sstevel@tonic-gate * set (setattr) or extract (getattr). 299*7c478bd9Sstevel@tonic-gate */ 300*7c478bd9Sstevel@tonic-gate 301*7c478bd9Sstevel@tonic-gate /* 302*7c478bd9Sstevel@tonic-gate * Note that va_nodeid and va_nblocks are 64bit data type. 303*7c478bd9Sstevel@tonic-gate * We support large files over NFSV3. With Solaris client and 304*7c478bd9Sstevel@tonic-gate * Server that generates 64bit ino's and sizes these fields 305*7c478bd9Sstevel@tonic-gate * will overflow if they are 32 bit sizes. 306*7c478bd9Sstevel@tonic-gate */ 307*7c478bd9Sstevel@tonic-gate 308*7c478bd9Sstevel@tonic-gate typedef struct vattr { 309*7c478bd9Sstevel@tonic-gate uint_t va_mask; /* bit-mask of attributes */ 310*7c478bd9Sstevel@tonic-gate vtype_t va_type; /* vnode type (for create) */ 311*7c478bd9Sstevel@tonic-gate mode_t va_mode; /* file access mode */ 312*7c478bd9Sstevel@tonic-gate uid_t va_uid; /* owner user id */ 313*7c478bd9Sstevel@tonic-gate gid_t va_gid; /* owner group id */ 314*7c478bd9Sstevel@tonic-gate dev_t va_fsid; /* file system id (dev for now) */ 315*7c478bd9Sstevel@tonic-gate u_longlong_t va_nodeid; /* node id */ 316*7c478bd9Sstevel@tonic-gate nlink_t va_nlink; /* number of references to file */ 317*7c478bd9Sstevel@tonic-gate u_offset_t va_size; /* file size in bytes */ 318*7c478bd9Sstevel@tonic-gate timestruc_t va_atime; /* time of last access */ 319*7c478bd9Sstevel@tonic-gate timestruc_t va_mtime; /* time of last modification */ 320*7c478bd9Sstevel@tonic-gate timestruc_t va_ctime; /* time of last status change */ 321*7c478bd9Sstevel@tonic-gate dev_t va_rdev; /* device the file represents */ 322*7c478bd9Sstevel@tonic-gate uint_t va_blksize; /* fundamental block size */ 323*7c478bd9Sstevel@tonic-gate u_longlong_t va_nblocks; /* # of blocks allocated */ 324*7c478bd9Sstevel@tonic-gate uint_t va_seq; /* sequence number */ 325*7c478bd9Sstevel@tonic-gate } vattr_t; 326*7c478bd9Sstevel@tonic-gate 327*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32 328*7c478bd9Sstevel@tonic-gate /* 329*7c478bd9Sstevel@tonic-gate * For bigtypes time_t changed to 64 bit on the 64-bit kernel. 330*7c478bd9Sstevel@tonic-gate * Define an old version for user/kernel interface 331*7c478bd9Sstevel@tonic-gate */ 332*7c478bd9Sstevel@tonic-gate 333*7c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 334*7c478bd9Sstevel@tonic-gate #pragma pack(4) 335*7c478bd9Sstevel@tonic-gate #endif 336*7c478bd9Sstevel@tonic-gate 337*7c478bd9Sstevel@tonic-gate typedef struct vattr32 { 338*7c478bd9Sstevel@tonic-gate uint32_t va_mask; /* bit-mask of attributes */ 339*7c478bd9Sstevel@tonic-gate vtype_t va_type; /* vnode type (for create) */ 340*7c478bd9Sstevel@tonic-gate mode32_t va_mode; /* file access mode */ 341*7c478bd9Sstevel@tonic-gate uid32_t va_uid; /* owner user id */ 342*7c478bd9Sstevel@tonic-gate gid32_t va_gid; /* owner group id */ 343*7c478bd9Sstevel@tonic-gate dev32_t va_fsid; /* file system id (dev for now) */ 344*7c478bd9Sstevel@tonic-gate u_longlong_t va_nodeid; /* node id */ 345*7c478bd9Sstevel@tonic-gate nlink_t va_nlink; /* number of references to file */ 346*7c478bd9Sstevel@tonic-gate u_offset_t va_size; /* file size in bytes */ 347*7c478bd9Sstevel@tonic-gate timestruc32_t va_atime; /* time of last access */ 348*7c478bd9Sstevel@tonic-gate timestruc32_t va_mtime; /* time of last modification */ 349*7c478bd9Sstevel@tonic-gate timestruc32_t va_ctime; /* time of last status change */ 350*7c478bd9Sstevel@tonic-gate dev32_t va_rdev; /* device the file represents */ 351*7c478bd9Sstevel@tonic-gate uint32_t va_blksize; /* fundamental block size */ 352*7c478bd9Sstevel@tonic-gate u_longlong_t va_nblocks; /* # of blocks allocated */ 353*7c478bd9Sstevel@tonic-gate uint32_t va_seq; /* sequence number */ 354*7c478bd9Sstevel@tonic-gate } vattr32_t; 355*7c478bd9Sstevel@tonic-gate 356*7c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 357*7c478bd9Sstevel@tonic-gate #pragma pack() 358*7c478bd9Sstevel@tonic-gate #endif 359*7c478bd9Sstevel@tonic-gate 360*7c478bd9Sstevel@tonic-gate #else /* not _SYSCALL32 */ 361*7c478bd9Sstevel@tonic-gate #define vattr32 vattr 362*7c478bd9Sstevel@tonic-gate typedef vattr_t vattr32_t; 363*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 364*7c478bd9Sstevel@tonic-gate 365*7c478bd9Sstevel@tonic-gate /* 366*7c478bd9Sstevel@tonic-gate * Attributes of interest to the caller of setattr or getattr. 367*7c478bd9Sstevel@tonic-gate */ 368*7c478bd9Sstevel@tonic-gate #define AT_TYPE 0x0001 369*7c478bd9Sstevel@tonic-gate #define AT_MODE 0x0002 370*7c478bd9Sstevel@tonic-gate #define AT_UID 0x0004 371*7c478bd9Sstevel@tonic-gate #define AT_GID 0x0008 372*7c478bd9Sstevel@tonic-gate #define AT_FSID 0x0010 373*7c478bd9Sstevel@tonic-gate #define AT_NODEID 0x0020 374*7c478bd9Sstevel@tonic-gate #define AT_NLINK 0x0040 375*7c478bd9Sstevel@tonic-gate #define AT_SIZE 0x0080 376*7c478bd9Sstevel@tonic-gate #define AT_ATIME 0x0100 377*7c478bd9Sstevel@tonic-gate #define AT_MTIME 0x0200 378*7c478bd9Sstevel@tonic-gate #define AT_CTIME 0x0400 379*7c478bd9Sstevel@tonic-gate #define AT_RDEV 0x0800 380*7c478bd9Sstevel@tonic-gate #define AT_BLKSIZE 0x1000 381*7c478bd9Sstevel@tonic-gate #define AT_NBLOCKS 0x2000 382*7c478bd9Sstevel@tonic-gate /* 0x4000 */ /* unused */ 383*7c478bd9Sstevel@tonic-gate #define AT_SEQ 0x8000 384*7c478bd9Sstevel@tonic-gate 385*7c478bd9Sstevel@tonic-gate #define AT_ALL (AT_TYPE|AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|\ 386*7c478bd9Sstevel@tonic-gate AT_NLINK|AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|\ 387*7c478bd9Sstevel@tonic-gate AT_RDEV|AT_BLKSIZE|AT_NBLOCKS|AT_SEQ) 388*7c478bd9Sstevel@tonic-gate 389*7c478bd9Sstevel@tonic-gate #define AT_STAT (AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|AT_NLINK|\ 390*7c478bd9Sstevel@tonic-gate AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|AT_RDEV|AT_TYPE) 391*7c478bd9Sstevel@tonic-gate 392*7c478bd9Sstevel@tonic-gate #define AT_TIMES (AT_ATIME|AT_MTIME|AT_CTIME) 393*7c478bd9Sstevel@tonic-gate 394*7c478bd9Sstevel@tonic-gate #define AT_NOSET (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\ 395*7c478bd9Sstevel@tonic-gate AT_BLKSIZE|AT_NBLOCKS|AT_SEQ) 396*7c478bd9Sstevel@tonic-gate 397*7c478bd9Sstevel@tonic-gate /* 398*7c478bd9Sstevel@tonic-gate * Modes. Some values same as S_xxx entries from stat.h for convenience. 399*7c478bd9Sstevel@tonic-gate */ 400*7c478bd9Sstevel@tonic-gate #define VSUID 04000 /* set user id on execution */ 401*7c478bd9Sstevel@tonic-gate #define VSGID 02000 /* set group id on execution */ 402*7c478bd9Sstevel@tonic-gate #define VSVTX 01000 /* save swapped text even after use */ 403*7c478bd9Sstevel@tonic-gate 404*7c478bd9Sstevel@tonic-gate /* 405*7c478bd9Sstevel@tonic-gate * Permissions. 406*7c478bd9Sstevel@tonic-gate */ 407*7c478bd9Sstevel@tonic-gate #define VREAD 00400 408*7c478bd9Sstevel@tonic-gate #define VWRITE 00200 409*7c478bd9Sstevel@tonic-gate #define VEXEC 00100 410*7c478bd9Sstevel@tonic-gate 411*7c478bd9Sstevel@tonic-gate #define MODEMASK 07777 /* mode bits plus permission bits */ 412*7c478bd9Sstevel@tonic-gate #define PERMMASK 00777 /* permission bits */ 413*7c478bd9Sstevel@tonic-gate 414*7c478bd9Sstevel@tonic-gate /* 415*7c478bd9Sstevel@tonic-gate * Check whether mandatory file locking is enabled. 416*7c478bd9Sstevel@tonic-gate */ 417*7c478bd9Sstevel@tonic-gate 418*7c478bd9Sstevel@tonic-gate #define MANDMODE(mode) (((mode) & (VSGID|(VEXEC>>3))) == VSGID) 419*7c478bd9Sstevel@tonic-gate #define MANDLOCK(vp, mode) ((vp)->v_type == VREG && MANDMODE(mode)) 420*7c478bd9Sstevel@tonic-gate 421*7c478bd9Sstevel@tonic-gate /* 422*7c478bd9Sstevel@tonic-gate * Flags for vnode operations. 423*7c478bd9Sstevel@tonic-gate */ 424*7c478bd9Sstevel@tonic-gate enum rm { RMFILE, RMDIRECTORY }; /* rm or rmdir (remove) */ 425*7c478bd9Sstevel@tonic-gate enum symfollow { NO_FOLLOW, FOLLOW }; /* follow symlinks (or not) */ 426*7c478bd9Sstevel@tonic-gate enum vcexcl { NONEXCL, EXCL }; /* (non)excl create */ 427*7c478bd9Sstevel@tonic-gate enum create { CRCREAT, CRMKNOD, CRMKDIR }; /* reason for create */ 428*7c478bd9Sstevel@tonic-gate 429*7c478bd9Sstevel@tonic-gate typedef enum rm rm_t; 430*7c478bd9Sstevel@tonic-gate typedef enum symfollow symfollow_t; 431*7c478bd9Sstevel@tonic-gate typedef enum vcexcl vcexcl_t; 432*7c478bd9Sstevel@tonic-gate typedef enum create create_t; 433*7c478bd9Sstevel@tonic-gate 434*7c478bd9Sstevel@tonic-gate /* Vnode Events - Used by VOP_VNEVENT */ 435*7c478bd9Sstevel@tonic-gate typedef enum vnevent { 436*7c478bd9Sstevel@tonic-gate VE_SUPPORT = 0, /* Query */ 437*7c478bd9Sstevel@tonic-gate VE_RENAME_SRC = 1, /* Rename, with vnode as source */ 438*7c478bd9Sstevel@tonic-gate VE_RENAME_DEST = 2, /* Rename, with vnode as target/destination */ 439*7c478bd9Sstevel@tonic-gate VE_REMOVE = 3, /* Remove of vnode's name */ 440*7c478bd9Sstevel@tonic-gate VE_RMDIR = 4 /* Remove of directory vnode's name */ 441*7c478bd9Sstevel@tonic-gate } vnevent_t; 442*7c478bd9Sstevel@tonic-gate 443*7c478bd9Sstevel@tonic-gate /* 444*7c478bd9Sstevel@tonic-gate * Values for checking vnode open and map counts 445*7c478bd9Sstevel@tonic-gate */ 446*7c478bd9Sstevel@tonic-gate enum v_mode { V_READ, V_WRITE, V_RDORWR, V_RDANDWR }; 447*7c478bd9Sstevel@tonic-gate 448*7c478bd9Sstevel@tonic-gate typedef enum v_mode v_mode_t; 449*7c478bd9Sstevel@tonic-gate 450*7c478bd9Sstevel@tonic-gate #define V_TRUE 1 451*7c478bd9Sstevel@tonic-gate #define V_FALSE 0 452*7c478bd9Sstevel@tonic-gate 453*7c478bd9Sstevel@tonic-gate /* 454*7c478bd9Sstevel@tonic-gate * Structure used on VOP_GETSECATTR and VOP_SETSECATTR operations 455*7c478bd9Sstevel@tonic-gate */ 456*7c478bd9Sstevel@tonic-gate 457*7c478bd9Sstevel@tonic-gate typedef struct vsecattr { 458*7c478bd9Sstevel@tonic-gate uint_t vsa_mask; /* See below */ 459*7c478bd9Sstevel@tonic-gate int vsa_aclcnt; /* ACL entry count */ 460*7c478bd9Sstevel@tonic-gate void *vsa_aclentp; /* pointer to ACL entries */ 461*7c478bd9Sstevel@tonic-gate int vsa_dfaclcnt; /* default ACL entry count */ 462*7c478bd9Sstevel@tonic-gate void *vsa_dfaclentp; /* pointer to default ACL entries */ 463*7c478bd9Sstevel@tonic-gate } vsecattr_t; 464*7c478bd9Sstevel@tonic-gate 465*7c478bd9Sstevel@tonic-gate /* vsa_mask values */ 466*7c478bd9Sstevel@tonic-gate #define VSA_ACL 0x0001 467*7c478bd9Sstevel@tonic-gate #define VSA_ACLCNT 0x0002 468*7c478bd9Sstevel@tonic-gate #define VSA_DFACL 0x0004 469*7c478bd9Sstevel@tonic-gate #define VSA_DFACLCNT 0x0008 470*7c478bd9Sstevel@tonic-gate #define VSA_ACE 0x0010 471*7c478bd9Sstevel@tonic-gate #define VSA_ACECNT 0x0020 472*7c478bd9Sstevel@tonic-gate 473*7c478bd9Sstevel@tonic-gate /* 474*7c478bd9Sstevel@tonic-gate * Structure used by various vnode operations to determine 475*7c478bd9Sstevel@tonic-gate * the context (pid, host, identity) of a caller. 476*7c478bd9Sstevel@tonic-gate * 477*7c478bd9Sstevel@tonic-gate * The cc_caller_id is used to identify one or more callers who invoke 478*7c478bd9Sstevel@tonic-gate * operations, possibly on behalf of others. For example, the NFS 479*7c478bd9Sstevel@tonic-gate * server could have it's own cc_caller_id which can be detected by 480*7c478bd9Sstevel@tonic-gate * vnode/vfs operations or (FEM) monitors on those operations. New 481*7c478bd9Sstevel@tonic-gate * caller IDs are generated by fs_new_caller_id(). 482*7c478bd9Sstevel@tonic-gate */ 483*7c478bd9Sstevel@tonic-gate typedef struct caller_context { 484*7c478bd9Sstevel@tonic-gate pid_t cc_pid; /* Process ID of the caller */ 485*7c478bd9Sstevel@tonic-gate int cc_sysid; /* System ID, used for remote calls */ 486*7c478bd9Sstevel@tonic-gate u_longlong_t cc_caller_id; /* Identifier for (set of) caller(s) */ 487*7c478bd9Sstevel@tonic-gate } caller_context_t; 488*7c478bd9Sstevel@tonic-gate 489*7c478bd9Sstevel@tonic-gate /* 490*7c478bd9Sstevel@tonic-gate * Structure tags for function prototypes, defined elsewhere. 491*7c478bd9Sstevel@tonic-gate */ 492*7c478bd9Sstevel@tonic-gate struct pathname; 493*7c478bd9Sstevel@tonic-gate struct fid; 494*7c478bd9Sstevel@tonic-gate struct flock64; 495*7c478bd9Sstevel@tonic-gate struct flk_callback; 496*7c478bd9Sstevel@tonic-gate struct shrlock; 497*7c478bd9Sstevel@tonic-gate struct page; 498*7c478bd9Sstevel@tonic-gate struct seg; 499*7c478bd9Sstevel@tonic-gate struct as; 500*7c478bd9Sstevel@tonic-gate struct pollhead; 501*7c478bd9Sstevel@tonic-gate 502*7c478bd9Sstevel@tonic-gate /* 503*7c478bd9Sstevel@tonic-gate * Operations on vnodes. Note: File systems should never operate directly 504*7c478bd9Sstevel@tonic-gate * on a 'vnodeops' structure -- it WILL change in future releases! They 505*7c478bd9Sstevel@tonic-gate * should use vn_make_ops() to create the structure. 506*7c478bd9Sstevel@tonic-gate */ 507*7c478bd9Sstevel@tonic-gate typedef struct vnodeops { 508*7c478bd9Sstevel@tonic-gate const char *vnop_name; 509*7c478bd9Sstevel@tonic-gate int (*vop_open)(vnode_t **, int, cred_t *); 510*7c478bd9Sstevel@tonic-gate int (*vop_close)(vnode_t *, int, int, offset_t, cred_t *); 511*7c478bd9Sstevel@tonic-gate int (*vop_read)(vnode_t *, uio_t *, int, cred_t *, 512*7c478bd9Sstevel@tonic-gate caller_context_t *); 513*7c478bd9Sstevel@tonic-gate int (*vop_write)(vnode_t *, uio_t *, int, cred_t *, 514*7c478bd9Sstevel@tonic-gate caller_context_t *); 515*7c478bd9Sstevel@tonic-gate int (*vop_ioctl)(vnode_t *, int, intptr_t, int, cred_t *, int *); 516*7c478bd9Sstevel@tonic-gate int (*vop_setfl)(vnode_t *, int, int, cred_t *); 517*7c478bd9Sstevel@tonic-gate int (*vop_getattr)(vnode_t *, vattr_t *, int, cred_t *); 518*7c478bd9Sstevel@tonic-gate int (*vop_setattr)(vnode_t *, vattr_t *, int, cred_t *, 519*7c478bd9Sstevel@tonic-gate caller_context_t *); 520*7c478bd9Sstevel@tonic-gate int (*vop_access)(vnode_t *, int, int, cred_t *); 521*7c478bd9Sstevel@tonic-gate int (*vop_lookup)(vnode_t *, char *, vnode_t **, struct pathname *, 522*7c478bd9Sstevel@tonic-gate int, vnode_t *, cred_t *); 523*7c478bd9Sstevel@tonic-gate int (*vop_create)(vnode_t *, char *, vattr_t *, vcexcl_t, int, 524*7c478bd9Sstevel@tonic-gate vnode_t **, cred_t *, int); 525*7c478bd9Sstevel@tonic-gate int (*vop_remove)(vnode_t *, char *, cred_t *); 526*7c478bd9Sstevel@tonic-gate int (*vop_link)(vnode_t *, vnode_t *, char *, cred_t *); 527*7c478bd9Sstevel@tonic-gate int (*vop_rename)(vnode_t *, char *, vnode_t *, char *, cred_t *); 528*7c478bd9Sstevel@tonic-gate int (*vop_mkdir)(vnode_t *, char *, vattr_t *, vnode_t **, 529*7c478bd9Sstevel@tonic-gate cred_t *); 530*7c478bd9Sstevel@tonic-gate int (*vop_rmdir)(vnode_t *, char *, vnode_t *, cred_t *); 531*7c478bd9Sstevel@tonic-gate int (*vop_readdir)(vnode_t *, uio_t *, cred_t *, int *); 532*7c478bd9Sstevel@tonic-gate int (*vop_symlink)(vnode_t *, char *, vattr_t *, char *, cred_t *); 533*7c478bd9Sstevel@tonic-gate int (*vop_readlink)(vnode_t *, uio_t *, cred_t *); 534*7c478bd9Sstevel@tonic-gate int (*vop_fsync)(vnode_t *, int, cred_t *); 535*7c478bd9Sstevel@tonic-gate void (*vop_inactive)(vnode_t *, cred_t *); 536*7c478bd9Sstevel@tonic-gate int (*vop_fid)(vnode_t *, struct fid *); 537*7c478bd9Sstevel@tonic-gate int (*vop_rwlock)(vnode_t *, int, caller_context_t *); 538*7c478bd9Sstevel@tonic-gate void (*vop_rwunlock)(vnode_t *, int, caller_context_t *); 539*7c478bd9Sstevel@tonic-gate int (*vop_seek)(vnode_t *, offset_t, offset_t *); 540*7c478bd9Sstevel@tonic-gate int (*vop_cmp)(vnode_t *, vnode_t *); 541*7c478bd9Sstevel@tonic-gate int (*vop_frlock)(vnode_t *, int, struct flock64 *, int, offset_t, 542*7c478bd9Sstevel@tonic-gate struct flk_callback *, cred_t *); 543*7c478bd9Sstevel@tonic-gate int (*vop_space)(vnode_t *, int, struct flock64 *, int, offset_t, 544*7c478bd9Sstevel@tonic-gate cred_t *, caller_context_t *); 545*7c478bd9Sstevel@tonic-gate int (*vop_realvp)(vnode_t *, vnode_t **); 546*7c478bd9Sstevel@tonic-gate int (*vop_getpage)(vnode_t *, offset_t, size_t, uint_t *, 547*7c478bd9Sstevel@tonic-gate struct page **, size_t, struct seg *, 548*7c478bd9Sstevel@tonic-gate caddr_t, enum seg_rw, cred_t *); 549*7c478bd9Sstevel@tonic-gate int (*vop_putpage)(vnode_t *, offset_t, size_t, int, cred_t *); 550*7c478bd9Sstevel@tonic-gate int (*vop_map)(vnode_t *, offset_t, struct as *, caddr_t *, size_t, 551*7c478bd9Sstevel@tonic-gate uchar_t, uchar_t, uint_t, cred_t *); 552*7c478bd9Sstevel@tonic-gate int (*vop_addmap)(vnode_t *, offset_t, struct as *, caddr_t, size_t, 553*7c478bd9Sstevel@tonic-gate uchar_t, uchar_t, uint_t, cred_t *); 554*7c478bd9Sstevel@tonic-gate int (*vop_delmap)(vnode_t *, offset_t, struct as *, caddr_t, size_t, 555*7c478bd9Sstevel@tonic-gate uint_t, uint_t, uint_t, cred_t *); 556*7c478bd9Sstevel@tonic-gate int (*vop_poll)(vnode_t *, short, int, short *, struct pollhead **); 557*7c478bd9Sstevel@tonic-gate int (*vop_dump)(vnode_t *, caddr_t, int, int); 558*7c478bd9Sstevel@tonic-gate int (*vop_pathconf)(vnode_t *, int, ulong_t *, cred_t *); 559*7c478bd9Sstevel@tonic-gate int (*vop_pageio)(vnode_t *, struct page *, u_offset_t, size_t, 560*7c478bd9Sstevel@tonic-gate int, cred_t *); 561*7c478bd9Sstevel@tonic-gate int (*vop_dumpctl)(vnode_t *, int, int *); 562*7c478bd9Sstevel@tonic-gate void (*vop_dispose)(vnode_t *, struct page *, int, int, cred_t *); 563*7c478bd9Sstevel@tonic-gate int (*vop_setsecattr)(vnode_t *, vsecattr_t *, int, cred_t *); 564*7c478bd9Sstevel@tonic-gate int (*vop_getsecattr)(vnode_t *, vsecattr_t *, int, cred_t *); 565*7c478bd9Sstevel@tonic-gate int (*vop_shrlock)(vnode_t *, int, struct shrlock *, int, cred_t *); 566*7c478bd9Sstevel@tonic-gate int (*vop_vnevent)(vnode_t *, vnevent_t); 567*7c478bd9Sstevel@tonic-gate } vnodeops_t; 568*7c478bd9Sstevel@tonic-gate 569*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 570*7c478bd9Sstevel@tonic-gate 571*7c478bd9Sstevel@tonic-gate extern int fop_open(vnode_t **, int, cred_t *); 572*7c478bd9Sstevel@tonic-gate extern int fop_close(vnode_t *, int, int, offset_t, cred_t *); 573*7c478bd9Sstevel@tonic-gate extern int fop_read(vnode_t *, uio_t *, int, cred_t *, caller_context_t *); 574*7c478bd9Sstevel@tonic-gate extern int fop_write(vnode_t *, uio_t *, int, cred_t *, 575*7c478bd9Sstevel@tonic-gate caller_context_t *); 576*7c478bd9Sstevel@tonic-gate extern int fop_ioctl(vnode_t *, int, intptr_t, int, cred_t *, int *); 577*7c478bd9Sstevel@tonic-gate extern int fop_setfl(vnode_t *, int, int, cred_t *); 578*7c478bd9Sstevel@tonic-gate extern int fop_getattr(vnode_t *, vattr_t *, int, cred_t *); 579*7c478bd9Sstevel@tonic-gate extern int fop_setattr(vnode_t *, vattr_t *, int, cred_t *, 580*7c478bd9Sstevel@tonic-gate caller_context_t *); 581*7c478bd9Sstevel@tonic-gate extern int fop_access(vnode_t *, int, int, cred_t *); 582*7c478bd9Sstevel@tonic-gate extern int fop_lookup(vnode_t *, char *, vnode_t **, struct pathname *, 583*7c478bd9Sstevel@tonic-gate int, vnode_t *, cred_t *); 584*7c478bd9Sstevel@tonic-gate extern int fop_create(vnode_t *, char *, vattr_t *, vcexcl_t, int, 585*7c478bd9Sstevel@tonic-gate vnode_t **, cred_t *, int); 586*7c478bd9Sstevel@tonic-gate extern int fop_remove(vnode_t *vp, char *, cred_t *); 587*7c478bd9Sstevel@tonic-gate extern int fop_link(vnode_t *, vnode_t *, char *, cred_t *); 588*7c478bd9Sstevel@tonic-gate extern int fop_rename(vnode_t *, char *, vnode_t *, char *, cred_t *); 589*7c478bd9Sstevel@tonic-gate extern int fop_mkdir(vnode_t *, char *, vattr_t *, vnode_t **, cred_t *); 590*7c478bd9Sstevel@tonic-gate extern int fop_rmdir(vnode_t *, char *, vnode_t *, cred_t *); 591*7c478bd9Sstevel@tonic-gate extern int fop_readdir(vnode_t *, uio_t *, cred_t *, int *); 592*7c478bd9Sstevel@tonic-gate extern int fop_symlink(vnode_t *, char *, vattr_t *, char *, cred_t *); 593*7c478bd9Sstevel@tonic-gate extern int fop_readlink(vnode_t *, uio_t *, cred_t *); 594*7c478bd9Sstevel@tonic-gate extern int fop_fsync(vnode_t *, int, cred_t *); 595*7c478bd9Sstevel@tonic-gate extern void fop_inactive(vnode_t *, cred_t *); 596*7c478bd9Sstevel@tonic-gate extern int fop_fid(vnode_t *, struct fid *); 597*7c478bd9Sstevel@tonic-gate extern int fop_rwlock(vnode_t *, int, caller_context_t *); 598*7c478bd9Sstevel@tonic-gate extern void fop_rwunlock(vnode_t *, int, caller_context_t *); 599*7c478bd9Sstevel@tonic-gate extern int fop_seek(vnode_t *, offset_t, offset_t *); 600*7c478bd9Sstevel@tonic-gate extern int fop_cmp(vnode_t *, vnode_t *); 601*7c478bd9Sstevel@tonic-gate extern int fop_frlock(vnode_t *, int, struct flock64 *, int, offset_t, 602*7c478bd9Sstevel@tonic-gate struct flk_callback *, cred_t *); 603*7c478bd9Sstevel@tonic-gate extern int fop_space(vnode_t *, int, struct flock64 *, int, offset_t, 604*7c478bd9Sstevel@tonic-gate cred_t *, caller_context_t *); 605*7c478bd9Sstevel@tonic-gate extern int fop_realvp(vnode_t *, vnode_t **); 606*7c478bd9Sstevel@tonic-gate extern int fop_getpage(vnode_t *, offset_t, size_t, uint_t *, 607*7c478bd9Sstevel@tonic-gate struct page **, size_t, struct seg *, 608*7c478bd9Sstevel@tonic-gate caddr_t, enum seg_rw, cred_t *); 609*7c478bd9Sstevel@tonic-gate extern int fop_putpage(vnode_t *, offset_t, size_t, int, cred_t *); 610*7c478bd9Sstevel@tonic-gate extern int fop_map(vnode_t *, offset_t, struct as *, caddr_t *, size_t, 611*7c478bd9Sstevel@tonic-gate uchar_t, uchar_t, uint_t, cred_t *cr); 612*7c478bd9Sstevel@tonic-gate extern int fop_addmap(vnode_t *, offset_t, struct as *, caddr_t, size_t, 613*7c478bd9Sstevel@tonic-gate uchar_t, uchar_t, uint_t, cred_t *); 614*7c478bd9Sstevel@tonic-gate extern int fop_delmap(vnode_t *, offset_t, struct as *, caddr_t, size_t, 615*7c478bd9Sstevel@tonic-gate uint_t, uint_t, uint_t, cred_t *); 616*7c478bd9Sstevel@tonic-gate extern int fop_poll(vnode_t *, short, int, short *, struct pollhead **); 617*7c478bd9Sstevel@tonic-gate extern int fop_dump(vnode_t *, caddr_t, int, int); 618*7c478bd9Sstevel@tonic-gate extern int fop_pathconf(vnode_t *, int, ulong_t *, cred_t *); 619*7c478bd9Sstevel@tonic-gate extern int fop_pageio(vnode_t *, struct page *, u_offset_t, size_t, int, 620*7c478bd9Sstevel@tonic-gate cred_t *); 621*7c478bd9Sstevel@tonic-gate extern int fop_dumpctl(vnode_t *, int, int *); 622*7c478bd9Sstevel@tonic-gate extern void fop_dispose(vnode_t *, struct page *, int, int, cred_t *); 623*7c478bd9Sstevel@tonic-gate extern int fop_setsecattr(vnode_t *, vsecattr_t *, int, cred_t *); 624*7c478bd9Sstevel@tonic-gate extern int fop_getsecattr(vnode_t *, vsecattr_t *, int, cred_t *); 625*7c478bd9Sstevel@tonic-gate extern int fop_shrlock(vnode_t *, int, struct shrlock *, int, cred_t *); 626*7c478bd9Sstevel@tonic-gate extern int fop_vnevent(vnode_t *, vnevent_t); 627*7c478bd9Sstevel@tonic-gate 628*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 629*7c478bd9Sstevel@tonic-gate 630*7c478bd9Sstevel@tonic-gate #define VOP_OPEN(vpp, mode, cr) \ 631*7c478bd9Sstevel@tonic-gate fop_open(vpp, mode, cr) 632*7c478bd9Sstevel@tonic-gate #define VOP_CLOSE(vp, f, c, o, cr) \ 633*7c478bd9Sstevel@tonic-gate fop_close(vp, f, c, o, cr) 634*7c478bd9Sstevel@tonic-gate #define VOP_READ(vp, uiop, iof, cr, ct) \ 635*7c478bd9Sstevel@tonic-gate fop_read(vp, uiop, iof, cr, ct) 636*7c478bd9Sstevel@tonic-gate #define VOP_WRITE(vp, uiop, iof, cr, ct) \ 637*7c478bd9Sstevel@tonic-gate fop_write(vp, uiop, iof, cr, ct) 638*7c478bd9Sstevel@tonic-gate #define VOP_IOCTL(vp, cmd, a, f, cr, rvp) \ 639*7c478bd9Sstevel@tonic-gate fop_ioctl(vp, cmd, a, f, cr, rvp) 640*7c478bd9Sstevel@tonic-gate #define VOP_SETFL(vp, f, a, cr) \ 641*7c478bd9Sstevel@tonic-gate fop_setfl(vp, f, a, cr) 642*7c478bd9Sstevel@tonic-gate #define VOP_GETATTR(vp, vap, f, cr) \ 643*7c478bd9Sstevel@tonic-gate fop_getattr(vp, vap, f, cr) 644*7c478bd9Sstevel@tonic-gate #define VOP_SETATTR(vp, vap, f, cr, ct) \ 645*7c478bd9Sstevel@tonic-gate fop_setattr(vp, vap, f, cr, ct) 646*7c478bd9Sstevel@tonic-gate #define VOP_ACCESS(vp, mode, f, cr) \ 647*7c478bd9Sstevel@tonic-gate fop_access(vp, mode, f, cr) 648*7c478bd9Sstevel@tonic-gate #define VOP_LOOKUP(vp, cp, vpp, pnp, f, rdir, cr) \ 649*7c478bd9Sstevel@tonic-gate fop_lookup(vp, cp, vpp, pnp, f, rdir, cr) 650*7c478bd9Sstevel@tonic-gate #define VOP_CREATE(dvp, p, vap, ex, mode, vpp, cr, flag) \ 651*7c478bd9Sstevel@tonic-gate fop_create(dvp, p, vap, ex, mode, vpp, cr, flag) 652*7c478bd9Sstevel@tonic-gate #define VOP_REMOVE(dvp, p, cr) \ 653*7c478bd9Sstevel@tonic-gate fop_remove(dvp, p, cr) 654*7c478bd9Sstevel@tonic-gate #define VOP_LINK(tdvp, fvp, p, cr) \ 655*7c478bd9Sstevel@tonic-gate fop_link(tdvp, fvp, p, cr) 656*7c478bd9Sstevel@tonic-gate #define VOP_RENAME(fvp, fnm, tdvp, tnm, cr) \ 657*7c478bd9Sstevel@tonic-gate fop_rename(fvp, fnm, tdvp, tnm, cr) 658*7c478bd9Sstevel@tonic-gate #define VOP_MKDIR(dp, p, vap, vpp, cr) \ 659*7c478bd9Sstevel@tonic-gate fop_mkdir(dp, p, vap, vpp, cr) 660*7c478bd9Sstevel@tonic-gate #define VOP_RMDIR(dp, p, cdir, cr) \ 661*7c478bd9Sstevel@tonic-gate fop_rmdir(dp, p, cdir, cr) 662*7c478bd9Sstevel@tonic-gate #define VOP_READDIR(vp, uiop, cr, eofp) \ 663*7c478bd9Sstevel@tonic-gate fop_readdir(vp, uiop, cr, eofp) 664*7c478bd9Sstevel@tonic-gate #define VOP_SYMLINK(dvp, lnm, vap, tnm, cr) \ 665*7c478bd9Sstevel@tonic-gate fop_symlink(dvp, lnm, vap, tnm, cr) 666*7c478bd9Sstevel@tonic-gate #define VOP_READLINK(vp, uiop, cr) \ 667*7c478bd9Sstevel@tonic-gate fop_readlink(vp, uiop, cr) 668*7c478bd9Sstevel@tonic-gate #define VOP_FSYNC(vp, syncflag, cr) \ 669*7c478bd9Sstevel@tonic-gate fop_fsync(vp, syncflag, cr) 670*7c478bd9Sstevel@tonic-gate #define VOP_INACTIVE(vp, cr) \ 671*7c478bd9Sstevel@tonic-gate fop_inactive(vp, cr) 672*7c478bd9Sstevel@tonic-gate #define VOP_FID(vp, fidp) \ 673*7c478bd9Sstevel@tonic-gate fop_fid(vp, fidp) 674*7c478bd9Sstevel@tonic-gate #define VOP_RWLOCK(vp, w, ct) \ 675*7c478bd9Sstevel@tonic-gate fop_rwlock(vp, w, ct) 676*7c478bd9Sstevel@tonic-gate #define VOP_RWUNLOCK(vp, w, ct) \ 677*7c478bd9Sstevel@tonic-gate fop_rwunlock(vp, w, ct) 678*7c478bd9Sstevel@tonic-gate #define VOP_SEEK(vp, ooff, noffp) \ 679*7c478bd9Sstevel@tonic-gate fop_seek(vp, ooff, noffp) 680*7c478bd9Sstevel@tonic-gate #define VOP_CMP(vp1, vp2) \ 681*7c478bd9Sstevel@tonic-gate fop_cmp(vp1, vp2) 682*7c478bd9Sstevel@tonic-gate #define VOP_FRLOCK(vp, cmd, a, f, o, cb, cr) \ 683*7c478bd9Sstevel@tonic-gate fop_frlock(vp, cmd, a, f, o, cb, cr) 684*7c478bd9Sstevel@tonic-gate #define VOP_SPACE(vp, cmd, a, f, o, cr, ct) \ 685*7c478bd9Sstevel@tonic-gate fop_space(vp, cmd, a, f, o, cr, ct) 686*7c478bd9Sstevel@tonic-gate #define VOP_REALVP(vp1, vp2) \ 687*7c478bd9Sstevel@tonic-gate fop_realvp(vp1, vp2) 688*7c478bd9Sstevel@tonic-gate #define VOP_GETPAGE(vp, of, sz, pr, pl, ps, sg, a, rw, cr) \ 689*7c478bd9Sstevel@tonic-gate fop_getpage(vp, of, sz, pr, pl, ps, sg, a, rw, cr) 690*7c478bd9Sstevel@tonic-gate #define VOP_PUTPAGE(vp, of, sz, fl, cr) \ 691*7c478bd9Sstevel@tonic-gate fop_putpage(vp, of, sz, fl, cr) 692*7c478bd9Sstevel@tonic-gate #define VOP_MAP(vp, of, as, a, sz, p, mp, fl, cr) \ 693*7c478bd9Sstevel@tonic-gate fop_map(vp, of, as, a, sz, p, mp, fl, cr) 694*7c478bd9Sstevel@tonic-gate #define VOP_ADDMAP(vp, of, as, a, sz, p, mp, fl, cr) \ 695*7c478bd9Sstevel@tonic-gate fop_addmap(vp, of, as, a, sz, p, mp, fl, cr) 696*7c478bd9Sstevel@tonic-gate #define VOP_DELMAP(vp, of, as, a, sz, p, mp, fl, cr) \ 697*7c478bd9Sstevel@tonic-gate fop_delmap(vp, of, as, a, sz, p, mp, fl, cr) 698*7c478bd9Sstevel@tonic-gate #define VOP_POLL(vp, events, anyyet, reventsp, phpp) \ 699*7c478bd9Sstevel@tonic-gate fop_poll(vp, events, anyyet, reventsp, phpp) 700*7c478bd9Sstevel@tonic-gate #define VOP_DUMP(vp, addr, bn, count) \ 701*7c478bd9Sstevel@tonic-gate fop_dump(vp, addr, bn, count) 702*7c478bd9Sstevel@tonic-gate #define VOP_PATHCONF(vp, cmd, valp, cr) \ 703*7c478bd9Sstevel@tonic-gate fop_pathconf(vp, cmd, valp, cr) 704*7c478bd9Sstevel@tonic-gate #define VOP_PAGEIO(vp, pp, io_off, io_len, flags, cr) \ 705*7c478bd9Sstevel@tonic-gate fop_pageio(vp, pp, io_off, io_len, flags, cr) 706*7c478bd9Sstevel@tonic-gate #define VOP_DUMPCTL(vp, action, blkp) \ 707*7c478bd9Sstevel@tonic-gate fop_dumpctl(vp, action, blkp) 708*7c478bd9Sstevel@tonic-gate #define VOP_DISPOSE(vp, pp, flag, dn, cr) \ 709*7c478bd9Sstevel@tonic-gate fop_dispose(vp, pp, flag, dn, cr) 710*7c478bd9Sstevel@tonic-gate #define VOP_GETSECATTR(vp, vsap, f, cr) \ 711*7c478bd9Sstevel@tonic-gate fop_getsecattr(vp, vsap, f, cr) 712*7c478bd9Sstevel@tonic-gate #define VOP_SETSECATTR(vp, vsap, f, cr) \ 713*7c478bd9Sstevel@tonic-gate fop_setsecattr(vp, vsap, f, cr) 714*7c478bd9Sstevel@tonic-gate #define VOP_SHRLOCK(vp, cmd, shr, f, cr) \ 715*7c478bd9Sstevel@tonic-gate fop_shrlock(vp, cmd, shr, f, cr) 716*7c478bd9Sstevel@tonic-gate #define VOP_VNEVENT(vp, vnevent) \ 717*7c478bd9Sstevel@tonic-gate fop_vnevent(vp, vnevent) 718*7c478bd9Sstevel@tonic-gate 719*7c478bd9Sstevel@tonic-gate #define VOPNAME_OPEN "open" 720*7c478bd9Sstevel@tonic-gate #define VOPNAME_CLOSE "close" 721*7c478bd9Sstevel@tonic-gate #define VOPNAME_READ "read" 722*7c478bd9Sstevel@tonic-gate #define VOPNAME_WRITE "write" 723*7c478bd9Sstevel@tonic-gate #define VOPNAME_IOCTL "ioctl" 724*7c478bd9Sstevel@tonic-gate #define VOPNAME_SETFL "setfl" 725*7c478bd9Sstevel@tonic-gate #define VOPNAME_GETATTR "getattr" 726*7c478bd9Sstevel@tonic-gate #define VOPNAME_SETATTR "setattr" 727*7c478bd9Sstevel@tonic-gate #define VOPNAME_ACCESS "access" 728*7c478bd9Sstevel@tonic-gate #define VOPNAME_LOOKUP "lookup" 729*7c478bd9Sstevel@tonic-gate #define VOPNAME_CREATE "create" 730*7c478bd9Sstevel@tonic-gate #define VOPNAME_REMOVE "remove" 731*7c478bd9Sstevel@tonic-gate #define VOPNAME_LINK "link" 732*7c478bd9Sstevel@tonic-gate #define VOPNAME_RENAME "rename" 733*7c478bd9Sstevel@tonic-gate #define VOPNAME_MKDIR "mkdir" 734*7c478bd9Sstevel@tonic-gate #define VOPNAME_RMDIR "rmdir" 735*7c478bd9Sstevel@tonic-gate #define VOPNAME_READDIR "readdir" 736*7c478bd9Sstevel@tonic-gate #define VOPNAME_SYMLINK "symlink" 737*7c478bd9Sstevel@tonic-gate #define VOPNAME_READLINK "readlink" 738*7c478bd9Sstevel@tonic-gate #define VOPNAME_FSYNC "fsync" 739*7c478bd9Sstevel@tonic-gate #define VOPNAME_INACTIVE "inactive" 740*7c478bd9Sstevel@tonic-gate #define VOPNAME_FID "fid" 741*7c478bd9Sstevel@tonic-gate #define VOPNAME_RWLOCK "rwlock" 742*7c478bd9Sstevel@tonic-gate #define VOPNAME_RWUNLOCK "rwunlock" 743*7c478bd9Sstevel@tonic-gate #define VOPNAME_SEEK "seek" 744*7c478bd9Sstevel@tonic-gate #define VOPNAME_CMP "cmp" 745*7c478bd9Sstevel@tonic-gate #define VOPNAME_FRLOCK "frlock" 746*7c478bd9Sstevel@tonic-gate #define VOPNAME_SPACE "space" 747*7c478bd9Sstevel@tonic-gate #define VOPNAME_REALVP "realvp" 748*7c478bd9Sstevel@tonic-gate #define VOPNAME_GETPAGE "getpage" 749*7c478bd9Sstevel@tonic-gate #define VOPNAME_PUTPAGE "putpage" 750*7c478bd9Sstevel@tonic-gate #define VOPNAME_MAP "map" 751*7c478bd9Sstevel@tonic-gate #define VOPNAME_ADDMAP "addmap" 752*7c478bd9Sstevel@tonic-gate #define VOPNAME_DELMAP "delmap" 753*7c478bd9Sstevel@tonic-gate #define VOPNAME_POLL "poll" 754*7c478bd9Sstevel@tonic-gate #define VOPNAME_DUMP "dump" 755*7c478bd9Sstevel@tonic-gate #define VOPNAME_PATHCONF "pathconf" 756*7c478bd9Sstevel@tonic-gate #define VOPNAME_PAGEIO "pageio" 757*7c478bd9Sstevel@tonic-gate #define VOPNAME_DUMPCTL "dumpctl" 758*7c478bd9Sstevel@tonic-gate #define VOPNAME_DISPOSE "dispose" 759*7c478bd9Sstevel@tonic-gate #define VOPNAME_GETSECATTR "getsecattr" 760*7c478bd9Sstevel@tonic-gate #define VOPNAME_SETSECATTR "setsecattr" 761*7c478bd9Sstevel@tonic-gate #define VOPNAME_SHRLOCK "shrlock" 762*7c478bd9Sstevel@tonic-gate #define VOPNAME_VNEVENT "vnevent" 763*7c478bd9Sstevel@tonic-gate 764*7c478bd9Sstevel@tonic-gate /* 765*7c478bd9Sstevel@tonic-gate * Flags for VOP_LOOKUP 766*7c478bd9Sstevel@tonic-gate */ 767*7c478bd9Sstevel@tonic-gate #define LOOKUP_DIR 0x01 /* want parent dir vp */ 768*7c478bd9Sstevel@tonic-gate #define LOOKUP_XATTR 0x02 /* lookup up extended attr dir */ 769*7c478bd9Sstevel@tonic-gate #define CREATE_XATTR_DIR 0x04 /* Create extended attr dir */ 770*7c478bd9Sstevel@tonic-gate 771*7c478bd9Sstevel@tonic-gate /* 772*7c478bd9Sstevel@tonic-gate * Flags for VOP_RWLOCK/VOP_RWUNLOCK 773*7c478bd9Sstevel@tonic-gate * VOP_RWLOCK will return the flag that was actually set, or -1 if none. 774*7c478bd9Sstevel@tonic-gate */ 775*7c478bd9Sstevel@tonic-gate #define V_WRITELOCK_TRUE (1) /* Request write-lock on the vnode */ 776*7c478bd9Sstevel@tonic-gate #define V_WRITELOCK_FALSE (0) /* Request read-lock on the vnode */ 777*7c478bd9Sstevel@tonic-gate 778*7c478bd9Sstevel@tonic-gate /* 779*7c478bd9Sstevel@tonic-gate * Flags for VOP_DUMPCTL 780*7c478bd9Sstevel@tonic-gate */ 781*7c478bd9Sstevel@tonic-gate #define DUMP_ALLOC 0 782*7c478bd9Sstevel@tonic-gate #define DUMP_FREE 1 783*7c478bd9Sstevel@tonic-gate #define DUMP_SCAN 2 784*7c478bd9Sstevel@tonic-gate 785*7c478bd9Sstevel@tonic-gate /* 786*7c478bd9Sstevel@tonic-gate * Public vnode manipulation functions. 787*7c478bd9Sstevel@tonic-gate */ 788*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 789*7c478bd9Sstevel@tonic-gate 790*7c478bd9Sstevel@tonic-gate vnode_t *vn_alloc(int); 791*7c478bd9Sstevel@tonic-gate void vn_reinit(vnode_t *); 792*7c478bd9Sstevel@tonic-gate void vn_recycle(vnode_t *); 793*7c478bd9Sstevel@tonic-gate void vn_free(vnode_t *); 794*7c478bd9Sstevel@tonic-gate 795*7c478bd9Sstevel@tonic-gate int vn_is_readonly(vnode_t *); 796*7c478bd9Sstevel@tonic-gate int vn_is_opened(vnode_t *, v_mode_t); 797*7c478bd9Sstevel@tonic-gate int vn_is_mapped(vnode_t *, v_mode_t); 798*7c478bd9Sstevel@tonic-gate 799*7c478bd9Sstevel@tonic-gate int vn_can_change_zones(vnode_t *vp); 800*7c478bd9Sstevel@tonic-gate 801*7c478bd9Sstevel@tonic-gate int vn_has_flocks(vnode_t *); 802*7c478bd9Sstevel@tonic-gate int vn_has_mandatory_locks(vnode_t *, int); 803*7c478bd9Sstevel@tonic-gate int vn_has_cached_data(vnode_t *); 804*7c478bd9Sstevel@tonic-gate 805*7c478bd9Sstevel@tonic-gate void vn_setops(vnode_t *, vnodeops_t *); 806*7c478bd9Sstevel@tonic-gate vnodeops_t *vn_getops(vnode_t *); 807*7c478bd9Sstevel@tonic-gate int vn_matchops(vnode_t *, vnodeops_t *); 808*7c478bd9Sstevel@tonic-gate int vn_matchopval(vnode_t *, char *, fs_generic_func_p); 809*7c478bd9Sstevel@tonic-gate int vn_ismntpt(vnode_t *); 810*7c478bd9Sstevel@tonic-gate 811*7c478bd9Sstevel@tonic-gate struct vfs *vn_mountedvfs(vnode_t *); 812*7c478bd9Sstevel@tonic-gate 813*7c478bd9Sstevel@tonic-gate void vn_create_cache(void); 814*7c478bd9Sstevel@tonic-gate void vn_destroy_cache(void); 815*7c478bd9Sstevel@tonic-gate 816*7c478bd9Sstevel@tonic-gate int vn_make_ops(const char *, const fs_operation_def_t *, vnodeops_t **); 817*7c478bd9Sstevel@tonic-gate void vn_freevnodeops(vnodeops_t *); 818*7c478bd9Sstevel@tonic-gate 819*7c478bd9Sstevel@tonic-gate int vn_open(char *pnamep, enum uio_seg seg, int filemode, int createmode, 820*7c478bd9Sstevel@tonic-gate struct vnode **vpp, enum create crwhy, mode_t umask); 821*7c478bd9Sstevel@tonic-gate int vn_openat(char *pnamep, enum uio_seg seg, int filemode, int createmode, 822*7c478bd9Sstevel@tonic-gate struct vnode **vpp, enum create crwhy, 823*7c478bd9Sstevel@tonic-gate mode_t umask, struct vnode *startvp); 824*7c478bd9Sstevel@tonic-gate int vn_create(char *pnamep, enum uio_seg seg, struct vattr *vap, 825*7c478bd9Sstevel@tonic-gate enum vcexcl excl, int mode, struct vnode **vpp, 826*7c478bd9Sstevel@tonic-gate enum create why, int flag, mode_t umask); 827*7c478bd9Sstevel@tonic-gate int vn_createat(char *pnamep, enum uio_seg seg, struct vattr *vap, 828*7c478bd9Sstevel@tonic-gate enum vcexcl excl, int mode, struct vnode **vpp, 829*7c478bd9Sstevel@tonic-gate enum create why, int flag, mode_t umask, struct vnode *startvp); 830*7c478bd9Sstevel@tonic-gate int vn_rdwr(enum uio_rw rw, struct vnode *vp, caddr_t base, ssize_t len, 831*7c478bd9Sstevel@tonic-gate offset_t offset, enum uio_seg seg, int ioflag, rlim64_t ulimit, 832*7c478bd9Sstevel@tonic-gate cred_t *cr, ssize_t *residp); 833*7c478bd9Sstevel@tonic-gate void vn_rele(struct vnode *vp); 834*7c478bd9Sstevel@tonic-gate void vn_rele_stream(struct vnode *vp); 835*7c478bd9Sstevel@tonic-gate int vn_link(char *from, char *to, enum uio_seg seg); 836*7c478bd9Sstevel@tonic-gate int vn_rename(char *from, char *to, enum uio_seg seg); 837*7c478bd9Sstevel@tonic-gate int vn_renameat(vnode_t *fdvp, char *fname, vnode_t *tdvp, char *tname, 838*7c478bd9Sstevel@tonic-gate enum uio_seg seg); 839*7c478bd9Sstevel@tonic-gate int vn_remove(char *fnamep, enum uio_seg seg, enum rm dirflag); 840*7c478bd9Sstevel@tonic-gate int vn_removeat(vnode_t *startvp, char *fnamep, enum uio_seg seg, 841*7c478bd9Sstevel@tonic-gate enum rm dirflag); 842*7c478bd9Sstevel@tonic-gate int vn_compare(vnode_t *vp1, vnode_t *vp2); 843*7c478bd9Sstevel@tonic-gate int vn_vfslock(struct vnode *vp); 844*7c478bd9Sstevel@tonic-gate int vn_vfswlock(struct vnode *vp); 845*7c478bd9Sstevel@tonic-gate int vn_vfswlock_wait(struct vnode *vp); 846*7c478bd9Sstevel@tonic-gate int vn_vfsrlock(struct vnode *vp); 847*7c478bd9Sstevel@tonic-gate int vn_vfsrlock_wait(struct vnode *vp); 848*7c478bd9Sstevel@tonic-gate void vn_vfsunlock(struct vnode *vp); 849*7c478bd9Sstevel@tonic-gate int vn_vfswlock_held(struct vnode *vp); 850*7c478bd9Sstevel@tonic-gate vnode_t *specvp(struct vnode *vp, dev_t dev, vtype_t type, struct cred *cr); 851*7c478bd9Sstevel@tonic-gate vnode_t *makespecvp(dev_t dev, vtype_t type); 852*7c478bd9Sstevel@tonic-gate vn_vfslocks_entry_t *vn_vfslocks_getlock(void *); 853*7c478bd9Sstevel@tonic-gate void vn_vfslocks_rele(vn_vfslocks_entry_t *); 854*7c478bd9Sstevel@tonic-gate 855*7c478bd9Sstevel@tonic-gate /* Vnode event notification */ 856*7c478bd9Sstevel@tonic-gate void vnevent_rename_src(vnode_t *); 857*7c478bd9Sstevel@tonic-gate void vnevent_rename_dest(vnode_t *); 858*7c478bd9Sstevel@tonic-gate void vnevent_remove(vnode_t *); 859*7c478bd9Sstevel@tonic-gate void vnevent_rmdir(vnode_t *); 860*7c478bd9Sstevel@tonic-gate int vnevent_support(vnode_t *); 861*7c478bd9Sstevel@tonic-gate 862*7c478bd9Sstevel@tonic-gate /* Context identification */ 863*7c478bd9Sstevel@tonic-gate u_longlong_t fs_new_caller_id(); 864*7c478bd9Sstevel@tonic-gate 865*7c478bd9Sstevel@tonic-gate char *vn_path(struct vnode *vp); 866*7c478bd9Sstevel@tonic-gate void vn_setpath(struct vnode *rootvp, struct vnode *startvp, 867*7c478bd9Sstevel@tonic-gate struct vnode *vp, const char *path, size_t len); 868*7c478bd9Sstevel@tonic-gate void vn_setpath_str(struct vnode *vp, const char *str, size_t len); 869*7c478bd9Sstevel@tonic-gate 870*7c478bd9Sstevel@tonic-gate /* 871*7c478bd9Sstevel@tonic-gate * This macro should be used instead of calling vn_setpath() directly. It 872*7c478bd9Sstevel@tonic-gate * optimizes for the common case, where the vnode already has a path. 873*7c478bd9Sstevel@tonic-gate */ 874*7c478bd9Sstevel@tonic-gate #define VN_SETPATH(rvp, svp, vp, p, len) { \ 875*7c478bd9Sstevel@tonic-gate if (vn_path(vp) == NULL) \ 876*7c478bd9Sstevel@tonic-gate vn_setpath((rvp), (svp), (vp), (p), (len)); \ 877*7c478bd9Sstevel@tonic-gate } 878*7c478bd9Sstevel@tonic-gate 879*7c478bd9Sstevel@tonic-gate void vn_copypath(struct vnode *src, struct vnode *dst); 880*7c478bd9Sstevel@tonic-gate 881*7c478bd9Sstevel@tonic-gate int vn_vmpss_usepageio(vnode_t *); 882*7c478bd9Sstevel@tonic-gate 883*7c478bd9Sstevel@tonic-gate /* 884*7c478bd9Sstevel@tonic-gate * Needed for use of IS_VMODSORT() in kernel. 885*7c478bd9Sstevel@tonic-gate */ 886*7c478bd9Sstevel@tonic-gate extern uint_t pvn_vmodsort_supported; 887*7c478bd9Sstevel@tonic-gate 888*7c478bd9Sstevel@tonic-gate #define VN_HOLD(vp) { \ 889*7c478bd9Sstevel@tonic-gate mutex_enter(&(vp)->v_lock); \ 890*7c478bd9Sstevel@tonic-gate (vp)->v_count++; \ 891*7c478bd9Sstevel@tonic-gate mutex_exit(&(vp)->v_lock); \ 892*7c478bd9Sstevel@tonic-gate } 893*7c478bd9Sstevel@tonic-gate 894*7c478bd9Sstevel@tonic-gate #define VN_RELE(vp) { \ 895*7c478bd9Sstevel@tonic-gate vn_rele(vp); \ 896*7c478bd9Sstevel@tonic-gate } 897*7c478bd9Sstevel@tonic-gate 898*7c478bd9Sstevel@tonic-gate #define VN_SET_VFS_TYPE_DEV(vp, vfsp, type, dev) { \ 899*7c478bd9Sstevel@tonic-gate (vp)->v_vfsp = (vfsp); \ 900*7c478bd9Sstevel@tonic-gate (vp)->v_type = (type); \ 901*7c478bd9Sstevel@tonic-gate (vp)->v_rdev = (dev); \ 902*7c478bd9Sstevel@tonic-gate } 903*7c478bd9Sstevel@tonic-gate 904*7c478bd9Sstevel@tonic-gate /* 905*7c478bd9Sstevel@tonic-gate * Compare two vnodes for equality. In general this macro should be used 906*7c478bd9Sstevel@tonic-gate * in preference to calling VOP_CMP directly. 907*7c478bd9Sstevel@tonic-gate */ 908*7c478bd9Sstevel@tonic-gate #define VN_CMP(VP1, VP2) ((VP1) == (VP2) ? 1 : \ 909*7c478bd9Sstevel@tonic-gate ((VP1) && (VP2) && (vn_getops(VP1) == vn_getops(VP2)) ? \ 910*7c478bd9Sstevel@tonic-gate VOP_CMP(VP1, VP2) : 0)) 911*7c478bd9Sstevel@tonic-gate 912*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 913*7c478bd9Sstevel@tonic-gate 914*7c478bd9Sstevel@tonic-gate /* 915*7c478bd9Sstevel@tonic-gate * Flags to VOP_SETATTR/VOP_GETATTR. 916*7c478bd9Sstevel@tonic-gate */ 917*7c478bd9Sstevel@tonic-gate #define ATTR_UTIME 0x01 /* non-default utime(2) request */ 918*7c478bd9Sstevel@tonic-gate #define ATTR_EXEC 0x02 /* invocation from exec(2) */ 919*7c478bd9Sstevel@tonic-gate #define ATTR_COMM 0x04 /* yield common vp attributes */ 920*7c478bd9Sstevel@tonic-gate #define ATTR_HINT 0x08 /* information returned will be `hint' */ 921*7c478bd9Sstevel@tonic-gate #define ATTR_REAL 0x10 /* yield attributes of the real vp */ 922*7c478bd9Sstevel@tonic-gate 923*7c478bd9Sstevel@tonic-gate /* 924*7c478bd9Sstevel@tonic-gate * Generally useful macros. 925*7c478bd9Sstevel@tonic-gate */ 926*7c478bd9Sstevel@tonic-gate #define VBSIZE(vp) ((vp)->v_vfsp->vfs_bsize) 927*7c478bd9Sstevel@tonic-gate #define VTOZ(vp) ((vp)->v_vfsp->vfs_zone) 928*7c478bd9Sstevel@tonic-gate #define NULLVP ((struct vnode *)0) 929*7c478bd9Sstevel@tonic-gate #define NULLVPP ((struct vnode **)0) 930*7c478bd9Sstevel@tonic-gate 931*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 932*7c478bd9Sstevel@tonic-gate 933*7c478bd9Sstevel@tonic-gate /* 934*7c478bd9Sstevel@tonic-gate * Structure used while handling asynchronous VOP_PUTPAGE operations. 935*7c478bd9Sstevel@tonic-gate */ 936*7c478bd9Sstevel@tonic-gate struct async_reqs { 937*7c478bd9Sstevel@tonic-gate struct async_reqs *a_next; /* pointer to next arg struct */ 938*7c478bd9Sstevel@tonic-gate struct vnode *a_vp; /* vnode pointer */ 939*7c478bd9Sstevel@tonic-gate u_offset_t a_off; /* offset in file */ 940*7c478bd9Sstevel@tonic-gate uint_t a_len; /* size of i/o request */ 941*7c478bd9Sstevel@tonic-gate int a_flags; /* flags to indicate operation type */ 942*7c478bd9Sstevel@tonic-gate struct cred *a_cred; /* cred pointer */ 943*7c478bd9Sstevel@tonic-gate ushort_t a_prealloced; /* set if struct is pre-allocated */ 944*7c478bd9Sstevel@tonic-gate }; 945*7c478bd9Sstevel@tonic-gate 946*7c478bd9Sstevel@tonic-gate /* 947*7c478bd9Sstevel@tonic-gate * VN_DISPOSE() -- given a page pointer, safely invoke VOP_DISPOSE(). 948*7c478bd9Sstevel@tonic-gate */ 949*7c478bd9Sstevel@tonic-gate #define VN_DISPOSE(pp, flag, dn, cr) { \ 950*7c478bd9Sstevel@tonic-gate extern struct vnode kvp; \ 951*7c478bd9Sstevel@tonic-gate if ((pp)->p_vnode != NULL && (pp)->p_vnode != &kvp) \ 952*7c478bd9Sstevel@tonic-gate VOP_DISPOSE((pp)->p_vnode, (pp), (flag), (dn), (cr)); \ 953*7c478bd9Sstevel@tonic-gate else if ((flag) == B_FREE) \ 954*7c478bd9Sstevel@tonic-gate page_free((pp), (dn)); \ 955*7c478bd9Sstevel@tonic-gate else \ 956*7c478bd9Sstevel@tonic-gate page_destroy((pp), (dn)); \ 957*7c478bd9Sstevel@tonic-gate } 958*7c478bd9Sstevel@tonic-gate 959*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 960*7c478bd9Sstevel@tonic-gate 961*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 962*7c478bd9Sstevel@tonic-gate } 963*7c478bd9Sstevel@tonic-gate #endif 964*7c478bd9Sstevel@tonic-gate 965*7c478bd9Sstevel@tonic-gate #endif /* _SYS_VNODE_H */ 966