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