17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*5a59a8b3Srsb * Common Development and Distribution License (the "License"). 6*5a59a8b3Srsb * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*5a59a8b3Srsb * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 277c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate /* 307c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 317c478bd9Sstevel@tonic-gate * The Regents of the University of California 327c478bd9Sstevel@tonic-gate * All Rights Reserved 337c478bd9Sstevel@tonic-gate * 347c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 357c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 367c478bd9Sstevel@tonic-gate * contributors. 377c478bd9Sstevel@tonic-gate */ 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #ifndef _SYS_VNODE_H 407c478bd9Sstevel@tonic-gate #define _SYS_VNODE_H 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate #include <sys/types.h> 457c478bd9Sstevel@tonic-gate #include <sys/t_lock.h> 467c478bd9Sstevel@tonic-gate #include <sys/rwstlock.h> 477c478bd9Sstevel@tonic-gate #include <sys/time_impl.h> 487c478bd9Sstevel@tonic-gate #include <sys/cred.h> 497c478bd9Sstevel@tonic-gate #include <sys/uio.h> 507c478bd9Sstevel@tonic-gate #include <sys/resource.h> 517c478bd9Sstevel@tonic-gate #include <vm/seg_enum.h> 52*5a59a8b3Srsb #include <sys/kstat.h> 53*5a59a8b3Srsb #include <sys/kmem.h> 54*5a59a8b3Srsb #include <sys/avl.h> 557c478bd9Sstevel@tonic-gate #ifdef _KERNEL 567c478bd9Sstevel@tonic-gate #include <sys/buf.h> 577c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate #ifdef __cplusplus 607c478bd9Sstevel@tonic-gate extern "C" { 617c478bd9Sstevel@tonic-gate #endif 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate typedef int (*fs_generic_func_p) (); 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate /* 677c478bd9Sstevel@tonic-gate * File systems use arrays of fs_operation_def structures to form 687c478bd9Sstevel@tonic-gate * name/value pairs of operations. These arrays get passed to: 697c478bd9Sstevel@tonic-gate * 707c478bd9Sstevel@tonic-gate * - vn_make_ops() to create vnodeops 717c478bd9Sstevel@tonic-gate * - vfs_makefsops()/vfs_setfsops() to create vfsops. 727c478bd9Sstevel@tonic-gate */ 737c478bd9Sstevel@tonic-gate typedef struct fs_operation_def { 747c478bd9Sstevel@tonic-gate char *name; /* name of operation (NULL at end) */ 757c478bd9Sstevel@tonic-gate fs_generic_func_p func; /* function implementing operation */ 767c478bd9Sstevel@tonic-gate } fs_operation_def_t; 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate /* 797c478bd9Sstevel@tonic-gate * The operation registration mechanism uses two master tables of operations: 807c478bd9Sstevel@tonic-gate * one for vnode operations (vn_ops_table[]) and one for vfs operations 817c478bd9Sstevel@tonic-gate * (vfs_ops_table[]). These tables are arrays of fs_operation_trans_def 827c478bd9Sstevel@tonic-gate * structures. They contain all of the information necessary for the system 837c478bd9Sstevel@tonic-gate * to populate an operations structure (e.g., vnodeops, vfsops). 847c478bd9Sstevel@tonic-gate * 857c478bd9Sstevel@tonic-gate * File systems call registration routines (vfs_setfsops(), vfs_makefsops(), 867c478bd9Sstevel@tonic-gate * and vn_make_ops()) and pass in their operations specification tables 877c478bd9Sstevel@tonic-gate * (arrays of fs_operation_def structures). These routines use the master 887c478bd9Sstevel@tonic-gate * table(s) of operations to build a vnodeops or vfsops structure. 897c478bd9Sstevel@tonic-gate */ 907c478bd9Sstevel@tonic-gate typedef struct fs_operation_trans_def { 917c478bd9Sstevel@tonic-gate char *name; /* name of operation (NULL at end) */ 927c478bd9Sstevel@tonic-gate int offset; /* byte offset within ops vector */ 937c478bd9Sstevel@tonic-gate fs_generic_func_p defaultFunc; /* default function */ 947c478bd9Sstevel@tonic-gate fs_generic_func_p errorFunc; /* error function */ 957c478bd9Sstevel@tonic-gate } fs_operation_trans_def_t; 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate 98*5a59a8b3Srsb /* 99*5a59a8b3Srsb * Statistics for all vnode operations. 100*5a59a8b3Srsb * All operations record number of ops (since boot/mount/zero'ed). 101*5a59a8b3Srsb * Certain I/O operations (read, write, readdir) also record number 102*5a59a8b3Srsb * of bytes transferred. 103*5a59a8b3Srsb * This appears in two places in the system: one is embedded in each 104*5a59a8b3Srsb * vfs_t. There is also an array of vopstats_t structures allocated 105*5a59a8b3Srsb * on a per-fstype basis. 106*5a59a8b3Srsb */ 107*5a59a8b3Srsb 108*5a59a8b3Srsb #define VOPSTATS_STR "vopstats_" /* Initial string for vopstat kstats */ 109*5a59a8b3Srsb 110*5a59a8b3Srsb typedef struct vopstats { 111*5a59a8b3Srsb kstat_named_t nopen; /* VOP_OPEN */ 112*5a59a8b3Srsb kstat_named_t nclose; /* VOP_CLOSE */ 113*5a59a8b3Srsb kstat_named_t nread; /* VOP_READ */ 114*5a59a8b3Srsb kstat_named_t read_bytes; 115*5a59a8b3Srsb kstat_named_t nwrite; /* VOP_WRITE */ 116*5a59a8b3Srsb kstat_named_t write_bytes; 117*5a59a8b3Srsb kstat_named_t nioctl; /* VOP_IOCTL */ 118*5a59a8b3Srsb kstat_named_t nsetfl; /* VOP_SETFL */ 119*5a59a8b3Srsb kstat_named_t ngetattr; /* VOP_GETATTR */ 120*5a59a8b3Srsb kstat_named_t nsetattr; /* VOP_SETATTR */ 121*5a59a8b3Srsb kstat_named_t naccess; /* VOP_ACCESS */ 122*5a59a8b3Srsb kstat_named_t nlookup; /* VOP_LOOKUP */ 123*5a59a8b3Srsb kstat_named_t ncreate; /* VOP_CREATE */ 124*5a59a8b3Srsb kstat_named_t nremove; /* VOP_REMOVE */ 125*5a59a8b3Srsb kstat_named_t nlink; /* VOP_LINK */ 126*5a59a8b3Srsb kstat_named_t nrename; /* VOP_RENAME */ 127*5a59a8b3Srsb kstat_named_t nmkdir; /* VOP_MKDIR */ 128*5a59a8b3Srsb kstat_named_t nrmdir; /* VOP_RMDIR */ 129*5a59a8b3Srsb kstat_named_t nreaddir; /* VOP_READDIR */ 130*5a59a8b3Srsb kstat_named_t readdir_bytes; 131*5a59a8b3Srsb kstat_named_t nsymlink; /* VOP_SYMLINK */ 132*5a59a8b3Srsb kstat_named_t nreadlink; /* VOP_READLINK */ 133*5a59a8b3Srsb kstat_named_t nfsync; /* VOP_FSYNC */ 134*5a59a8b3Srsb kstat_named_t ninactive; /* VOP_INACTIVE */ 135*5a59a8b3Srsb kstat_named_t nfid; /* VOP_FID */ 136*5a59a8b3Srsb kstat_named_t nrwlock; /* VOP_RWLOCK */ 137*5a59a8b3Srsb kstat_named_t nrwunlock; /* VOP_RWUNLOCK */ 138*5a59a8b3Srsb kstat_named_t nseek; /* VOP_SEEK */ 139*5a59a8b3Srsb kstat_named_t ncmp; /* VOP_CMP */ 140*5a59a8b3Srsb kstat_named_t nfrlock; /* VOP_FRLOCK */ 141*5a59a8b3Srsb kstat_named_t nspace; /* VOP_SPACE */ 142*5a59a8b3Srsb kstat_named_t nrealvp; /* VOP_REALVP */ 143*5a59a8b3Srsb kstat_named_t ngetpage; /* VOP_GETPAGE */ 144*5a59a8b3Srsb kstat_named_t nputpage; /* VOP_PUTPAGE */ 145*5a59a8b3Srsb kstat_named_t nmap; /* VOP_MAP */ 146*5a59a8b3Srsb kstat_named_t naddmap; /* VOP_ADDMAP */ 147*5a59a8b3Srsb kstat_named_t ndelmap; /* VOP_DELMAP */ 148*5a59a8b3Srsb kstat_named_t npoll; /* VOP_POLL */ 149*5a59a8b3Srsb kstat_named_t ndump; /* VOP_DUMP */ 150*5a59a8b3Srsb kstat_named_t npathconf; /* VOP_PATHCONF */ 151*5a59a8b3Srsb kstat_named_t npageio; /* VOP_PAGEIO */ 152*5a59a8b3Srsb kstat_named_t ndumpctl; /* VOP_DUMPCTL */ 153*5a59a8b3Srsb kstat_named_t ndispose; /* VOP_DISPOSE */ 154*5a59a8b3Srsb kstat_named_t nsetsecattr; /* VOP_SETSECATTR */ 155*5a59a8b3Srsb kstat_named_t ngetsecattr; /* VOP_GETSECATTR */ 156*5a59a8b3Srsb kstat_named_t nshrlock; /* VOP_SHRLOCK */ 157*5a59a8b3Srsb kstat_named_t nvnevent; /* VOP_VNEVENT */ 158*5a59a8b3Srsb } vopstats_t; 159*5a59a8b3Srsb 1607c478bd9Sstevel@tonic-gate /* 1617c478bd9Sstevel@tonic-gate * The vnode is the focus of all file activity in UNIX. 1627c478bd9Sstevel@tonic-gate * A vnode is allocated for each active file, each current 1637c478bd9Sstevel@tonic-gate * directory, each mounted-on file, and the root. 1647c478bd9Sstevel@tonic-gate * 1657c478bd9Sstevel@tonic-gate * Each vnode is usually associated with a file-system-specific node (for 1667c478bd9Sstevel@tonic-gate * UFS, this is the in-memory inode). Generally, a vnode and an fs-node 1677c478bd9Sstevel@tonic-gate * should be created and destroyed together as a pair. 1687c478bd9Sstevel@tonic-gate * 1697c478bd9Sstevel@tonic-gate * If a vnode is reused for a new file, it should be reinitialized by calling 1707c478bd9Sstevel@tonic-gate * either vn_reinit() or vn_recycle(). 1717c478bd9Sstevel@tonic-gate * 1727c478bd9Sstevel@tonic-gate * vn_reinit() resets the entire vnode as if it was returned by vn_alloc(). 1737c478bd9Sstevel@tonic-gate * The caller is responsible for setting up the entire vnode after calling 1747c478bd9Sstevel@tonic-gate * vn_reinit(). This is important when using kmem caching where the vnode is 1757c478bd9Sstevel@tonic-gate * allocated by a constructor, for instance. 1767c478bd9Sstevel@tonic-gate * 1777c478bd9Sstevel@tonic-gate * vn_recycle() is used when the file system keeps some state around in both 1787c478bd9Sstevel@tonic-gate * the vnode and the associated FS-node. In UFS, for example, the inode of 1797c478bd9Sstevel@tonic-gate * a deleted file can be reused immediately. The v_data, v_vfsp, v_op, etc. 1807c478bd9Sstevel@tonic-gate * remains the same but certain fields related to the previous instance need 1817c478bd9Sstevel@tonic-gate * to be reset. In particular: 1827c478bd9Sstevel@tonic-gate * v_femhead 1837c478bd9Sstevel@tonic-gate * v_path 1847c478bd9Sstevel@tonic-gate * v_rdcnt, v_wrcnt 1857c478bd9Sstevel@tonic-gate * v_mmap_read, v_mmap_write 1867c478bd9Sstevel@tonic-gate */ 1877c478bd9Sstevel@tonic-gate 1887c478bd9Sstevel@tonic-gate /* 1897c478bd9Sstevel@tonic-gate * vnode types. VNON means no type. These values are unrelated to 1907c478bd9Sstevel@tonic-gate * values in on-disk inodes. 1917c478bd9Sstevel@tonic-gate */ 1927c478bd9Sstevel@tonic-gate typedef enum vtype { 1937c478bd9Sstevel@tonic-gate VNON = 0, 1947c478bd9Sstevel@tonic-gate VREG = 1, 1957c478bd9Sstevel@tonic-gate VDIR = 2, 1967c478bd9Sstevel@tonic-gate VBLK = 3, 1977c478bd9Sstevel@tonic-gate VCHR = 4, 1987c478bd9Sstevel@tonic-gate VLNK = 5, 1997c478bd9Sstevel@tonic-gate VFIFO = 6, 2007c478bd9Sstevel@tonic-gate VDOOR = 7, 2017c478bd9Sstevel@tonic-gate VPROC = 8, 2027c478bd9Sstevel@tonic-gate VSOCK = 9, 2037c478bd9Sstevel@tonic-gate VPORT = 10, 2047c478bd9Sstevel@tonic-gate VBAD = 11 2057c478bd9Sstevel@tonic-gate } vtype_t; 2067c478bd9Sstevel@tonic-gate 2077c478bd9Sstevel@tonic-gate /* 2087c478bd9Sstevel@tonic-gate * Many of the fields in the vnode are read-only once they are initialized 2097c478bd9Sstevel@tonic-gate * at vnode creation time. Other fields are protected by locks. 2107c478bd9Sstevel@tonic-gate * 2117c478bd9Sstevel@tonic-gate * IMPORTANT: vnodes should be created ONLY by calls to vn_alloc(). They 2127c478bd9Sstevel@tonic-gate * may not be embedded into the file-system specific node (inode). The 2137c478bd9Sstevel@tonic-gate * size of vnodes may change. 2147c478bd9Sstevel@tonic-gate * 2157c478bd9Sstevel@tonic-gate * The v_lock protects: 2167c478bd9Sstevel@tonic-gate * v_flag 2177c478bd9Sstevel@tonic-gate * v_stream 2187c478bd9Sstevel@tonic-gate * v_count 2197c478bd9Sstevel@tonic-gate * v_shrlocks 2207c478bd9Sstevel@tonic-gate * v_path 2217c478bd9Sstevel@tonic-gate * 2227c478bd9Sstevel@tonic-gate * A special lock (implemented by vn_vfswlock in vnode.c) protects: 2237c478bd9Sstevel@tonic-gate * v_vfsmountedhere 2247c478bd9Sstevel@tonic-gate * 2257c478bd9Sstevel@tonic-gate * The global flock_lock mutex (in flock.c) protects: 2267c478bd9Sstevel@tonic-gate * v_filocks 2277c478bd9Sstevel@tonic-gate * 2287c478bd9Sstevel@tonic-gate * IMPORTANT NOTE: 2297c478bd9Sstevel@tonic-gate * 2307c478bd9Sstevel@tonic-gate * The following vnode fields are considered public and may safely be 2317c478bd9Sstevel@tonic-gate * accessed by file systems or other consumers: 2327c478bd9Sstevel@tonic-gate * 2337c478bd9Sstevel@tonic-gate * v_lock 2347c478bd9Sstevel@tonic-gate * v_flag 2357c478bd9Sstevel@tonic-gate * v_count 2367c478bd9Sstevel@tonic-gate * v_data 2377c478bd9Sstevel@tonic-gate * v_vfsp 2387c478bd9Sstevel@tonic-gate * v_stream 2397c478bd9Sstevel@tonic-gate * v_type 2407c478bd9Sstevel@tonic-gate * v_rdev 2417c478bd9Sstevel@tonic-gate * 2427c478bd9Sstevel@tonic-gate * ALL OTHER FIELDS SHOULD BE ACCESSED ONLY BY THE OWNER OF THAT FIELD. 2437c478bd9Sstevel@tonic-gate * In particular, file systems should not access other fields; they may 2447c478bd9Sstevel@tonic-gate * change or even be removed. The functionality which was once provided 2457c478bd9Sstevel@tonic-gate * by these fields is available through vn_* functions. 2467c478bd9Sstevel@tonic-gate */ 2477c478bd9Sstevel@tonic-gate 2487c478bd9Sstevel@tonic-gate struct fem_head; /* from fem.h */ 2497c478bd9Sstevel@tonic-gate 2507c478bd9Sstevel@tonic-gate typedef struct vnode { 2517c478bd9Sstevel@tonic-gate kmutex_t v_lock; /* protects vnode fields */ 2527c478bd9Sstevel@tonic-gate uint_t v_flag; /* vnode flags (see below) */ 2537c478bd9Sstevel@tonic-gate uint_t v_count; /* reference count */ 2547c478bd9Sstevel@tonic-gate void *v_data; /* private data for fs */ 2557c478bd9Sstevel@tonic-gate struct vfs *v_vfsp; /* ptr to containing VFS */ 2567c478bd9Sstevel@tonic-gate struct stdata *v_stream; /* associated stream */ 2577c478bd9Sstevel@tonic-gate enum vtype v_type; /* vnode type */ 2587c478bd9Sstevel@tonic-gate dev_t v_rdev; /* device (VCHR, VBLK) */ 2597c478bd9Sstevel@tonic-gate 2607c478bd9Sstevel@tonic-gate /* PRIVATE FIELDS BELOW - DO NOT USE */ 2617c478bd9Sstevel@tonic-gate 2627c478bd9Sstevel@tonic-gate struct vfs *v_vfsmountedhere; /* ptr to vfs mounted here */ 2637c478bd9Sstevel@tonic-gate struct vnodeops *v_op; /* vnode operations */ 2647c478bd9Sstevel@tonic-gate struct page *v_pages; /* vnode pages list */ 2657c478bd9Sstevel@tonic-gate pgcnt_t v_npages; /* # pages on this vnode */ 2667c478bd9Sstevel@tonic-gate pgcnt_t v_msnpages; /* # pages charged to v_mset */ 2677c478bd9Sstevel@tonic-gate struct page *v_scanfront; /* scanner front hand */ 2687c478bd9Sstevel@tonic-gate struct page *v_scanback; /* scanner back hand */ 2697c478bd9Sstevel@tonic-gate struct filock *v_filocks; /* ptr to filock list */ 2707c478bd9Sstevel@tonic-gate struct shrlocklist *v_shrlocks; /* ptr to shrlock list */ 2717c478bd9Sstevel@tonic-gate krwlock_t v_nbllock; /* sync for NBMAND locks */ 2727c478bd9Sstevel@tonic-gate kcondvar_t v_cv; /* synchronize locking */ 2737c478bd9Sstevel@tonic-gate void *v_locality; /* hook for locality info */ 2747c478bd9Sstevel@tonic-gate struct fem_head *v_femhead; /* fs monitoring */ 2757c478bd9Sstevel@tonic-gate char *v_path; /* cached path */ 2767c478bd9Sstevel@tonic-gate uint_t v_rdcnt; /* open for read count (VREG only) */ 2777c478bd9Sstevel@tonic-gate uint_t v_wrcnt; /* open for write count (VREG only) */ 2787c478bd9Sstevel@tonic-gate u_longlong_t v_mmap_read; /* mmap read count */ 2797c478bd9Sstevel@tonic-gate u_longlong_t v_mmap_write; /* mmap write count */ 2807c478bd9Sstevel@tonic-gate void *v_mpssdata; /* info for large page mappings */ 2817c478bd9Sstevel@tonic-gate hrtime_t v_scantime; /* last time this vnode was scanned */ 2827c478bd9Sstevel@tonic-gate ushort_t v_mset; /* memory set ID */ 2837c478bd9Sstevel@tonic-gate uint_t v_msflags; /* memory set flags */ 2847c478bd9Sstevel@tonic-gate struct vnode *v_msnext; /* list of vnodes on an mset */ 2857c478bd9Sstevel@tonic-gate struct vnode *v_msprev; /* list of vnodes on an mset */ 2867c478bd9Sstevel@tonic-gate krwlock_t v_mslock; /* protects v_mset */ 2877c478bd9Sstevel@tonic-gate } vnode_t; 2887c478bd9Sstevel@tonic-gate 2897c478bd9Sstevel@tonic-gate #define IS_DEVVP(vp) \ 2907c478bd9Sstevel@tonic-gate ((vp)->v_type == VCHR || (vp)->v_type == VBLK || (vp)->v_type == VFIFO) 2917c478bd9Sstevel@tonic-gate 2927c478bd9Sstevel@tonic-gate /* 2937c478bd9Sstevel@tonic-gate * vnode flags. 2947c478bd9Sstevel@tonic-gate */ 2957c478bd9Sstevel@tonic-gate #define VROOT 0x01 /* root of its file system */ 2967c478bd9Sstevel@tonic-gate #define VNOCACHE 0x02 /* don't keep cache pages on vnode */ 2977c478bd9Sstevel@tonic-gate #define VNOMAP 0x04 /* file cannot be mapped/faulted */ 2987c478bd9Sstevel@tonic-gate #define VDUP 0x08 /* file should be dup'ed rather then opened */ 2997c478bd9Sstevel@tonic-gate #define VNOSWAP 0x10 /* file cannot be used as virtual swap device */ 3007c478bd9Sstevel@tonic-gate #define VNOMOUNT 0x20 /* file cannot be covered by mount */ 3017c478bd9Sstevel@tonic-gate #define VISSWAP 0x40 /* vnode is being used for swap */ 3027c478bd9Sstevel@tonic-gate #define VSWAPLIKE 0x80 /* vnode acts like swap (but may not be) */ 3037c478bd9Sstevel@tonic-gate 3047c478bd9Sstevel@tonic-gate #define IS_SWAPVP(vp) (((vp)->v_flag & (VISSWAP | VSWAPLIKE)) != 0) 3057c478bd9Sstevel@tonic-gate 3067c478bd9Sstevel@tonic-gate typedef struct vn_vfslocks_entry { 3077c478bd9Sstevel@tonic-gate rwstlock_t ve_lock; 3087c478bd9Sstevel@tonic-gate void *ve_vpvfs; 3097c478bd9Sstevel@tonic-gate struct vn_vfslocks_entry *ve_next; 3107c478bd9Sstevel@tonic-gate uint32_t ve_refcnt; 3117c478bd9Sstevel@tonic-gate char pad[64 - sizeof (rwstlock_t) - 2 * sizeof (void *) - \ 3127c478bd9Sstevel@tonic-gate sizeof (uint32_t)]; 3137c478bd9Sstevel@tonic-gate } vn_vfslocks_entry_t; 3147c478bd9Sstevel@tonic-gate 3157c478bd9Sstevel@tonic-gate /* 3167c478bd9Sstevel@tonic-gate * The following two flags are used to lock the v_vfsmountedhere field 3177c478bd9Sstevel@tonic-gate */ 3187c478bd9Sstevel@tonic-gate #define VVFSLOCK 0x100 3197c478bd9Sstevel@tonic-gate #define VVFSWAIT 0x200 3207c478bd9Sstevel@tonic-gate 3217c478bd9Sstevel@tonic-gate /* 3227c478bd9Sstevel@tonic-gate * Used to serialize VM operations on a vnode 3237c478bd9Sstevel@tonic-gate */ 3247c478bd9Sstevel@tonic-gate #define VVMLOCK 0x400 3257c478bd9Sstevel@tonic-gate 3267c478bd9Sstevel@tonic-gate /* 3277c478bd9Sstevel@tonic-gate * Tell vn_open() not to fail a directory open for writing but 3287c478bd9Sstevel@tonic-gate * to go ahead and call VOP_OPEN() to let the filesystem check. 3297c478bd9Sstevel@tonic-gate */ 3307c478bd9Sstevel@tonic-gate #define VDIROPEN 0x800 3317c478bd9Sstevel@tonic-gate 3327c478bd9Sstevel@tonic-gate /* 3337c478bd9Sstevel@tonic-gate * Flag to let the VM system know that this file is most likely a binary 3347c478bd9Sstevel@tonic-gate * or shared library since it has been mmap()ed EXEC at some time. 3357c478bd9Sstevel@tonic-gate */ 3367c478bd9Sstevel@tonic-gate #define VVMEXEC 0x1000 3377c478bd9Sstevel@tonic-gate 3387c478bd9Sstevel@tonic-gate #define VPXFS 0x2000 /* clustering: global fs proxy vnode */ 3397c478bd9Sstevel@tonic-gate 3407c478bd9Sstevel@tonic-gate #define IS_PXFSVP(vp) ((vp)->v_flag & VPXFS) 3417c478bd9Sstevel@tonic-gate 3427c478bd9Sstevel@tonic-gate #define V_XATTRDIR 0x4000 /* attribute unnamed directory */ 3437c478bd9Sstevel@tonic-gate 3447c478bd9Sstevel@tonic-gate #define V_LOCALITY 0x8000 /* whether locality aware */ 3457c478bd9Sstevel@tonic-gate 3467c478bd9Sstevel@tonic-gate /* 3477c478bd9Sstevel@tonic-gate * Flag that indicates the VM should maintain the v_pages list with all modified 3487c478bd9Sstevel@tonic-gate * pages on one end and unmodified pages at the other. This makes finding dirty 3497c478bd9Sstevel@tonic-gate * pages to write back to disk much faster at the expense of taking a minor 3507c478bd9Sstevel@tonic-gate * fault on the first store instruction which touches a writable page. 3517c478bd9Sstevel@tonic-gate */ 3527c478bd9Sstevel@tonic-gate #define VMODSORT (0x10000) 3537c478bd9Sstevel@tonic-gate #define IS_VMODSORT(vp) \ 3547c478bd9Sstevel@tonic-gate (pvn_vmodsort_supported != 0 && ((vp)->v_flag & VMODSORT) != 0) 3557c478bd9Sstevel@tonic-gate 3567c478bd9Sstevel@tonic-gate #define VISSWAPFS 0x20000 /* vnode is being used for swapfs */ 3577c478bd9Sstevel@tonic-gate #define IS_SWAPFSVP(vp) (((vp)->v_flag & VISSWAPFS) != 0) 3587c478bd9Sstevel@tonic-gate 3597c478bd9Sstevel@tonic-gate /* 3607c478bd9Sstevel@tonic-gate * Vnode attributes. A bit-mask is supplied as part of the 3617c478bd9Sstevel@tonic-gate * structure to indicate the attributes the caller wants to 3627c478bd9Sstevel@tonic-gate * set (setattr) or extract (getattr). 3637c478bd9Sstevel@tonic-gate */ 3647c478bd9Sstevel@tonic-gate 3657c478bd9Sstevel@tonic-gate /* 3667c478bd9Sstevel@tonic-gate * Note that va_nodeid and va_nblocks are 64bit data type. 3677c478bd9Sstevel@tonic-gate * We support large files over NFSV3. With Solaris client and 3687c478bd9Sstevel@tonic-gate * Server that generates 64bit ino's and sizes these fields 3697c478bd9Sstevel@tonic-gate * will overflow if they are 32 bit sizes. 3707c478bd9Sstevel@tonic-gate */ 3717c478bd9Sstevel@tonic-gate 3727c478bd9Sstevel@tonic-gate typedef struct vattr { 3737c478bd9Sstevel@tonic-gate uint_t va_mask; /* bit-mask of attributes */ 3747c478bd9Sstevel@tonic-gate vtype_t va_type; /* vnode type (for create) */ 3757c478bd9Sstevel@tonic-gate mode_t va_mode; /* file access mode */ 3767c478bd9Sstevel@tonic-gate uid_t va_uid; /* owner user id */ 3777c478bd9Sstevel@tonic-gate gid_t va_gid; /* owner group id */ 3787c478bd9Sstevel@tonic-gate dev_t va_fsid; /* file system id (dev for now) */ 3797c478bd9Sstevel@tonic-gate u_longlong_t va_nodeid; /* node id */ 3807c478bd9Sstevel@tonic-gate nlink_t va_nlink; /* number of references to file */ 3817c478bd9Sstevel@tonic-gate u_offset_t va_size; /* file size in bytes */ 3827c478bd9Sstevel@tonic-gate timestruc_t va_atime; /* time of last access */ 3837c478bd9Sstevel@tonic-gate timestruc_t va_mtime; /* time of last modification */ 3847c478bd9Sstevel@tonic-gate timestruc_t va_ctime; /* time of last status change */ 3857c478bd9Sstevel@tonic-gate dev_t va_rdev; /* device the file represents */ 3867c478bd9Sstevel@tonic-gate uint_t va_blksize; /* fundamental block size */ 3877c478bd9Sstevel@tonic-gate u_longlong_t va_nblocks; /* # of blocks allocated */ 3887c478bd9Sstevel@tonic-gate uint_t va_seq; /* sequence number */ 3897c478bd9Sstevel@tonic-gate } vattr_t; 3907c478bd9Sstevel@tonic-gate 3917c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32 3927c478bd9Sstevel@tonic-gate /* 3937c478bd9Sstevel@tonic-gate * For bigtypes time_t changed to 64 bit on the 64-bit kernel. 3947c478bd9Sstevel@tonic-gate * Define an old version for user/kernel interface 3957c478bd9Sstevel@tonic-gate */ 3967c478bd9Sstevel@tonic-gate 3977c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 3987c478bd9Sstevel@tonic-gate #pragma pack(4) 3997c478bd9Sstevel@tonic-gate #endif 4007c478bd9Sstevel@tonic-gate 4017c478bd9Sstevel@tonic-gate typedef struct vattr32 { 4027c478bd9Sstevel@tonic-gate uint32_t va_mask; /* bit-mask of attributes */ 4037c478bd9Sstevel@tonic-gate vtype_t va_type; /* vnode type (for create) */ 4047c478bd9Sstevel@tonic-gate mode32_t va_mode; /* file access mode */ 4057c478bd9Sstevel@tonic-gate uid32_t va_uid; /* owner user id */ 4067c478bd9Sstevel@tonic-gate gid32_t va_gid; /* owner group id */ 4077c478bd9Sstevel@tonic-gate dev32_t va_fsid; /* file system id (dev for now) */ 4087c478bd9Sstevel@tonic-gate u_longlong_t va_nodeid; /* node id */ 4097c478bd9Sstevel@tonic-gate nlink_t va_nlink; /* number of references to file */ 4107c478bd9Sstevel@tonic-gate u_offset_t va_size; /* file size in bytes */ 4117c478bd9Sstevel@tonic-gate timestruc32_t va_atime; /* time of last access */ 4127c478bd9Sstevel@tonic-gate timestruc32_t va_mtime; /* time of last modification */ 4137c478bd9Sstevel@tonic-gate timestruc32_t va_ctime; /* time of last status change */ 4147c478bd9Sstevel@tonic-gate dev32_t va_rdev; /* device the file represents */ 4157c478bd9Sstevel@tonic-gate uint32_t va_blksize; /* fundamental block size */ 4167c478bd9Sstevel@tonic-gate u_longlong_t va_nblocks; /* # of blocks allocated */ 4177c478bd9Sstevel@tonic-gate uint32_t va_seq; /* sequence number */ 4187c478bd9Sstevel@tonic-gate } vattr32_t; 4197c478bd9Sstevel@tonic-gate 4207c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 4217c478bd9Sstevel@tonic-gate #pragma pack() 4227c478bd9Sstevel@tonic-gate #endif 4237c478bd9Sstevel@tonic-gate 4247c478bd9Sstevel@tonic-gate #else /* not _SYSCALL32 */ 4257c478bd9Sstevel@tonic-gate #define vattr32 vattr 4267c478bd9Sstevel@tonic-gate typedef vattr_t vattr32_t; 4277c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 4287c478bd9Sstevel@tonic-gate 4297c478bd9Sstevel@tonic-gate /* 4307c478bd9Sstevel@tonic-gate * Attributes of interest to the caller of setattr or getattr. 4317c478bd9Sstevel@tonic-gate */ 4327c478bd9Sstevel@tonic-gate #define AT_TYPE 0x0001 4337c478bd9Sstevel@tonic-gate #define AT_MODE 0x0002 4347c478bd9Sstevel@tonic-gate #define AT_UID 0x0004 4357c478bd9Sstevel@tonic-gate #define AT_GID 0x0008 4367c478bd9Sstevel@tonic-gate #define AT_FSID 0x0010 4377c478bd9Sstevel@tonic-gate #define AT_NODEID 0x0020 4387c478bd9Sstevel@tonic-gate #define AT_NLINK 0x0040 4397c478bd9Sstevel@tonic-gate #define AT_SIZE 0x0080 4407c478bd9Sstevel@tonic-gate #define AT_ATIME 0x0100 4417c478bd9Sstevel@tonic-gate #define AT_MTIME 0x0200 4427c478bd9Sstevel@tonic-gate #define AT_CTIME 0x0400 4437c478bd9Sstevel@tonic-gate #define AT_RDEV 0x0800 4447c478bd9Sstevel@tonic-gate #define AT_BLKSIZE 0x1000 4457c478bd9Sstevel@tonic-gate #define AT_NBLOCKS 0x2000 4467c478bd9Sstevel@tonic-gate /* 0x4000 */ /* unused */ 4477c478bd9Sstevel@tonic-gate #define AT_SEQ 0x8000 4487c478bd9Sstevel@tonic-gate 4497c478bd9Sstevel@tonic-gate #define AT_ALL (AT_TYPE|AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|\ 4507c478bd9Sstevel@tonic-gate AT_NLINK|AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|\ 4517c478bd9Sstevel@tonic-gate AT_RDEV|AT_BLKSIZE|AT_NBLOCKS|AT_SEQ) 4527c478bd9Sstevel@tonic-gate 4537c478bd9Sstevel@tonic-gate #define AT_STAT (AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|AT_NLINK|\ 4547c478bd9Sstevel@tonic-gate AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|AT_RDEV|AT_TYPE) 4557c478bd9Sstevel@tonic-gate 4567c478bd9Sstevel@tonic-gate #define AT_TIMES (AT_ATIME|AT_MTIME|AT_CTIME) 4577c478bd9Sstevel@tonic-gate 4587c478bd9Sstevel@tonic-gate #define AT_NOSET (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\ 4597c478bd9Sstevel@tonic-gate AT_BLKSIZE|AT_NBLOCKS|AT_SEQ) 4607c478bd9Sstevel@tonic-gate 4617c478bd9Sstevel@tonic-gate /* 4627c478bd9Sstevel@tonic-gate * Modes. Some values same as S_xxx entries from stat.h for convenience. 4637c478bd9Sstevel@tonic-gate */ 4647c478bd9Sstevel@tonic-gate #define VSUID 04000 /* set user id on execution */ 4657c478bd9Sstevel@tonic-gate #define VSGID 02000 /* set group id on execution */ 4667c478bd9Sstevel@tonic-gate #define VSVTX 01000 /* save swapped text even after use */ 4677c478bd9Sstevel@tonic-gate 4687c478bd9Sstevel@tonic-gate /* 4697c478bd9Sstevel@tonic-gate * Permissions. 4707c478bd9Sstevel@tonic-gate */ 4717c478bd9Sstevel@tonic-gate #define VREAD 00400 4727c478bd9Sstevel@tonic-gate #define VWRITE 00200 4737c478bd9Sstevel@tonic-gate #define VEXEC 00100 4747c478bd9Sstevel@tonic-gate 4757c478bd9Sstevel@tonic-gate #define MODEMASK 07777 /* mode bits plus permission bits */ 4767c478bd9Sstevel@tonic-gate #define PERMMASK 00777 /* permission bits */ 4777c478bd9Sstevel@tonic-gate 4787c478bd9Sstevel@tonic-gate /* 4797c478bd9Sstevel@tonic-gate * Check whether mandatory file locking is enabled. 4807c478bd9Sstevel@tonic-gate */ 4817c478bd9Sstevel@tonic-gate 4827c478bd9Sstevel@tonic-gate #define MANDMODE(mode) (((mode) & (VSGID|(VEXEC>>3))) == VSGID) 4837c478bd9Sstevel@tonic-gate #define MANDLOCK(vp, mode) ((vp)->v_type == VREG && MANDMODE(mode)) 4847c478bd9Sstevel@tonic-gate 4857c478bd9Sstevel@tonic-gate /* 4867c478bd9Sstevel@tonic-gate * Flags for vnode operations. 4877c478bd9Sstevel@tonic-gate */ 4887c478bd9Sstevel@tonic-gate enum rm { RMFILE, RMDIRECTORY }; /* rm or rmdir (remove) */ 4897c478bd9Sstevel@tonic-gate enum symfollow { NO_FOLLOW, FOLLOW }; /* follow symlinks (or not) */ 4907c478bd9Sstevel@tonic-gate enum vcexcl { NONEXCL, EXCL }; /* (non)excl create */ 4917c478bd9Sstevel@tonic-gate enum create { CRCREAT, CRMKNOD, CRMKDIR }; /* reason for create */ 4927c478bd9Sstevel@tonic-gate 4937c478bd9Sstevel@tonic-gate typedef enum rm rm_t; 4947c478bd9Sstevel@tonic-gate typedef enum symfollow symfollow_t; 4957c478bd9Sstevel@tonic-gate typedef enum vcexcl vcexcl_t; 4967c478bd9Sstevel@tonic-gate typedef enum create create_t; 4977c478bd9Sstevel@tonic-gate 4987c478bd9Sstevel@tonic-gate /* Vnode Events - Used by VOP_VNEVENT */ 4997c478bd9Sstevel@tonic-gate typedef enum vnevent { 5007c478bd9Sstevel@tonic-gate VE_SUPPORT = 0, /* Query */ 5017c478bd9Sstevel@tonic-gate VE_RENAME_SRC = 1, /* Rename, with vnode as source */ 5027c478bd9Sstevel@tonic-gate VE_RENAME_DEST = 2, /* Rename, with vnode as target/destination */ 5037c478bd9Sstevel@tonic-gate VE_REMOVE = 3, /* Remove of vnode's name */ 5047c478bd9Sstevel@tonic-gate VE_RMDIR = 4 /* Remove of directory vnode's name */ 5057c478bd9Sstevel@tonic-gate } vnevent_t; 5067c478bd9Sstevel@tonic-gate 5077c478bd9Sstevel@tonic-gate /* 5087c478bd9Sstevel@tonic-gate * Values for checking vnode open and map counts 5097c478bd9Sstevel@tonic-gate */ 5107c478bd9Sstevel@tonic-gate enum v_mode { V_READ, V_WRITE, V_RDORWR, V_RDANDWR }; 5117c478bd9Sstevel@tonic-gate 5127c478bd9Sstevel@tonic-gate typedef enum v_mode v_mode_t; 5137c478bd9Sstevel@tonic-gate 5147c478bd9Sstevel@tonic-gate #define V_TRUE 1 5157c478bd9Sstevel@tonic-gate #define V_FALSE 0 5167c478bd9Sstevel@tonic-gate 5177c478bd9Sstevel@tonic-gate /* 5187c478bd9Sstevel@tonic-gate * Structure used on VOP_GETSECATTR and VOP_SETSECATTR operations 5197c478bd9Sstevel@tonic-gate */ 5207c478bd9Sstevel@tonic-gate 5217c478bd9Sstevel@tonic-gate typedef struct vsecattr { 5227c478bd9Sstevel@tonic-gate uint_t vsa_mask; /* See below */ 5237c478bd9Sstevel@tonic-gate int vsa_aclcnt; /* ACL entry count */ 5247c478bd9Sstevel@tonic-gate void *vsa_aclentp; /* pointer to ACL entries */ 5257c478bd9Sstevel@tonic-gate int vsa_dfaclcnt; /* default ACL entry count */ 5267c478bd9Sstevel@tonic-gate void *vsa_dfaclentp; /* pointer to default ACL entries */ 5277c478bd9Sstevel@tonic-gate } vsecattr_t; 5287c478bd9Sstevel@tonic-gate 5297c478bd9Sstevel@tonic-gate /* vsa_mask values */ 5307c478bd9Sstevel@tonic-gate #define VSA_ACL 0x0001 5317c478bd9Sstevel@tonic-gate #define VSA_ACLCNT 0x0002 5327c478bd9Sstevel@tonic-gate #define VSA_DFACL 0x0004 5337c478bd9Sstevel@tonic-gate #define VSA_DFACLCNT 0x0008 5347c478bd9Sstevel@tonic-gate #define VSA_ACE 0x0010 5357c478bd9Sstevel@tonic-gate #define VSA_ACECNT 0x0020 5367c478bd9Sstevel@tonic-gate 5377c478bd9Sstevel@tonic-gate /* 5387c478bd9Sstevel@tonic-gate * Structure used by various vnode operations to determine 5397c478bd9Sstevel@tonic-gate * the context (pid, host, identity) of a caller. 5407c478bd9Sstevel@tonic-gate * 5417c478bd9Sstevel@tonic-gate * The cc_caller_id is used to identify one or more callers who invoke 5427c478bd9Sstevel@tonic-gate * operations, possibly on behalf of others. For example, the NFS 5437c478bd9Sstevel@tonic-gate * server could have it's own cc_caller_id which can be detected by 5447c478bd9Sstevel@tonic-gate * vnode/vfs operations or (FEM) monitors on those operations. New 5457c478bd9Sstevel@tonic-gate * caller IDs are generated by fs_new_caller_id(). 5467c478bd9Sstevel@tonic-gate */ 5477c478bd9Sstevel@tonic-gate typedef struct caller_context { 5487c478bd9Sstevel@tonic-gate pid_t cc_pid; /* Process ID of the caller */ 5497c478bd9Sstevel@tonic-gate int cc_sysid; /* System ID, used for remote calls */ 5507c478bd9Sstevel@tonic-gate u_longlong_t cc_caller_id; /* Identifier for (set of) caller(s) */ 5517c478bd9Sstevel@tonic-gate } caller_context_t; 5527c478bd9Sstevel@tonic-gate 5537c478bd9Sstevel@tonic-gate /* 5547c478bd9Sstevel@tonic-gate * Structure tags for function prototypes, defined elsewhere. 5557c478bd9Sstevel@tonic-gate */ 5567c478bd9Sstevel@tonic-gate struct pathname; 5577c478bd9Sstevel@tonic-gate struct fid; 5587c478bd9Sstevel@tonic-gate struct flock64; 5597c478bd9Sstevel@tonic-gate struct flk_callback; 5607c478bd9Sstevel@tonic-gate struct shrlock; 5617c478bd9Sstevel@tonic-gate struct page; 5627c478bd9Sstevel@tonic-gate struct seg; 5637c478bd9Sstevel@tonic-gate struct as; 5647c478bd9Sstevel@tonic-gate struct pollhead; 5657c478bd9Sstevel@tonic-gate 5667c478bd9Sstevel@tonic-gate /* 5677c478bd9Sstevel@tonic-gate * Operations on vnodes. Note: File systems should never operate directly 5687c478bd9Sstevel@tonic-gate * on a 'vnodeops' structure -- it WILL change in future releases! They 5697c478bd9Sstevel@tonic-gate * should use vn_make_ops() to create the structure. 5707c478bd9Sstevel@tonic-gate */ 5717c478bd9Sstevel@tonic-gate typedef struct vnodeops { 5727c478bd9Sstevel@tonic-gate const char *vnop_name; 5737c478bd9Sstevel@tonic-gate int (*vop_open)(vnode_t **, int, cred_t *); 5747c478bd9Sstevel@tonic-gate int (*vop_close)(vnode_t *, int, int, offset_t, cred_t *); 5757c478bd9Sstevel@tonic-gate int (*vop_read)(vnode_t *, uio_t *, int, cred_t *, 5767c478bd9Sstevel@tonic-gate caller_context_t *); 5777c478bd9Sstevel@tonic-gate int (*vop_write)(vnode_t *, uio_t *, int, cred_t *, 5787c478bd9Sstevel@tonic-gate caller_context_t *); 5797c478bd9Sstevel@tonic-gate int (*vop_ioctl)(vnode_t *, int, intptr_t, int, cred_t *, int *); 5807c478bd9Sstevel@tonic-gate int (*vop_setfl)(vnode_t *, int, int, cred_t *); 5817c478bd9Sstevel@tonic-gate int (*vop_getattr)(vnode_t *, vattr_t *, int, cred_t *); 5827c478bd9Sstevel@tonic-gate int (*vop_setattr)(vnode_t *, vattr_t *, int, cred_t *, 5837c478bd9Sstevel@tonic-gate caller_context_t *); 5847c478bd9Sstevel@tonic-gate int (*vop_access)(vnode_t *, int, int, cred_t *); 5857c478bd9Sstevel@tonic-gate int (*vop_lookup)(vnode_t *, char *, vnode_t **, struct pathname *, 5867c478bd9Sstevel@tonic-gate int, vnode_t *, cred_t *); 5877c478bd9Sstevel@tonic-gate int (*vop_create)(vnode_t *, char *, vattr_t *, vcexcl_t, int, 5887c478bd9Sstevel@tonic-gate vnode_t **, cred_t *, int); 5897c478bd9Sstevel@tonic-gate int (*vop_remove)(vnode_t *, char *, cred_t *); 5907c478bd9Sstevel@tonic-gate int (*vop_link)(vnode_t *, vnode_t *, char *, cred_t *); 5917c478bd9Sstevel@tonic-gate int (*vop_rename)(vnode_t *, char *, vnode_t *, char *, cred_t *); 5927c478bd9Sstevel@tonic-gate int (*vop_mkdir)(vnode_t *, char *, vattr_t *, vnode_t **, 5937c478bd9Sstevel@tonic-gate cred_t *); 5947c478bd9Sstevel@tonic-gate int (*vop_rmdir)(vnode_t *, char *, vnode_t *, cred_t *); 5957c478bd9Sstevel@tonic-gate int (*vop_readdir)(vnode_t *, uio_t *, cred_t *, int *); 5967c478bd9Sstevel@tonic-gate int (*vop_symlink)(vnode_t *, char *, vattr_t *, char *, cred_t *); 5977c478bd9Sstevel@tonic-gate int (*vop_readlink)(vnode_t *, uio_t *, cred_t *); 5987c478bd9Sstevel@tonic-gate int (*vop_fsync)(vnode_t *, int, cred_t *); 5997c478bd9Sstevel@tonic-gate void (*vop_inactive)(vnode_t *, cred_t *); 6007c478bd9Sstevel@tonic-gate int (*vop_fid)(vnode_t *, struct fid *); 6017c478bd9Sstevel@tonic-gate int (*vop_rwlock)(vnode_t *, int, caller_context_t *); 6027c478bd9Sstevel@tonic-gate void (*vop_rwunlock)(vnode_t *, int, caller_context_t *); 6037c478bd9Sstevel@tonic-gate int (*vop_seek)(vnode_t *, offset_t, offset_t *); 6047c478bd9Sstevel@tonic-gate int (*vop_cmp)(vnode_t *, vnode_t *); 6057c478bd9Sstevel@tonic-gate int (*vop_frlock)(vnode_t *, int, struct flock64 *, int, offset_t, 6067c478bd9Sstevel@tonic-gate struct flk_callback *, cred_t *); 6077c478bd9Sstevel@tonic-gate int (*vop_space)(vnode_t *, int, struct flock64 *, int, offset_t, 6087c478bd9Sstevel@tonic-gate cred_t *, caller_context_t *); 6097c478bd9Sstevel@tonic-gate int (*vop_realvp)(vnode_t *, vnode_t **); 6107c478bd9Sstevel@tonic-gate int (*vop_getpage)(vnode_t *, offset_t, size_t, uint_t *, 6117c478bd9Sstevel@tonic-gate struct page **, size_t, struct seg *, 6127c478bd9Sstevel@tonic-gate caddr_t, enum seg_rw, cred_t *); 6137c478bd9Sstevel@tonic-gate int (*vop_putpage)(vnode_t *, offset_t, size_t, int, cred_t *); 6147c478bd9Sstevel@tonic-gate int (*vop_map)(vnode_t *, offset_t, struct as *, caddr_t *, size_t, 6157c478bd9Sstevel@tonic-gate uchar_t, uchar_t, uint_t, cred_t *); 6167c478bd9Sstevel@tonic-gate int (*vop_addmap)(vnode_t *, offset_t, struct as *, caddr_t, size_t, 6177c478bd9Sstevel@tonic-gate uchar_t, uchar_t, uint_t, cred_t *); 6187c478bd9Sstevel@tonic-gate int (*vop_delmap)(vnode_t *, offset_t, struct as *, caddr_t, size_t, 6197c478bd9Sstevel@tonic-gate uint_t, uint_t, uint_t, cred_t *); 6207c478bd9Sstevel@tonic-gate int (*vop_poll)(vnode_t *, short, int, short *, struct pollhead **); 6217c478bd9Sstevel@tonic-gate int (*vop_dump)(vnode_t *, caddr_t, int, int); 6227c478bd9Sstevel@tonic-gate int (*vop_pathconf)(vnode_t *, int, ulong_t *, cred_t *); 6237c478bd9Sstevel@tonic-gate int (*vop_pageio)(vnode_t *, struct page *, u_offset_t, size_t, 6247c478bd9Sstevel@tonic-gate int, cred_t *); 6257c478bd9Sstevel@tonic-gate int (*vop_dumpctl)(vnode_t *, int, int *); 6267c478bd9Sstevel@tonic-gate void (*vop_dispose)(vnode_t *, struct page *, int, int, cred_t *); 6277c478bd9Sstevel@tonic-gate int (*vop_setsecattr)(vnode_t *, vsecattr_t *, int, cred_t *); 6287c478bd9Sstevel@tonic-gate int (*vop_getsecattr)(vnode_t *, vsecattr_t *, int, cred_t *); 6297c478bd9Sstevel@tonic-gate int (*vop_shrlock)(vnode_t *, int, struct shrlock *, int, cred_t *); 6307c478bd9Sstevel@tonic-gate int (*vop_vnevent)(vnode_t *, vnevent_t); 6317c478bd9Sstevel@tonic-gate } vnodeops_t; 6327c478bd9Sstevel@tonic-gate 6337c478bd9Sstevel@tonic-gate #ifdef _KERNEL 6347c478bd9Sstevel@tonic-gate 6357c478bd9Sstevel@tonic-gate extern int fop_open(vnode_t **, int, cred_t *); 6367c478bd9Sstevel@tonic-gate extern int fop_close(vnode_t *, int, int, offset_t, cred_t *); 6377c478bd9Sstevel@tonic-gate extern int fop_read(vnode_t *, uio_t *, int, cred_t *, caller_context_t *); 6387c478bd9Sstevel@tonic-gate extern int fop_write(vnode_t *, uio_t *, int, cred_t *, 6397c478bd9Sstevel@tonic-gate caller_context_t *); 6407c478bd9Sstevel@tonic-gate extern int fop_ioctl(vnode_t *, int, intptr_t, int, cred_t *, int *); 6417c478bd9Sstevel@tonic-gate extern int fop_setfl(vnode_t *, int, int, cred_t *); 6427c478bd9Sstevel@tonic-gate extern int fop_getattr(vnode_t *, vattr_t *, int, cred_t *); 6437c478bd9Sstevel@tonic-gate extern int fop_setattr(vnode_t *, vattr_t *, int, cred_t *, 6447c478bd9Sstevel@tonic-gate caller_context_t *); 6457c478bd9Sstevel@tonic-gate extern int fop_access(vnode_t *, int, int, cred_t *); 6467c478bd9Sstevel@tonic-gate extern int fop_lookup(vnode_t *, char *, vnode_t **, struct pathname *, 6477c478bd9Sstevel@tonic-gate int, vnode_t *, cred_t *); 6487c478bd9Sstevel@tonic-gate extern int fop_create(vnode_t *, char *, vattr_t *, vcexcl_t, int, 6497c478bd9Sstevel@tonic-gate vnode_t **, cred_t *, int); 6507c478bd9Sstevel@tonic-gate extern int fop_remove(vnode_t *vp, char *, cred_t *); 6517c478bd9Sstevel@tonic-gate extern int fop_link(vnode_t *, vnode_t *, char *, cred_t *); 6527c478bd9Sstevel@tonic-gate extern int fop_rename(vnode_t *, char *, vnode_t *, char *, cred_t *); 6537c478bd9Sstevel@tonic-gate extern int fop_mkdir(vnode_t *, char *, vattr_t *, vnode_t **, cred_t *); 6547c478bd9Sstevel@tonic-gate extern int fop_rmdir(vnode_t *, char *, vnode_t *, cred_t *); 6557c478bd9Sstevel@tonic-gate extern int fop_readdir(vnode_t *, uio_t *, cred_t *, int *); 6567c478bd9Sstevel@tonic-gate extern int fop_symlink(vnode_t *, char *, vattr_t *, char *, cred_t *); 6577c478bd9Sstevel@tonic-gate extern int fop_readlink(vnode_t *, uio_t *, cred_t *); 6587c478bd9Sstevel@tonic-gate extern int fop_fsync(vnode_t *, int, cred_t *); 6597c478bd9Sstevel@tonic-gate extern void fop_inactive(vnode_t *, cred_t *); 6607c478bd9Sstevel@tonic-gate extern int fop_fid(vnode_t *, struct fid *); 6617c478bd9Sstevel@tonic-gate extern int fop_rwlock(vnode_t *, int, caller_context_t *); 6627c478bd9Sstevel@tonic-gate extern void fop_rwunlock(vnode_t *, int, caller_context_t *); 6637c478bd9Sstevel@tonic-gate extern int fop_seek(vnode_t *, offset_t, offset_t *); 6647c478bd9Sstevel@tonic-gate extern int fop_cmp(vnode_t *, vnode_t *); 6657c478bd9Sstevel@tonic-gate extern int fop_frlock(vnode_t *, int, struct flock64 *, int, offset_t, 6667c478bd9Sstevel@tonic-gate struct flk_callback *, cred_t *); 6677c478bd9Sstevel@tonic-gate extern int fop_space(vnode_t *, int, struct flock64 *, int, offset_t, 6687c478bd9Sstevel@tonic-gate cred_t *, caller_context_t *); 6697c478bd9Sstevel@tonic-gate extern int fop_realvp(vnode_t *, vnode_t **); 6707c478bd9Sstevel@tonic-gate extern int fop_getpage(vnode_t *, offset_t, size_t, uint_t *, 6717c478bd9Sstevel@tonic-gate struct page **, size_t, struct seg *, 6727c478bd9Sstevel@tonic-gate caddr_t, enum seg_rw, cred_t *); 6737c478bd9Sstevel@tonic-gate extern int fop_putpage(vnode_t *, offset_t, size_t, int, cred_t *); 6747c478bd9Sstevel@tonic-gate extern int fop_map(vnode_t *, offset_t, struct as *, caddr_t *, size_t, 6757c478bd9Sstevel@tonic-gate uchar_t, uchar_t, uint_t, cred_t *cr); 6767c478bd9Sstevel@tonic-gate extern int fop_addmap(vnode_t *, offset_t, struct as *, caddr_t, size_t, 6777c478bd9Sstevel@tonic-gate uchar_t, uchar_t, uint_t, cred_t *); 6787c478bd9Sstevel@tonic-gate extern int fop_delmap(vnode_t *, offset_t, struct as *, caddr_t, size_t, 6797c478bd9Sstevel@tonic-gate uint_t, uint_t, uint_t, cred_t *); 6807c478bd9Sstevel@tonic-gate extern int fop_poll(vnode_t *, short, int, short *, struct pollhead **); 6817c478bd9Sstevel@tonic-gate extern int fop_dump(vnode_t *, caddr_t, int, int); 6827c478bd9Sstevel@tonic-gate extern int fop_pathconf(vnode_t *, int, ulong_t *, cred_t *); 6837c478bd9Sstevel@tonic-gate extern int fop_pageio(vnode_t *, struct page *, u_offset_t, size_t, int, 6847c478bd9Sstevel@tonic-gate cred_t *); 6857c478bd9Sstevel@tonic-gate extern int fop_dumpctl(vnode_t *, int, int *); 6867c478bd9Sstevel@tonic-gate extern void fop_dispose(vnode_t *, struct page *, int, int, cred_t *); 6877c478bd9Sstevel@tonic-gate extern int fop_setsecattr(vnode_t *, vsecattr_t *, int, cred_t *); 6887c478bd9Sstevel@tonic-gate extern int fop_getsecattr(vnode_t *, vsecattr_t *, int, cred_t *); 6897c478bd9Sstevel@tonic-gate extern int fop_shrlock(vnode_t *, int, struct shrlock *, int, cred_t *); 6907c478bd9Sstevel@tonic-gate extern int fop_vnevent(vnode_t *, vnevent_t); 6917c478bd9Sstevel@tonic-gate 6927c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 6937c478bd9Sstevel@tonic-gate 6947c478bd9Sstevel@tonic-gate #define VOP_OPEN(vpp, mode, cr) \ 6957c478bd9Sstevel@tonic-gate fop_open(vpp, mode, cr) 6967c478bd9Sstevel@tonic-gate #define VOP_CLOSE(vp, f, c, o, cr) \ 6977c478bd9Sstevel@tonic-gate fop_close(vp, f, c, o, cr) 6987c478bd9Sstevel@tonic-gate #define VOP_READ(vp, uiop, iof, cr, ct) \ 6997c478bd9Sstevel@tonic-gate fop_read(vp, uiop, iof, cr, ct) 7007c478bd9Sstevel@tonic-gate #define VOP_WRITE(vp, uiop, iof, cr, ct) \ 7017c478bd9Sstevel@tonic-gate fop_write(vp, uiop, iof, cr, ct) 7027c478bd9Sstevel@tonic-gate #define VOP_IOCTL(vp, cmd, a, f, cr, rvp) \ 7037c478bd9Sstevel@tonic-gate fop_ioctl(vp, cmd, a, f, cr, rvp) 7047c478bd9Sstevel@tonic-gate #define VOP_SETFL(vp, f, a, cr) \ 7057c478bd9Sstevel@tonic-gate fop_setfl(vp, f, a, cr) 7067c478bd9Sstevel@tonic-gate #define VOP_GETATTR(vp, vap, f, cr) \ 7077c478bd9Sstevel@tonic-gate fop_getattr(vp, vap, f, cr) 7087c478bd9Sstevel@tonic-gate #define VOP_SETATTR(vp, vap, f, cr, ct) \ 7097c478bd9Sstevel@tonic-gate fop_setattr(vp, vap, f, cr, ct) 7107c478bd9Sstevel@tonic-gate #define VOP_ACCESS(vp, mode, f, cr) \ 7117c478bd9Sstevel@tonic-gate fop_access(vp, mode, f, cr) 7127c478bd9Sstevel@tonic-gate #define VOP_LOOKUP(vp, cp, vpp, pnp, f, rdir, cr) \ 7137c478bd9Sstevel@tonic-gate fop_lookup(vp, cp, vpp, pnp, f, rdir, cr) 7147c478bd9Sstevel@tonic-gate #define VOP_CREATE(dvp, p, vap, ex, mode, vpp, cr, flag) \ 7157c478bd9Sstevel@tonic-gate fop_create(dvp, p, vap, ex, mode, vpp, cr, flag) 7167c478bd9Sstevel@tonic-gate #define VOP_REMOVE(dvp, p, cr) \ 7177c478bd9Sstevel@tonic-gate fop_remove(dvp, p, cr) 7187c478bd9Sstevel@tonic-gate #define VOP_LINK(tdvp, fvp, p, cr) \ 7197c478bd9Sstevel@tonic-gate fop_link(tdvp, fvp, p, cr) 7207c478bd9Sstevel@tonic-gate #define VOP_RENAME(fvp, fnm, tdvp, tnm, cr) \ 7217c478bd9Sstevel@tonic-gate fop_rename(fvp, fnm, tdvp, tnm, cr) 7227c478bd9Sstevel@tonic-gate #define VOP_MKDIR(dp, p, vap, vpp, cr) \ 7237c478bd9Sstevel@tonic-gate fop_mkdir(dp, p, vap, vpp, cr) 7247c478bd9Sstevel@tonic-gate #define VOP_RMDIR(dp, p, cdir, cr) \ 7257c478bd9Sstevel@tonic-gate fop_rmdir(dp, p, cdir, cr) 7267c478bd9Sstevel@tonic-gate #define VOP_READDIR(vp, uiop, cr, eofp) \ 7277c478bd9Sstevel@tonic-gate fop_readdir(vp, uiop, cr, eofp) 7287c478bd9Sstevel@tonic-gate #define VOP_SYMLINK(dvp, lnm, vap, tnm, cr) \ 7297c478bd9Sstevel@tonic-gate fop_symlink(dvp, lnm, vap, tnm, cr) 7307c478bd9Sstevel@tonic-gate #define VOP_READLINK(vp, uiop, cr) \ 7317c478bd9Sstevel@tonic-gate fop_readlink(vp, uiop, cr) 7327c478bd9Sstevel@tonic-gate #define VOP_FSYNC(vp, syncflag, cr) \ 7337c478bd9Sstevel@tonic-gate fop_fsync(vp, syncflag, cr) 7347c478bd9Sstevel@tonic-gate #define VOP_INACTIVE(vp, cr) \ 7357c478bd9Sstevel@tonic-gate fop_inactive(vp, cr) 7367c478bd9Sstevel@tonic-gate #define VOP_FID(vp, fidp) \ 7377c478bd9Sstevel@tonic-gate fop_fid(vp, fidp) 7387c478bd9Sstevel@tonic-gate #define VOP_RWLOCK(vp, w, ct) \ 7397c478bd9Sstevel@tonic-gate fop_rwlock(vp, w, ct) 7407c478bd9Sstevel@tonic-gate #define VOP_RWUNLOCK(vp, w, ct) \ 7417c478bd9Sstevel@tonic-gate fop_rwunlock(vp, w, ct) 7427c478bd9Sstevel@tonic-gate #define VOP_SEEK(vp, ooff, noffp) \ 7437c478bd9Sstevel@tonic-gate fop_seek(vp, ooff, noffp) 7447c478bd9Sstevel@tonic-gate #define VOP_CMP(vp1, vp2) \ 7457c478bd9Sstevel@tonic-gate fop_cmp(vp1, vp2) 7467c478bd9Sstevel@tonic-gate #define VOP_FRLOCK(vp, cmd, a, f, o, cb, cr) \ 7477c478bd9Sstevel@tonic-gate fop_frlock(vp, cmd, a, f, o, cb, cr) 7487c478bd9Sstevel@tonic-gate #define VOP_SPACE(vp, cmd, a, f, o, cr, ct) \ 7497c478bd9Sstevel@tonic-gate fop_space(vp, cmd, a, f, o, cr, ct) 7507c478bd9Sstevel@tonic-gate #define VOP_REALVP(vp1, vp2) \ 7517c478bd9Sstevel@tonic-gate fop_realvp(vp1, vp2) 7527c478bd9Sstevel@tonic-gate #define VOP_GETPAGE(vp, of, sz, pr, pl, ps, sg, a, rw, cr) \ 7537c478bd9Sstevel@tonic-gate fop_getpage(vp, of, sz, pr, pl, ps, sg, a, rw, cr) 7547c478bd9Sstevel@tonic-gate #define VOP_PUTPAGE(vp, of, sz, fl, cr) \ 7557c478bd9Sstevel@tonic-gate fop_putpage(vp, of, sz, fl, cr) 7567c478bd9Sstevel@tonic-gate #define VOP_MAP(vp, of, as, a, sz, p, mp, fl, cr) \ 7577c478bd9Sstevel@tonic-gate fop_map(vp, of, as, a, sz, p, mp, fl, cr) 7587c478bd9Sstevel@tonic-gate #define VOP_ADDMAP(vp, of, as, a, sz, p, mp, fl, cr) \ 7597c478bd9Sstevel@tonic-gate fop_addmap(vp, of, as, a, sz, p, mp, fl, cr) 7607c478bd9Sstevel@tonic-gate #define VOP_DELMAP(vp, of, as, a, sz, p, mp, fl, cr) \ 7617c478bd9Sstevel@tonic-gate fop_delmap(vp, of, as, a, sz, p, mp, fl, cr) 7627c478bd9Sstevel@tonic-gate #define VOP_POLL(vp, events, anyyet, reventsp, phpp) \ 7637c478bd9Sstevel@tonic-gate fop_poll(vp, events, anyyet, reventsp, phpp) 7647c478bd9Sstevel@tonic-gate #define VOP_DUMP(vp, addr, bn, count) \ 7657c478bd9Sstevel@tonic-gate fop_dump(vp, addr, bn, count) 7667c478bd9Sstevel@tonic-gate #define VOP_PATHCONF(vp, cmd, valp, cr) \ 7677c478bd9Sstevel@tonic-gate fop_pathconf(vp, cmd, valp, cr) 7687c478bd9Sstevel@tonic-gate #define VOP_PAGEIO(vp, pp, io_off, io_len, flags, cr) \ 7697c478bd9Sstevel@tonic-gate fop_pageio(vp, pp, io_off, io_len, flags, cr) 7707c478bd9Sstevel@tonic-gate #define VOP_DUMPCTL(vp, action, blkp) \ 7717c478bd9Sstevel@tonic-gate fop_dumpctl(vp, action, blkp) 7727c478bd9Sstevel@tonic-gate #define VOP_DISPOSE(vp, pp, flag, dn, cr) \ 7737c478bd9Sstevel@tonic-gate fop_dispose(vp, pp, flag, dn, cr) 7747c478bd9Sstevel@tonic-gate #define VOP_GETSECATTR(vp, vsap, f, cr) \ 7757c478bd9Sstevel@tonic-gate fop_getsecattr(vp, vsap, f, cr) 7767c478bd9Sstevel@tonic-gate #define VOP_SETSECATTR(vp, vsap, f, cr) \ 7777c478bd9Sstevel@tonic-gate fop_setsecattr(vp, vsap, f, cr) 7787c478bd9Sstevel@tonic-gate #define VOP_SHRLOCK(vp, cmd, shr, f, cr) \ 7797c478bd9Sstevel@tonic-gate fop_shrlock(vp, cmd, shr, f, cr) 7807c478bd9Sstevel@tonic-gate #define VOP_VNEVENT(vp, vnevent) \ 7817c478bd9Sstevel@tonic-gate fop_vnevent(vp, vnevent) 7827c478bd9Sstevel@tonic-gate 7837c478bd9Sstevel@tonic-gate #define VOPNAME_OPEN "open" 7847c478bd9Sstevel@tonic-gate #define VOPNAME_CLOSE "close" 7857c478bd9Sstevel@tonic-gate #define VOPNAME_READ "read" 7867c478bd9Sstevel@tonic-gate #define VOPNAME_WRITE "write" 7877c478bd9Sstevel@tonic-gate #define VOPNAME_IOCTL "ioctl" 7887c478bd9Sstevel@tonic-gate #define VOPNAME_SETFL "setfl" 7897c478bd9Sstevel@tonic-gate #define VOPNAME_GETATTR "getattr" 7907c478bd9Sstevel@tonic-gate #define VOPNAME_SETATTR "setattr" 7917c478bd9Sstevel@tonic-gate #define VOPNAME_ACCESS "access" 7927c478bd9Sstevel@tonic-gate #define VOPNAME_LOOKUP "lookup" 7937c478bd9Sstevel@tonic-gate #define VOPNAME_CREATE "create" 7947c478bd9Sstevel@tonic-gate #define VOPNAME_REMOVE "remove" 7957c478bd9Sstevel@tonic-gate #define VOPNAME_LINK "link" 7967c478bd9Sstevel@tonic-gate #define VOPNAME_RENAME "rename" 7977c478bd9Sstevel@tonic-gate #define VOPNAME_MKDIR "mkdir" 7987c478bd9Sstevel@tonic-gate #define VOPNAME_RMDIR "rmdir" 7997c478bd9Sstevel@tonic-gate #define VOPNAME_READDIR "readdir" 8007c478bd9Sstevel@tonic-gate #define VOPNAME_SYMLINK "symlink" 8017c478bd9Sstevel@tonic-gate #define VOPNAME_READLINK "readlink" 8027c478bd9Sstevel@tonic-gate #define VOPNAME_FSYNC "fsync" 8037c478bd9Sstevel@tonic-gate #define VOPNAME_INACTIVE "inactive" 8047c478bd9Sstevel@tonic-gate #define VOPNAME_FID "fid" 8057c478bd9Sstevel@tonic-gate #define VOPNAME_RWLOCK "rwlock" 8067c478bd9Sstevel@tonic-gate #define VOPNAME_RWUNLOCK "rwunlock" 8077c478bd9Sstevel@tonic-gate #define VOPNAME_SEEK "seek" 8087c478bd9Sstevel@tonic-gate #define VOPNAME_CMP "cmp" 8097c478bd9Sstevel@tonic-gate #define VOPNAME_FRLOCK "frlock" 8107c478bd9Sstevel@tonic-gate #define VOPNAME_SPACE "space" 8117c478bd9Sstevel@tonic-gate #define VOPNAME_REALVP "realvp" 8127c478bd9Sstevel@tonic-gate #define VOPNAME_GETPAGE "getpage" 8137c478bd9Sstevel@tonic-gate #define VOPNAME_PUTPAGE "putpage" 8147c478bd9Sstevel@tonic-gate #define VOPNAME_MAP "map" 8157c478bd9Sstevel@tonic-gate #define VOPNAME_ADDMAP "addmap" 8167c478bd9Sstevel@tonic-gate #define VOPNAME_DELMAP "delmap" 8177c478bd9Sstevel@tonic-gate #define VOPNAME_POLL "poll" 8187c478bd9Sstevel@tonic-gate #define VOPNAME_DUMP "dump" 8197c478bd9Sstevel@tonic-gate #define VOPNAME_PATHCONF "pathconf" 8207c478bd9Sstevel@tonic-gate #define VOPNAME_PAGEIO "pageio" 8217c478bd9Sstevel@tonic-gate #define VOPNAME_DUMPCTL "dumpctl" 8227c478bd9Sstevel@tonic-gate #define VOPNAME_DISPOSE "dispose" 8237c478bd9Sstevel@tonic-gate #define VOPNAME_GETSECATTR "getsecattr" 8247c478bd9Sstevel@tonic-gate #define VOPNAME_SETSECATTR "setsecattr" 8257c478bd9Sstevel@tonic-gate #define VOPNAME_SHRLOCK "shrlock" 8267c478bd9Sstevel@tonic-gate #define VOPNAME_VNEVENT "vnevent" 8277c478bd9Sstevel@tonic-gate 8287c478bd9Sstevel@tonic-gate /* 8297c478bd9Sstevel@tonic-gate * Flags for VOP_LOOKUP 8307c478bd9Sstevel@tonic-gate */ 8317c478bd9Sstevel@tonic-gate #define LOOKUP_DIR 0x01 /* want parent dir vp */ 8327c478bd9Sstevel@tonic-gate #define LOOKUP_XATTR 0x02 /* lookup up extended attr dir */ 8337c478bd9Sstevel@tonic-gate #define CREATE_XATTR_DIR 0x04 /* Create extended attr dir */ 8347c478bd9Sstevel@tonic-gate 8357c478bd9Sstevel@tonic-gate /* 8367c478bd9Sstevel@tonic-gate * Flags for VOP_RWLOCK/VOP_RWUNLOCK 8377c478bd9Sstevel@tonic-gate * VOP_RWLOCK will return the flag that was actually set, or -1 if none. 8387c478bd9Sstevel@tonic-gate */ 8397c478bd9Sstevel@tonic-gate #define V_WRITELOCK_TRUE (1) /* Request write-lock on the vnode */ 8407c478bd9Sstevel@tonic-gate #define V_WRITELOCK_FALSE (0) /* Request read-lock on the vnode */ 8417c478bd9Sstevel@tonic-gate 8427c478bd9Sstevel@tonic-gate /* 8437c478bd9Sstevel@tonic-gate * Flags for VOP_DUMPCTL 8447c478bd9Sstevel@tonic-gate */ 8457c478bd9Sstevel@tonic-gate #define DUMP_ALLOC 0 8467c478bd9Sstevel@tonic-gate #define DUMP_FREE 1 8477c478bd9Sstevel@tonic-gate #define DUMP_SCAN 2 8487c478bd9Sstevel@tonic-gate 8497c478bd9Sstevel@tonic-gate /* 8507c478bd9Sstevel@tonic-gate * Public vnode manipulation functions. 8517c478bd9Sstevel@tonic-gate */ 8527c478bd9Sstevel@tonic-gate #ifdef _KERNEL 8537c478bd9Sstevel@tonic-gate 8547c478bd9Sstevel@tonic-gate vnode_t *vn_alloc(int); 8557c478bd9Sstevel@tonic-gate void vn_reinit(vnode_t *); 8567c478bd9Sstevel@tonic-gate void vn_recycle(vnode_t *); 8577c478bd9Sstevel@tonic-gate void vn_free(vnode_t *); 8587c478bd9Sstevel@tonic-gate 8597c478bd9Sstevel@tonic-gate int vn_is_readonly(vnode_t *); 8607c478bd9Sstevel@tonic-gate int vn_is_opened(vnode_t *, v_mode_t); 8617c478bd9Sstevel@tonic-gate int vn_is_mapped(vnode_t *, v_mode_t); 8627c478bd9Sstevel@tonic-gate 8637c478bd9Sstevel@tonic-gate int vn_can_change_zones(vnode_t *vp); 8647c478bd9Sstevel@tonic-gate 8657c478bd9Sstevel@tonic-gate int vn_has_flocks(vnode_t *); 8667c478bd9Sstevel@tonic-gate int vn_has_mandatory_locks(vnode_t *, int); 8677c478bd9Sstevel@tonic-gate int vn_has_cached_data(vnode_t *); 8687c478bd9Sstevel@tonic-gate 8697c478bd9Sstevel@tonic-gate void vn_setops(vnode_t *, vnodeops_t *); 8707c478bd9Sstevel@tonic-gate vnodeops_t *vn_getops(vnode_t *); 8717c478bd9Sstevel@tonic-gate int vn_matchops(vnode_t *, vnodeops_t *); 8727c478bd9Sstevel@tonic-gate int vn_matchopval(vnode_t *, char *, fs_generic_func_p); 8737c478bd9Sstevel@tonic-gate int vn_ismntpt(vnode_t *); 8747c478bd9Sstevel@tonic-gate 8757c478bd9Sstevel@tonic-gate struct vfs *vn_mountedvfs(vnode_t *); 8767c478bd9Sstevel@tonic-gate 8777c478bd9Sstevel@tonic-gate void vn_create_cache(void); 8787c478bd9Sstevel@tonic-gate void vn_destroy_cache(void); 8797c478bd9Sstevel@tonic-gate 8807c478bd9Sstevel@tonic-gate int vn_make_ops(const char *, const fs_operation_def_t *, vnodeops_t **); 8817c478bd9Sstevel@tonic-gate void vn_freevnodeops(vnodeops_t *); 8827c478bd9Sstevel@tonic-gate 8837c478bd9Sstevel@tonic-gate int vn_open(char *pnamep, enum uio_seg seg, int filemode, int createmode, 8847c478bd9Sstevel@tonic-gate struct vnode **vpp, enum create crwhy, mode_t umask); 8857c478bd9Sstevel@tonic-gate int vn_openat(char *pnamep, enum uio_seg seg, int filemode, int createmode, 8867c478bd9Sstevel@tonic-gate struct vnode **vpp, enum create crwhy, 8877c478bd9Sstevel@tonic-gate mode_t umask, struct vnode *startvp); 8887c478bd9Sstevel@tonic-gate int vn_create(char *pnamep, enum uio_seg seg, struct vattr *vap, 8897c478bd9Sstevel@tonic-gate enum vcexcl excl, int mode, struct vnode **vpp, 8907c478bd9Sstevel@tonic-gate enum create why, int flag, mode_t umask); 8917c478bd9Sstevel@tonic-gate int vn_createat(char *pnamep, enum uio_seg seg, struct vattr *vap, 8927c478bd9Sstevel@tonic-gate enum vcexcl excl, int mode, struct vnode **vpp, 8937c478bd9Sstevel@tonic-gate enum create why, int flag, mode_t umask, struct vnode *startvp); 8947c478bd9Sstevel@tonic-gate int vn_rdwr(enum uio_rw rw, struct vnode *vp, caddr_t base, ssize_t len, 8957c478bd9Sstevel@tonic-gate offset_t offset, enum uio_seg seg, int ioflag, rlim64_t ulimit, 8967c478bd9Sstevel@tonic-gate cred_t *cr, ssize_t *residp); 8977c478bd9Sstevel@tonic-gate void vn_rele(struct vnode *vp); 8987c478bd9Sstevel@tonic-gate void vn_rele_stream(struct vnode *vp); 8997c478bd9Sstevel@tonic-gate int vn_link(char *from, char *to, enum uio_seg seg); 9007c478bd9Sstevel@tonic-gate int vn_rename(char *from, char *to, enum uio_seg seg); 9017c478bd9Sstevel@tonic-gate int vn_renameat(vnode_t *fdvp, char *fname, vnode_t *tdvp, char *tname, 9027c478bd9Sstevel@tonic-gate enum uio_seg seg); 9037c478bd9Sstevel@tonic-gate int vn_remove(char *fnamep, enum uio_seg seg, enum rm dirflag); 9047c478bd9Sstevel@tonic-gate int vn_removeat(vnode_t *startvp, char *fnamep, enum uio_seg seg, 9057c478bd9Sstevel@tonic-gate enum rm dirflag); 9067c478bd9Sstevel@tonic-gate int vn_compare(vnode_t *vp1, vnode_t *vp2); 9077c478bd9Sstevel@tonic-gate int vn_vfswlock(struct vnode *vp); 9087c478bd9Sstevel@tonic-gate int vn_vfswlock_wait(struct vnode *vp); 9097c478bd9Sstevel@tonic-gate int vn_vfsrlock(struct vnode *vp); 9107c478bd9Sstevel@tonic-gate int vn_vfsrlock_wait(struct vnode *vp); 9117c478bd9Sstevel@tonic-gate void vn_vfsunlock(struct vnode *vp); 9127c478bd9Sstevel@tonic-gate int vn_vfswlock_held(struct vnode *vp); 9137c478bd9Sstevel@tonic-gate vnode_t *specvp(struct vnode *vp, dev_t dev, vtype_t type, struct cred *cr); 9147c478bd9Sstevel@tonic-gate vnode_t *makespecvp(dev_t dev, vtype_t type); 9157c478bd9Sstevel@tonic-gate vn_vfslocks_entry_t *vn_vfslocks_getlock(void *); 9167c478bd9Sstevel@tonic-gate void vn_vfslocks_rele(vn_vfslocks_entry_t *); 9177c478bd9Sstevel@tonic-gate 918ca2c3138Seschrock void vn_copypath(struct vnode *src, struct vnode *dst); 919ca2c3138Seschrock void vn_setpath_str(struct vnode *vp, const char *str, size_t len); 920ca2c3138Seschrock void vn_setpath(vnode_t *rootvp, struct vnode *startvp, struct vnode *vp, 921ca2c3138Seschrock const char *path, size_t plen); 922ca2c3138Seschrock 9237c478bd9Sstevel@tonic-gate /* Vnode event notification */ 9247c478bd9Sstevel@tonic-gate void vnevent_rename_src(vnode_t *); 9257c478bd9Sstevel@tonic-gate void vnevent_rename_dest(vnode_t *); 9267c478bd9Sstevel@tonic-gate void vnevent_remove(vnode_t *); 9277c478bd9Sstevel@tonic-gate void vnevent_rmdir(vnode_t *); 9287c478bd9Sstevel@tonic-gate int vnevent_support(vnode_t *); 9297c478bd9Sstevel@tonic-gate 9307c478bd9Sstevel@tonic-gate /* Context identification */ 9317c478bd9Sstevel@tonic-gate u_longlong_t fs_new_caller_id(); 9327c478bd9Sstevel@tonic-gate 9337c478bd9Sstevel@tonic-gate int vn_vmpss_usepageio(vnode_t *); 9347c478bd9Sstevel@tonic-gate 9357c478bd9Sstevel@tonic-gate /* 9367c478bd9Sstevel@tonic-gate * Needed for use of IS_VMODSORT() in kernel. 9377c478bd9Sstevel@tonic-gate */ 9387c478bd9Sstevel@tonic-gate extern uint_t pvn_vmodsort_supported; 9397c478bd9Sstevel@tonic-gate 9407c478bd9Sstevel@tonic-gate #define VN_HOLD(vp) { \ 9417c478bd9Sstevel@tonic-gate mutex_enter(&(vp)->v_lock); \ 9427c478bd9Sstevel@tonic-gate (vp)->v_count++; \ 9437c478bd9Sstevel@tonic-gate mutex_exit(&(vp)->v_lock); \ 9447c478bd9Sstevel@tonic-gate } 9457c478bd9Sstevel@tonic-gate 9467c478bd9Sstevel@tonic-gate #define VN_RELE(vp) { \ 9477c478bd9Sstevel@tonic-gate vn_rele(vp); \ 9487c478bd9Sstevel@tonic-gate } 9497c478bd9Sstevel@tonic-gate 9507c478bd9Sstevel@tonic-gate #define VN_SET_VFS_TYPE_DEV(vp, vfsp, type, dev) { \ 9517c478bd9Sstevel@tonic-gate (vp)->v_vfsp = (vfsp); \ 9527c478bd9Sstevel@tonic-gate (vp)->v_type = (type); \ 9537c478bd9Sstevel@tonic-gate (vp)->v_rdev = (dev); \ 9547c478bd9Sstevel@tonic-gate } 9557c478bd9Sstevel@tonic-gate 9567c478bd9Sstevel@tonic-gate /* 9577c478bd9Sstevel@tonic-gate * Compare two vnodes for equality. In general this macro should be used 9587c478bd9Sstevel@tonic-gate * in preference to calling VOP_CMP directly. 9597c478bd9Sstevel@tonic-gate */ 9607c478bd9Sstevel@tonic-gate #define VN_CMP(VP1, VP2) ((VP1) == (VP2) ? 1 : \ 9617c478bd9Sstevel@tonic-gate ((VP1) && (VP2) && (vn_getops(VP1) == vn_getops(VP2)) ? \ 9627c478bd9Sstevel@tonic-gate VOP_CMP(VP1, VP2) : 0)) 9637c478bd9Sstevel@tonic-gate 9647c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 9657c478bd9Sstevel@tonic-gate 9667c478bd9Sstevel@tonic-gate /* 9677c478bd9Sstevel@tonic-gate * Flags to VOP_SETATTR/VOP_GETATTR. 9687c478bd9Sstevel@tonic-gate */ 9697c478bd9Sstevel@tonic-gate #define ATTR_UTIME 0x01 /* non-default utime(2) request */ 9707c478bd9Sstevel@tonic-gate #define ATTR_EXEC 0x02 /* invocation from exec(2) */ 9717c478bd9Sstevel@tonic-gate #define ATTR_COMM 0x04 /* yield common vp attributes */ 9727c478bd9Sstevel@tonic-gate #define ATTR_HINT 0x08 /* information returned will be `hint' */ 9737c478bd9Sstevel@tonic-gate #define ATTR_REAL 0x10 /* yield attributes of the real vp */ 9747c478bd9Sstevel@tonic-gate 9757c478bd9Sstevel@tonic-gate /* 9767c478bd9Sstevel@tonic-gate * Generally useful macros. 9777c478bd9Sstevel@tonic-gate */ 9787c478bd9Sstevel@tonic-gate #define VBSIZE(vp) ((vp)->v_vfsp->vfs_bsize) 979fa9e4066Sahrens 980fa9e4066Sahrens #define VTOZONE(vp) ((vp)->v_vfsp->vfs_zone) 981fa9e4066Sahrens 9827c478bd9Sstevel@tonic-gate #define NULLVP ((struct vnode *)0) 9837c478bd9Sstevel@tonic-gate #define NULLVPP ((struct vnode **)0) 9847c478bd9Sstevel@tonic-gate 9857c478bd9Sstevel@tonic-gate #ifdef _KERNEL 9867c478bd9Sstevel@tonic-gate 9877c478bd9Sstevel@tonic-gate /* 9887c478bd9Sstevel@tonic-gate * Structure used while handling asynchronous VOP_PUTPAGE operations. 9897c478bd9Sstevel@tonic-gate */ 9907c478bd9Sstevel@tonic-gate struct async_reqs { 9917c478bd9Sstevel@tonic-gate struct async_reqs *a_next; /* pointer to next arg struct */ 9927c478bd9Sstevel@tonic-gate struct vnode *a_vp; /* vnode pointer */ 9937c478bd9Sstevel@tonic-gate u_offset_t a_off; /* offset in file */ 9947c478bd9Sstevel@tonic-gate uint_t a_len; /* size of i/o request */ 9957c478bd9Sstevel@tonic-gate int a_flags; /* flags to indicate operation type */ 9967c478bd9Sstevel@tonic-gate struct cred *a_cred; /* cred pointer */ 9977c478bd9Sstevel@tonic-gate ushort_t a_prealloced; /* set if struct is pre-allocated */ 9987c478bd9Sstevel@tonic-gate }; 9997c478bd9Sstevel@tonic-gate 10007c478bd9Sstevel@tonic-gate /* 10017c478bd9Sstevel@tonic-gate * VN_DISPOSE() -- given a page pointer, safely invoke VOP_DISPOSE(). 10027c478bd9Sstevel@tonic-gate */ 10037c478bd9Sstevel@tonic-gate #define VN_DISPOSE(pp, flag, dn, cr) { \ 10047c478bd9Sstevel@tonic-gate extern struct vnode kvp; \ 10057c478bd9Sstevel@tonic-gate if ((pp)->p_vnode != NULL && (pp)->p_vnode != &kvp) \ 10067c478bd9Sstevel@tonic-gate VOP_DISPOSE((pp)->p_vnode, (pp), (flag), (dn), (cr)); \ 10077c478bd9Sstevel@tonic-gate else if ((flag) == B_FREE) \ 10087c478bd9Sstevel@tonic-gate page_free((pp), (dn)); \ 10097c478bd9Sstevel@tonic-gate else \ 10107c478bd9Sstevel@tonic-gate page_destroy((pp), (dn)); \ 10117c478bd9Sstevel@tonic-gate } 10127c478bd9Sstevel@tonic-gate 10137c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 10147c478bd9Sstevel@tonic-gate 10157c478bd9Sstevel@tonic-gate #ifdef __cplusplus 10167c478bd9Sstevel@tonic-gate } 10177c478bd9Sstevel@tonic-gate #endif 10187c478bd9Sstevel@tonic-gate 10197c478bd9Sstevel@tonic-gate #endif /* _SYS_VNODE_H */ 1020