vnode.h revision 50137
1311116Sdim/* 2311116Sdim * Copyright (c) 1989, 1993 3311116Sdim * The Regents of the University of California. All rights reserved. 4311116Sdim * 5311116Sdim * Redistribution and use in source and binary forms, with or without 6311116Sdim * modification, are permitted provided that the following conditions 7311116Sdim * are met: 8311116Sdim * 1. Redistributions of source code must retain the above copyright 9311116Sdim * notice, this list of conditions and the following disclaimer. 10311116Sdim * 2. Redistributions in binary form must reproduce the above copyright 11311116Sdim * notice, this list of conditions and the following disclaimer in the 12311116Sdim * documentation and/or other materials provided with the distribution. 13311116Sdim * 3. All advertising materials mentioning features or use of this software 14311116Sdim * must display the following acknowledgement: 15321369Sdim * This product includes software developed by the University of 16321369Sdim * California, Berkeley and its contributors. 17321369Sdim * 4. Neither the name of the University nor the names of its contributors 18321369Sdim * may be used to endorse or promote products derived from this software 19321369Sdim * without specific prior written permission. 20327952Sdim * 21311116Sdim * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22311116Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23311116Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24311116Sdim * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25311116Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26311116Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27327952Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28327952Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29327952Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30327952Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31327952Sdim * SUCH DAMAGE. 32327952Sdim * 33327952Sdim * @(#)vnode.h 8.7 (Berkeley) 2/4/94 34327952Sdim * $Id: vnode.h,v 1.94 1999/08/13 10:10:11 phk Exp $ 35327952Sdim */ 36327952Sdim 37327952Sdim#ifndef _SYS_VNODE_H_ 38327952Sdim#define _SYS_VNODE_H_ 39327952Sdim 40327952Sdim#include <sys/queue.h> 41327952Sdim#include <sys/select.h> 42327952Sdim#include <sys/uio.h> 43327952Sdim 44327952Sdim#include <machine/lock.h> 45327952Sdim 46311116Sdim/* 47327952Sdim * The vnode is the focus of all file activity in UNIX. There is a 48327952Sdim * unique vnode allocated for each active file, each current directory, 49327952Sdim * each mounted-on file, text file, and the root. 50327952Sdim */ 51327952Sdim 52327952Sdim/* 53327952Sdim * Vnode types. VNON means no type. 54327952Sdim */ 55327952Sdimenum vtype { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VBAD }; 56327952Sdim 57327952Sdim/* 58327952Sdim * Vnode tag types. 59327952Sdim * These are for the benefit of external programs only (e.g., pstat) 60327952Sdim * and should NEVER be inspected by the kernel. 61327952Sdim */ 62327952Sdimenum vtagtype { 63327952Sdim VT_NON, VT_UFS, VT_NFS, VT_MFS, VT_PC, VT_LFS, VT_LOFS, VT_FDESC, 64327952Sdim VT_PORTAL, VT_NULL, VT_UMAP, VT_KERNFS, VT_PROCFS, VT_AFS, VT_ISOFS, 65327952Sdim VT_UNION, VT_MSDOSFS, VT_DEVFS, VT_TFS, VT_VFS, VT_CODA, VT_NTFS 66327952Sdim}; 67327952Sdim 68327952Sdim/* 69327952Sdim * Each underlying filesystem allocates its own private area and hangs 70327952Sdim * it from v_data. If non-null, this area is freed in getnewvnode(). 71327952Sdim */ 72327952SdimTAILQ_HEAD(buflists, buf); 73327952Sdim 74327952Sdimtypedef int vop_t __P((void *)); 75321369Sdimstruct namecache; 76321369Sdim 77321369Sdim/* 78321369Sdim * Reading or writing any of these items requires holding the appropriate lock. 79321369Sdim * v_freelist is locked by the global vnode_free_list simple lock. 80311116Sdim * v_mntvnodes is locked by the global mntvnodes simple lock. 81311116Sdim * v_flag, v_usecount, v_holdcount and v_writecount are 82311116Sdim * locked by the v_interlock simple lock. 83311116Sdim * v_pollinfo is locked by the lock contained inside it. 84321369Sdim */ 85311116Sdimstruct vnode { 86311116Sdim u_long v_flag; /* vnode flags (see below) */ 87311116Sdim int v_usecount; /* reference count of users */ 88321369Sdim int v_writecount; /* reference count of writers */ 89311116Sdim int v_holdcnt; /* page & buffer references */ 90327952Sdim daddr_t v_lastr; /* last read (read-ahead) */ 91311116Sdim u_long v_id; /* capability identifier */ 92311116Sdim struct mount *v_mount; /* ptr to vfs we are in */ 93321369Sdim vop_t **v_op; /* vnode operations vector */ 94321369Sdim TAILQ_ENTRY(vnode) v_freelist; /* vnode freelist */ 95321369Sdim LIST_ENTRY(vnode) v_mntvnodes; /* vnodes for mount point */ 96321369Sdim struct buflists v_cleanblkhd; /* clean blocklist head */ 97321369Sdim struct buflists v_dirtyblkhd; /* dirty blocklist head */ 98311116Sdim LIST_ENTRY(vnode) v_synclist; /* vnodes with dirty buffers */ 99321369Sdim long v_numoutput; /* num of writes in progress */ 100327952Sdim enum vtype v_type; /* vnode type */ 101327952Sdim union { 102327952Sdim struct mount *vu_mountedhere;/* ptr to mounted vfs (VDIR) */ 103321369Sdim struct socket *vu_socket; /* unix ipc (VSOCK) */ 104321369Sdim struct { 105311116Sdim struct specinfo *vu_specinfo; /* device (VCHR, VBLK) */ 106321369Sdim struct vnode *vu_specnext; 107327952Sdim } vu_spec; 108327952Sdim struct fifoinfo *vu_fifoinfo; /* fifo (VFIFO) */ 109321369Sdim } v_un; 110321369Sdim struct nqlease *v_lease; /* Soft reference to lease */ 111321369Sdim daddr_t v_lastw; /* last write (write cluster) */ 112321369Sdim daddr_t v_cstart; /* start block of cluster */ 113321369Sdim daddr_t v_lasta; /* last allocation */ 114321369Sdim int v_clen; /* length of current cluster */ 115321369Sdim int v_maxio; /* maximum I/O cluster size */ 116327952Sdim struct vm_object *v_object; /* Place to store VM object */ 117321369Sdim struct simplelock v_interlock; /* lock on usecount and flag */ 118321369Sdim struct lock *v_vnlock; /* used for non-locking fs's */ 119321369Sdim enum vtagtype v_tag; /* type of underlying data */ 120321369Sdim void *v_data; /* private data for fs */ 121321369Sdim LIST_HEAD(, namecache) v_cache_src; /* Cache entries from us */ 122321369Sdim TAILQ_HEAD(, namecache) v_cache_dst; /* Cache entries to us */ 123321369Sdim struct vnode *v_dd; /* .. vnode */ 124321369Sdim u_long v_ddid; /* .. capability identifier */ 125327952Sdim struct { 126321369Sdim struct simplelock vpi_lock; /* lock to protect below */ 127321369Sdim struct selinfo vpi_selinfo; /* identity of poller(s) */ 128321369Sdim short vpi_events; /* what they are looking for */ 129327952Sdim short vpi_revents; /* what has happened */ 130327952Sdim } v_pollinfo; 131327952Sdim#ifdef DEBUG_LOCKS 132327952Sdim const char *filename; /* Source file doing locking */ 133327952Sdim int line; /* Line number doing locking */ 134327952Sdim#endif 135327952Sdim}; 136327952Sdim#define v_mountedhere v_un.vu_mountedhere 137327952Sdim#define v_socket v_un.vu_socket 138321369Sdim#define v_rdev v_un.vu_spec.vu_specinfo 139321369Sdim#define v_specnext v_un.vu_spec.vu_specnext 140321369Sdim#define v_fifoinfo v_un.vu_fifoinfo 141321369Sdim 142321369Sdim#define VN_POLLEVENT(vp, events) \ 143321369Sdim do { \ 144321369Sdim if ((vp)->v_pollinfo.vpi_events & (events)) \ 145321369Sdim vn_pollevent((vp), (events)); \ 146321369Sdim } while (0) 147321369Sdim 148327952Sdim/* 149327952Sdim * Vnode flags. 150321369Sdim */ 151321369Sdim#define VROOT 0x00001 /* root of its file system */ 152327952Sdim#define VTEXT 0x00002 /* vnode is a pure text prototype */ 153327952Sdim#define VSYSTEM 0x00004 /* vnode being used by kernel */ 154321369Sdim#define VISTTY 0x00008 /* vnode represents a tty */ 155321369Sdim#define VXLOCK 0x00100 /* vnode is locked to change underlying type */ 156321369Sdim#define VXWANT 0x00200 /* process is waiting for vnode */ 157321369Sdim#define VBWAIT 0x00400 /* waiting for output to complete */ 158327952Sdim#define VALIASED 0x00800 /* vnode has an alias */ 159327952Sdim#define VDIROP 0x01000 /* LFS: vnode is involved in a directory op */ 160327952Sdim#define VOBJBUF 0x02000 /* Allocate buffers in VM object */ 161321369Sdim#define VNINACT 0x04000 /* LFS: skip ufs_inactive() in lfs_vunref */ 162321369Sdim#define VAGE 0x08000 /* Insert vnode at head of free list */ 163321369Sdim#define VOLOCK 0x10000 /* vnode is locked waiting for an object */ 164321369Sdim#define VOWANT 0x20000 /* a process is waiting for VOLOCK */ 165321369Sdim#define VDOOMED 0x40000 /* This vnode is being recycled */ 166321369Sdim#define VFREE 0x80000 /* This vnode is on the freelist */ 167321369Sdim#define VTBFREE 0x100000 /* This vnode is on the to-be-freelist */ 168327952Sdim#define VONWORKLST 0x200000 /* On syncer work-list */ 169327952Sdim#define VMOUNT 0x400000 /* Mount in progress */ 170327952Sdim 171327952Sdim/* 172327952Sdim * Vnode attributes. A field value of VNOVAL represents a field whose value 173321369Sdim * is unavailable (getattr) or which is not to be changed (setattr). 174327952Sdim */ 175327952Sdimstruct vattr { 176327952Sdim enum vtype va_type; /* vnode type (for create) */ 177321369Sdim u_short va_mode; /* files access mode and type */ 178321369Sdim short va_nlink; /* number of references to file */ 179321369Sdim uid_t va_uid; /* owner user id */ 180321369Sdim gid_t va_gid; /* owner group id */ 181321369Sdim udev_t va_fsid; /* file system id */ 182321369Sdim long va_fileid; /* file id */ 183321369Sdim u_quad_t va_size; /* file size in bytes */ 184321369Sdim long va_blocksize; /* blocksize preferred for i/o */ 185321369Sdim struct timespec va_atime; /* time of last access */ 186321369Sdim struct timespec va_mtime; /* time of last modification */ 187321369Sdim struct timespec va_ctime; /* time file changed */ 188321369Sdim u_long va_gen; /* generation number of file */ 189321369Sdim u_long va_flags; /* flags defined for file */ 190321369Sdim udev_t va_rdev; /* device the special file represents */ 191321369Sdim u_quad_t va_bytes; /* bytes of disk space held by file */ 192311116Sdim u_quad_t va_filerev; /* file modification number */ 193311116Sdim u_int va_vaflags; /* operations flags, see below */ 194321369Sdim long va_spare; /* remain quad aligned */ 195321369Sdim}; 196321369Sdim 197321369Sdim/* 198321369Sdim * Flags for va_vaflags. 199321369Sdim */ 200321369Sdim#define VA_UTIMES_NULL 0x01 /* utimes argument was NULL */ 201321369Sdim#define VA_EXCLUSIVE 0x02 /* exclusive create request */ 202321369Sdim 203321369Sdim/* 204321369Sdim * Flags for ioflag. 205321369Sdim */ 206321369Sdim#define IO_UNIT 0x01 /* do I/O as atomic unit */ 207321369Sdim#define IO_APPEND 0x02 /* append write to end */ 208321369Sdim#define IO_SYNC 0x04 /* do I/O synchronously */ 209321369Sdim#define IO_NODELOCKED 0x08 /* underlying node already locked */ 210321369Sdim#define IO_NDELAY 0x10 /* FNDELAY flag set in file table */ 211321369Sdim#define IO_VMIO 0x20 /* data already in VMIO space */ 212321369Sdim#define IO_INVAL 0x40 /* invalidate after I/O */ 213321369Sdim 214321369Sdim/* 215321369Sdim * Modes. Some values same as Ixxx entries from inode.h for now. 216321369Sdim */ 217321369Sdim#define VSUID 04000 /* set user id on execution */ 218321369Sdim#define VSGID 02000 /* set group id on execution */ 219321369Sdim#define VSVTX 01000 /* save swapped text even after use */ 220321369Sdim#define VREAD 00400 /* read, write, execute permissions */ 221321369Sdim#define VWRITE 00200 222321369Sdim#define VEXEC 00100 223321369Sdim 224321369Sdim/* 225321369Sdim * Token indicating no attribute value yet assigned. 226321369Sdim */ 227321369Sdim#define VNOVAL (-1) 228321369Sdim 229321369Sdim#ifdef KERNEL 230321369Sdim 231321369Sdim#ifdef MALLOC_DECLARE 232321369SdimMALLOC_DECLARE(M_VNODE); 233321369Sdim#endif 234321369Sdim 235321369Sdim/* 236321369Sdim * Convert between vnode types and inode formats (since POSIX.1 237321369Sdim * defines mode word of stat structure in terms of inode formats). 238321369Sdim */ 239321369Sdimextern enum vtype iftovt_tab[]; 240321369Sdimextern int vttoif_tab[]; 241321369Sdim#define IFTOVT(mode) (iftovt_tab[((mode) & S_IFMT) >> 12]) 242321369Sdim#define VTTOIF(indx) (vttoif_tab[(int)(indx)]) 243321369Sdim#define MAKEIMODE(indx, mode) (int)(VTTOIF(indx) | (mode)) 244321369Sdim 245321369Sdim/* 246321369Sdim * Flags to various vnode functions. 247321369Sdim */ 248321369Sdim#define SKIPSYSTEM 0x0001 /* vflush: skip vnodes marked VSYSTEM */ 249321369Sdim#define FORCECLOSE 0x0002 /* vflush: force file closure */ 250321369Sdim#define WRITECLOSE 0x0004 /* vflush: only close writable files */ 251321369Sdim#define DOCLOSE 0x0008 /* vclean: close active files */ 252321369Sdim#define V_SAVE 0x0001 /* vinvalbuf: sync file first */ 253321369Sdim#define REVOKEALL 0x0001 /* vop_revoke: revoke all aliases */ 254321369Sdim 255321369Sdim#define VREF(vp) vref(vp) 256321369Sdim 257321369Sdim 258321369Sdim#ifdef DIAGNOSTIC 259321369Sdim#define VATTR_NULL(vap) vattr_null(vap) 260321369Sdim#else 261321369Sdim#define VATTR_NULL(vap) (*(vap) = va_null) /* initialize a vattr */ 262321369Sdim#endif /* DIAGNOSTIC */ 263321369Sdim 264321369Sdim#define NULLVP ((struct vnode *)NULL) 265321369Sdim 266321369Sdim#define VNODEOP_SET(f) \ 267321369Sdim C_SYSINIT(f##init, SI_SUB_VFS, SI_ORDER_SECOND, vfs_add_vnodeops, &f); \ 268321369Sdim C_SYSUNINIT(f##uninit, SI_SUB_VFS, SI_ORDER_SECOND, vfs_rm_vnodeops, &f); 269321369Sdim 270321369Sdim/* 271321369Sdim * Global vnode data. 272321369Sdim */ 273321369Sdimextern struct vnode *rootvnode; /* root (i.e. "/") vnode */ 274321369Sdimextern int desiredvnodes; /* number of vnodes desired */ 275321369Sdimextern time_t syncdelay; /* max time to delay syncing data */ 276321369Sdimextern time_t filedelay; /* time to delay syncing files */ 277321369Sdimextern time_t dirdelay; /* time to delay syncing directories */ 278321369Sdimextern time_t metadelay; /* time to delay syncing metadata */ 279321369Sdimextern struct vm_zone *namei_zone; 280321369Sdimextern int prtactive; /* nonzero to call vprint() */ 281321369Sdimextern struct vattr va_null; /* predefined null vattr structure */ 282321369Sdimextern int vfs_ioopt; 283321369Sdim 284321369Sdim/* 285321369Sdim * Macro/function to check for client cache inconsistency w.r.t. leasing. 286321369Sdim */ 287321369Sdim#define LEASE_READ 0x1 /* Check lease for readers */ 288321369Sdim#define LEASE_WRITE 0x2 /* Check lease for modifiers */ 289321369Sdim 290321369Sdim 291321369Sdimextern void (*lease_updatetime) __P((int deltat)); 292321369Sdim 293321369Sdim#define VSHOULDFREE(vp) \ 294321369Sdim (!((vp)->v_flag & (VFREE|VDOOMED)) && \ 295321369Sdim !(vp)->v_holdcnt && !(vp)->v_usecount && \ 296321369Sdim (!(vp)->v_object || \ 297321369Sdim !((vp)->v_object->ref_count || (vp)->v_object->resident_page_count))) 298321369Sdim 299321369Sdim#define VSHOULDBUSY(vp) \ 300321369Sdim (((vp)->v_flag & (VFREE|VTBFREE)) && \ 301321369Sdim ((vp)->v_holdcnt || (vp)->v_usecount)) 302321369Sdim 303321369Sdim#endif /* KERNEL */ 304321369Sdim 305321369Sdim 306321369Sdim/* 307321369Sdim * Mods for extensibility. 308321369Sdim */ 309321369Sdim 310321369Sdim/* 311321369Sdim * Flags for vdesc_flags: 312321369Sdim */ 313321369Sdim#define VDESC_MAX_VPS 16 314321369Sdim/* Low order 16 flag bits are reserved for willrele flags for vp arguments. */ 315321369Sdim#define VDESC_VP0_WILLRELE 0x0001 316321369Sdim#define VDESC_VP1_WILLRELE 0x0002 317321369Sdim#define VDESC_VP2_WILLRELE 0x0004 318321369Sdim#define VDESC_VP3_WILLRELE 0x0008 319321369Sdim#define VDESC_NOMAP_VPP 0x0100 320321369Sdim#define VDESC_VPP_WILLRELE 0x0200 321321369Sdim 322321369Sdim/* 323321369Sdim * VDESC_NO_OFFSET is used to identify the end of the offset list 324327952Sdim * and in places where no such field exists. 325321369Sdim */ 326321369Sdim#define VDESC_NO_OFFSET -1 327321369Sdim 328321369Sdim/* 329321369Sdim * This structure describes the vnode operation taking place. 330321369Sdim */ 331321369Sdimstruct vnodeop_desc { 332321369Sdim int vdesc_offset; /* offset in vector--first for speed */ 333321369Sdim char *vdesc_name; /* a readable name for debugging */ 334321369Sdim int vdesc_flags; /* VDESC_* flags */ 335321369Sdim 336321369Sdim /* 337321369Sdim * These ops are used by bypass routines to map and locate arguments. 338321369Sdim * Creds and procs are not needed in bypass routines, but sometimes 339321369Sdim * they are useful to (for example) transport layers. 340321369Sdim * Nameidata is useful because it has a cred in it. 341321369Sdim */ 342321369Sdim int *vdesc_vp_offsets; /* list ended by VDESC_NO_OFFSET */ 343321369Sdim int vdesc_vpp_offset; /* return vpp location */ 344321369Sdim int vdesc_cred_offset; /* cred location, if any */ 345321369Sdim int vdesc_proc_offset; /* proc location, if any */ 346321369Sdim int vdesc_componentname_offset; /* if any */ 347321369Sdim /* 348321369Sdim * Finally, we've got a list of private data (about each operation) 349321369Sdim * for each transport layer. (Support to manage this list is not 350321369Sdim * yet part of BSD.) 351321369Sdim */ 352321369Sdim caddr_t *vdesc_transports; 353321369Sdim}; 354321369Sdim 355321369Sdim#ifdef KERNEL 356321369Sdim/* 357321369Sdim * A list of all the operation descs. 358321369Sdim */ 359321369Sdimextern struct vnodeop_desc *vnodeop_descs[]; 360321369Sdim 361321369Sdim/* 362321369Sdim * Interlock for scanning list of vnodes attached to a mountpoint 363321369Sdim */ 364321369Sdimextern struct simplelock mntvnode_slock; 365327952Sdim 366321369Sdim/* 367321369Sdim * This macro is very helpful in defining those offsets in the vdesc struct. 368321369Sdim * 369321369Sdim * This is stolen from X11R4. I ignored all the fancy stuff for 370321369Sdim * Crays, so if you decide to port this to such a serious machine, 371321369Sdim * you might want to consult Intrinsic.h's XtOffset{,Of,To}. 372321369Sdim */ 373321369Sdim#define VOPARG_OFFSET(p_type,field) \ 374321369Sdim ((int) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL))) 375321369Sdim#define VOPARG_OFFSETOF(s_type,field) \ 376321369Sdim VOPARG_OFFSET(s_type*,field) 377321369Sdim#define VOPARG_OFFSETTO(S_TYPE,S_OFFSET,STRUCT_P) \ 378321369Sdim ((S_TYPE)(((char*)(STRUCT_P))+(S_OFFSET))) 379321369Sdim 380321369Sdim 381321369Sdim/* 382321369Sdim * This structure is used to configure the new vnodeops vector. 383321369Sdim */ 384321369Sdimstruct vnodeopv_entry_desc { 385321369Sdim struct vnodeop_desc *opve_op; /* which operation this is */ 386321369Sdim vop_t *opve_impl; /* code implementing this operation */ 387321369Sdim}; 388321369Sdimstruct vnodeopv_desc { 389321369Sdim /* ptr to the ptr to the vector where op should go */ 390321369Sdim vop_t ***opv_desc_vector_p; 391321369Sdim struct vnodeopv_entry_desc *opv_desc_ops; /* null terminated list */ 392321369Sdim}; 393321369Sdim 394321369Sdim/* 395321369Sdim * A generic structure. 396321369Sdim * This can be used by bypass routines to identify generic arguments. 397321369Sdim */ 398321369Sdimstruct vop_generic_args { 399321369Sdim struct vnodeop_desc *a_desc; 400321369Sdim /* other random data follows, presumably */ 401321369Sdim}; 402321369Sdim 403321369Sdim 404321369Sdim#ifdef DEBUG_VFS_LOCKS 405321369Sdim/* 406321369Sdim * Macros to aid in tracing VFS locking problems. Not totally 407321369Sdim * reliable since if the process sleeps between changing the lock 408321369Sdim * state and checking it with the assert, some other process could 409321369Sdim * change the state. They are good enough for debugging a single 410321369Sdim * filesystem using a single-threaded test. I find that 'cvs co src' 411321369Sdim * is a pretty good test. 412321369Sdim */ 413321369Sdim 414321369Sdim/* 415 * [dfr] Kludge until I get around to fixing all the vfs locking. 416 */ 417#define IS_LOCKING_VFS(vp) ((vp)->v_tag == VT_UFS \ 418 || (vp)->v_tag == VT_MFS \ 419 || (vp)->v_tag == VT_NFS \ 420 || (vp)->v_tag == VT_LFS \ 421 || (vp)->v_tag == VT_ISOFS \ 422 || (vp)->v_tag == VT_MSDOSFS \ 423 || (vp)->v_tag == VT_DEVFS) 424 425#define ASSERT_VOP_LOCKED(vp, str) \ 426 if ((vp) && IS_LOCKING_VFS(vp) && !VOP_ISLOCKED(vp)) { \ 427 panic("%s: %p is not locked but should be", str, vp); \ 428 } 429 430#define ASSERT_VOP_UNLOCKED(vp, str) \ 431 if ((vp) && IS_LOCKING_VFS(vp) && VOP_ISLOCKED(vp)) { \ 432 panic("%s: %p is locked but shouldn't be", str, vp); \ 433 } 434 435#else 436 437#define ASSERT_VOP_LOCKED(vp, str) 438#define ASSERT_VOP_UNLOCKED(vp, str) 439 440#endif 441 442/* 443 * VOCALL calls an op given an ops vector. We break it out because BSD's 444 * vclean changes the ops vector and then wants to call ops with the old 445 * vector. 446 */ 447#define VOCALL(OPSV,OFF,AP) (( *((OPSV)[(OFF)])) (AP)) 448 449/* 450 * This call works for vnodes in the kernel. 451 */ 452#define VCALL(VP,OFF,AP) VOCALL((VP)->v_op,(OFF),(AP)) 453#define VDESC(OP) (& __CONCAT(OP,_desc)) 454#define VOFFSET(OP) (VDESC(OP)->vdesc_offset) 455 456/* 457 * VMIO support inline 458 */ 459 460extern int vmiodirenable; 461 462static __inline int 463vn_canvmio(struct vnode *vp) 464{ 465 if (vp && (vp->v_type == VREG || (vmiodirenable && vp->v_type == VDIR))) 466 return(TRUE); 467 return(FALSE); 468} 469 470/* 471 * Finally, include the default set of vnode operations. 472 */ 473#include "vnode_if.h" 474 475/* 476 * Public vnode manipulation functions. 477 */ 478struct componentname; 479struct file; 480struct mount; 481struct nameidata; 482struct ostat; 483struct proc; 484struct stat; 485struct nstat; 486struct ucred; 487struct uio; 488struct vattr; 489struct vnode; 490struct vop_bwrite_args; 491 492extern int (*lease_check_hook) __P((struct vop_lease_args *)); 493 494int bdevvp __P((dev_t dev, struct vnode **vpp)); 495/* cache_* may belong in namei.h. */ 496void cache_enter __P((struct vnode *dvp, struct vnode *vp, 497 struct componentname *cnp)); 498int cache_lookup __P((struct vnode *dvp, struct vnode **vpp, 499 struct componentname *cnp)); 500void cache_purge __P((struct vnode *vp)); 501void cache_purgevfs __P((struct mount *mp)); 502void cvtstat __P((struct stat *st, struct ostat *ost)); 503void cvtnstat __P((struct stat *sb, struct nstat *nsb)); 504int getnewvnode __P((enum vtagtype tag, 505 struct mount *mp, vop_t **vops, struct vnode **vpp)); 506int lease_check __P((struct vop_lease_args *ap)); 507int spec_vnoperate __P((struct vop_generic_args *)); 508int speedup_syncer __P((void)); 509void vattr_null __P((struct vattr *vap)); 510int vcount __P((struct vnode *vp)); 511void vdrop __P((struct vnode *)); 512int vfinddev __P((dev_t dev, enum vtype type, struct vnode **vpp)); 513void vfs_add_vnodeops __P((const void *)); 514void vfs_rm_vnodeops __P((const void *)); 515int vflush __P((struct mount *mp, struct vnode *skipvp, int flags)); 516int vget __P((struct vnode *vp, int lockflag, struct proc *p)); 517void vgone __P((struct vnode *vp)); 518void vhold __P((struct vnode *)); 519int vinvalbuf __P((struct vnode *vp, int save, struct ucred *cred, 520 521 struct proc *p, int slpflag, int slptimeo)); 522int vtruncbuf __P((struct vnode *vp, struct ucred *cred, struct proc *p, 523 off_t length, int blksize)); 524void vprint __P((char *label, struct vnode *vp)); 525int vrecycle __P((struct vnode *vp, struct simplelock *inter_lkp, 526 struct proc *p)); 527int vn_close __P((struct vnode *vp, 528 int flags, struct ucred *cred, struct proc *p)); 529int vn_lock __P((struct vnode *vp, int flags, struct proc *p)); 530#ifdef DEBUG_LOCKS 531int debug_vn_lock __P((struct vnode *vp, int flags, struct proc *p, 532 const char *filename, int line)); 533#define vn_lock(vp,flags,p) debug_vn_lock(vp,flags,p,__FILE__,__LINE__) 534#endif 535int vn_open __P((struct nameidata *ndp, int fmode, int cmode)); 536void vn_pollevent __P((struct vnode *vp, int events)); 537void vn_pollgone __P((struct vnode *vp)); 538int vn_pollrecord __P((struct vnode *vp, struct proc *p, int events)); 539int vn_rdwr __P((enum uio_rw rw, struct vnode *vp, caddr_t base, 540 int len, off_t offset, enum uio_seg segflg, int ioflg, 541 struct ucred *cred, int *aresid, struct proc *p)); 542int vn_stat __P((struct vnode *vp, struct stat *sb, struct proc *p)); 543dev_t vn_todev __P((struct vnode *vp)); 544int vfs_cache_lookup __P((struct vop_lookup_args *ap)); 545int vfs_object_create __P((struct vnode *vp, struct proc *p, 546 struct ucred *cred)); 547void vfs_timestamp __P((struct timespec *)); 548int vn_writechk __P((struct vnode *vp)); 549int vop_stdbwrite __P((struct vop_bwrite_args *ap)); 550int vop_stdislocked __P((struct vop_islocked_args *)); 551int vop_stdlock __P((struct vop_lock_args *)); 552int vop_stdunlock __P((struct vop_unlock_args *)); 553int vop_noislocked __P((struct vop_islocked_args *)); 554int vop_nolock __P((struct vop_lock_args *)); 555int vop_nopoll __P((struct vop_poll_args *)); 556int vop_nounlock __P((struct vop_unlock_args *)); 557int vop_stdpathconf __P((struct vop_pathconf_args *)); 558int vop_stdpoll __P((struct vop_poll_args *)); 559int vop_revoke __P((struct vop_revoke_args *)); 560int vop_sharedlock __P((struct vop_lock_args *)); 561int vop_eopnotsupp __P((struct vop_generic_args *ap)); 562int vop_ebadf __P((struct vop_generic_args *ap)); 563int vop_einval __P((struct vop_generic_args *ap)); 564int vop_enotty __P((struct vop_generic_args *ap)); 565int vop_defaultop __P((struct vop_generic_args *ap)); 566int vop_null __P((struct vop_generic_args *ap)); 567int vop_panic __P((struct vop_generic_args *ap)); 568 569struct vnode * 570 checkalias __P((struct vnode *vp, udev_t nvp_rdev, struct mount *mp)); 571void vput __P((struct vnode *vp)); 572void vrele __P((struct vnode *vp)); 573void vref __P((struct vnode *vp)); 574void vbusy __P((struct vnode *vp)); 575 576extern vop_t **default_vnodeop_p; 577extern vop_t **spec_vnodeop_p; 578 579extern TAILQ_HEAD(tobefreelist, vnode) 580 vnode_tobefree_list; /* vnode free list */ 581 582#endif /* KERNEL */ 583 584#endif /* !_SYS_VNODE_H_ */ 585