10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51488Srsb * Common Development and Distribution License (the "License"). 61488Srsb * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 2112789SRoger.Faulkner@Oracle.COM 220Sstevel@tonic-gate /* 2312230SFrank.Rival@oracle.com * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 270Sstevel@tonic-gate /* All Rights Reserved */ 280Sstevel@tonic-gate 290Sstevel@tonic-gate /* 300Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 310Sstevel@tonic-gate * The Regents of the University of California 320Sstevel@tonic-gate * All Rights Reserved 330Sstevel@tonic-gate * 340Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 350Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 360Sstevel@tonic-gate * contributors. 370Sstevel@tonic-gate */ 380Sstevel@tonic-gate 390Sstevel@tonic-gate #ifndef _SYS_VNODE_H 400Sstevel@tonic-gate #define _SYS_VNODE_H 410Sstevel@tonic-gate 420Sstevel@tonic-gate #include <sys/types.h> 430Sstevel@tonic-gate #include <sys/t_lock.h> 440Sstevel@tonic-gate #include <sys/rwstlock.h> 450Sstevel@tonic-gate #include <sys/time_impl.h> 460Sstevel@tonic-gate #include <sys/cred.h> 470Sstevel@tonic-gate #include <sys/uio.h> 480Sstevel@tonic-gate #include <sys/resource.h> 490Sstevel@tonic-gate #include <vm/seg_enum.h> 501488Srsb #include <sys/kstat.h> 511488Srsb #include <sys/kmem.h> 525050Sjwahlig #include <sys/list.h> 530Sstevel@tonic-gate #ifdef _KERNEL 540Sstevel@tonic-gate #include <sys/buf.h> 550Sstevel@tonic-gate #endif /* _KERNEL */ 560Sstevel@tonic-gate 570Sstevel@tonic-gate #ifdef __cplusplus 580Sstevel@tonic-gate extern "C" { 590Sstevel@tonic-gate #endif 600Sstevel@tonic-gate 610Sstevel@tonic-gate /* 621488Srsb * Statistics for all vnode operations. 631488Srsb * All operations record number of ops (since boot/mount/zero'ed). 641488Srsb * Certain I/O operations (read, write, readdir) also record number 651488Srsb * of bytes transferred. 661488Srsb * This appears in two places in the system: one is embedded in each 671488Srsb * vfs_t. There is also an array of vopstats_t structures allocated 681488Srsb * on a per-fstype basis. 691488Srsb */ 701488Srsb 711488Srsb #define VOPSTATS_STR "vopstats_" /* Initial string for vopstat kstats */ 721488Srsb 731488Srsb typedef struct vopstats { 741488Srsb kstat_named_t nopen; /* VOP_OPEN */ 751488Srsb kstat_named_t nclose; /* VOP_CLOSE */ 761488Srsb kstat_named_t nread; /* VOP_READ */ 771488Srsb kstat_named_t read_bytes; 781488Srsb kstat_named_t nwrite; /* VOP_WRITE */ 791488Srsb kstat_named_t write_bytes; 801488Srsb kstat_named_t nioctl; /* VOP_IOCTL */ 811488Srsb kstat_named_t nsetfl; /* VOP_SETFL */ 821488Srsb kstat_named_t ngetattr; /* VOP_GETATTR */ 831488Srsb kstat_named_t nsetattr; /* VOP_SETATTR */ 841488Srsb kstat_named_t naccess; /* VOP_ACCESS */ 851488Srsb kstat_named_t nlookup; /* VOP_LOOKUP */ 861488Srsb kstat_named_t ncreate; /* VOP_CREATE */ 871488Srsb kstat_named_t nremove; /* VOP_REMOVE */ 881488Srsb kstat_named_t nlink; /* VOP_LINK */ 891488Srsb kstat_named_t nrename; /* VOP_RENAME */ 901488Srsb kstat_named_t nmkdir; /* VOP_MKDIR */ 911488Srsb kstat_named_t nrmdir; /* VOP_RMDIR */ 921488Srsb kstat_named_t nreaddir; /* VOP_READDIR */ 931488Srsb kstat_named_t readdir_bytes; 941488Srsb kstat_named_t nsymlink; /* VOP_SYMLINK */ 951488Srsb kstat_named_t nreadlink; /* VOP_READLINK */ 961488Srsb kstat_named_t nfsync; /* VOP_FSYNC */ 971488Srsb kstat_named_t ninactive; /* VOP_INACTIVE */ 981488Srsb kstat_named_t nfid; /* VOP_FID */ 991488Srsb kstat_named_t nrwlock; /* VOP_RWLOCK */ 1001488Srsb kstat_named_t nrwunlock; /* VOP_RWUNLOCK */ 1011488Srsb kstat_named_t nseek; /* VOP_SEEK */ 1021488Srsb kstat_named_t ncmp; /* VOP_CMP */ 1031488Srsb kstat_named_t nfrlock; /* VOP_FRLOCK */ 1041488Srsb kstat_named_t nspace; /* VOP_SPACE */ 1051488Srsb kstat_named_t nrealvp; /* VOP_REALVP */ 1061488Srsb kstat_named_t ngetpage; /* VOP_GETPAGE */ 1071488Srsb kstat_named_t nputpage; /* VOP_PUTPAGE */ 1081488Srsb kstat_named_t nmap; /* VOP_MAP */ 1091488Srsb kstat_named_t naddmap; /* VOP_ADDMAP */ 1101488Srsb kstat_named_t ndelmap; /* VOP_DELMAP */ 1111488Srsb kstat_named_t npoll; /* VOP_POLL */ 1121488Srsb kstat_named_t ndump; /* VOP_DUMP */ 1131488Srsb kstat_named_t npathconf; /* VOP_PATHCONF */ 1141488Srsb kstat_named_t npageio; /* VOP_PAGEIO */ 1151488Srsb kstat_named_t ndumpctl; /* VOP_DUMPCTL */ 1161488Srsb kstat_named_t ndispose; /* VOP_DISPOSE */ 1171488Srsb kstat_named_t nsetsecattr; /* VOP_SETSECATTR */ 1181488Srsb kstat_named_t ngetsecattr; /* VOP_GETSECATTR */ 1191488Srsb kstat_named_t nshrlock; /* VOP_SHRLOCK */ 1201488Srsb kstat_named_t nvnevent; /* VOP_VNEVENT */ 12111539SChunli.Zhang@Sun.COM kstat_named_t nreqzcbuf; /* VOP_REQZCBUF */ 12211539SChunli.Zhang@Sun.COM kstat_named_t nretzcbuf; /* VOP_RETZCBUF */ 1231488Srsb } vopstats_t; 1241488Srsb 1251488Srsb /* 1260Sstevel@tonic-gate * The vnode is the focus of all file activity in UNIX. 1270Sstevel@tonic-gate * A vnode is allocated for each active file, each current 1280Sstevel@tonic-gate * directory, each mounted-on file, and the root. 1290Sstevel@tonic-gate * 1300Sstevel@tonic-gate * Each vnode is usually associated with a file-system-specific node (for 1310Sstevel@tonic-gate * UFS, this is the in-memory inode). Generally, a vnode and an fs-node 1320Sstevel@tonic-gate * should be created and destroyed together as a pair. 1330Sstevel@tonic-gate * 1340Sstevel@tonic-gate * If a vnode is reused for a new file, it should be reinitialized by calling 1350Sstevel@tonic-gate * either vn_reinit() or vn_recycle(). 1360Sstevel@tonic-gate * 1370Sstevel@tonic-gate * vn_reinit() resets the entire vnode as if it was returned by vn_alloc(). 1380Sstevel@tonic-gate * The caller is responsible for setting up the entire vnode after calling 1390Sstevel@tonic-gate * vn_reinit(). This is important when using kmem caching where the vnode is 1400Sstevel@tonic-gate * allocated by a constructor, for instance. 1410Sstevel@tonic-gate * 1420Sstevel@tonic-gate * vn_recycle() is used when the file system keeps some state around in both 1430Sstevel@tonic-gate * the vnode and the associated FS-node. In UFS, for example, the inode of 1440Sstevel@tonic-gate * a deleted file can be reused immediately. The v_data, v_vfsp, v_op, etc. 1450Sstevel@tonic-gate * remains the same but certain fields related to the previous instance need 1460Sstevel@tonic-gate * to be reset. In particular: 1470Sstevel@tonic-gate * v_femhead 1480Sstevel@tonic-gate * v_path 1490Sstevel@tonic-gate * v_rdcnt, v_wrcnt 1500Sstevel@tonic-gate * v_mmap_read, v_mmap_write 1510Sstevel@tonic-gate */ 1520Sstevel@tonic-gate 1530Sstevel@tonic-gate /* 1540Sstevel@tonic-gate * vnode types. VNON means no type. These values are unrelated to 1550Sstevel@tonic-gate * values in on-disk inodes. 1560Sstevel@tonic-gate */ 1570Sstevel@tonic-gate typedef enum vtype { 1580Sstevel@tonic-gate VNON = 0, 1590Sstevel@tonic-gate VREG = 1, 1600Sstevel@tonic-gate VDIR = 2, 1610Sstevel@tonic-gate VBLK = 3, 1620Sstevel@tonic-gate VCHR = 4, 1630Sstevel@tonic-gate VLNK = 5, 1640Sstevel@tonic-gate VFIFO = 6, 1650Sstevel@tonic-gate VDOOR = 7, 1660Sstevel@tonic-gate VPROC = 8, 1670Sstevel@tonic-gate VSOCK = 9, 1680Sstevel@tonic-gate VPORT = 10, 1690Sstevel@tonic-gate VBAD = 11 1700Sstevel@tonic-gate } vtype_t; 1710Sstevel@tonic-gate 1720Sstevel@tonic-gate /* 1735050Sjwahlig * VSD - Vnode Specific Data 1745050Sjwahlig * Used to associate additional private data with a vnode. 1755050Sjwahlig */ 1765050Sjwahlig struct vsd_node { 1775050Sjwahlig list_node_t vs_nodes; /* list of all VSD nodes */ 1785050Sjwahlig uint_t vs_nkeys; /* entries in value array */ 1795050Sjwahlig void **vs_value; /* array of value/key */ 1805050Sjwahlig }; 1815050Sjwahlig 1825050Sjwahlig /* 1830Sstevel@tonic-gate * Many of the fields in the vnode are read-only once they are initialized 1840Sstevel@tonic-gate * at vnode creation time. Other fields are protected by locks. 1850Sstevel@tonic-gate * 1860Sstevel@tonic-gate * IMPORTANT: vnodes should be created ONLY by calls to vn_alloc(). They 1870Sstevel@tonic-gate * may not be embedded into the file-system specific node (inode). The 1880Sstevel@tonic-gate * size of vnodes may change. 1890Sstevel@tonic-gate * 1900Sstevel@tonic-gate * The v_lock protects: 1910Sstevel@tonic-gate * v_flag 1920Sstevel@tonic-gate * v_stream 1930Sstevel@tonic-gate * v_count 1940Sstevel@tonic-gate * v_shrlocks 1950Sstevel@tonic-gate * v_path 1965050Sjwahlig * v_vsd 1975331Samw * v_xattrdir 1980Sstevel@tonic-gate * 1990Sstevel@tonic-gate * A special lock (implemented by vn_vfswlock in vnode.c) protects: 2000Sstevel@tonic-gate * v_vfsmountedhere 2010Sstevel@tonic-gate * 2020Sstevel@tonic-gate * The global flock_lock mutex (in flock.c) protects: 2030Sstevel@tonic-gate * v_filocks 2040Sstevel@tonic-gate * 2050Sstevel@tonic-gate * IMPORTANT NOTE: 2060Sstevel@tonic-gate * 2070Sstevel@tonic-gate * The following vnode fields are considered public and may safely be 2080Sstevel@tonic-gate * accessed by file systems or other consumers: 2090Sstevel@tonic-gate * 2100Sstevel@tonic-gate * v_lock 2110Sstevel@tonic-gate * v_flag 2120Sstevel@tonic-gate * v_count 2130Sstevel@tonic-gate * v_data 2140Sstevel@tonic-gate * v_vfsp 2150Sstevel@tonic-gate * v_stream 2160Sstevel@tonic-gate * v_type 2170Sstevel@tonic-gate * v_rdev 2180Sstevel@tonic-gate * 2190Sstevel@tonic-gate * ALL OTHER FIELDS SHOULD BE ACCESSED ONLY BY THE OWNER OF THAT FIELD. 2200Sstevel@tonic-gate * In particular, file systems should not access other fields; they may 2210Sstevel@tonic-gate * change or even be removed. The functionality which was once provided 2220Sstevel@tonic-gate * by these fields is available through vn_* functions. 2230Sstevel@tonic-gate */ 2240Sstevel@tonic-gate 2250Sstevel@tonic-gate struct fem_head; /* from fem.h */ 2260Sstevel@tonic-gate 2270Sstevel@tonic-gate typedef struct vnode { 2280Sstevel@tonic-gate kmutex_t v_lock; /* protects vnode fields */ 2290Sstevel@tonic-gate uint_t v_flag; /* vnode flags (see below) */ 2300Sstevel@tonic-gate uint_t v_count; /* reference count */ 2310Sstevel@tonic-gate void *v_data; /* private data for fs */ 2320Sstevel@tonic-gate struct vfs *v_vfsp; /* ptr to containing VFS */ 2330Sstevel@tonic-gate struct stdata *v_stream; /* associated stream */ 2340Sstevel@tonic-gate enum vtype v_type; /* vnode type */ 2350Sstevel@tonic-gate dev_t v_rdev; /* device (VCHR, VBLK) */ 2360Sstevel@tonic-gate 2370Sstevel@tonic-gate /* PRIVATE FIELDS BELOW - DO NOT USE */ 2380Sstevel@tonic-gate 2390Sstevel@tonic-gate struct vfs *v_vfsmountedhere; /* ptr to vfs mounted here */ 2400Sstevel@tonic-gate struct vnodeops *v_op; /* vnode operations */ 2410Sstevel@tonic-gate struct page *v_pages; /* vnode pages list */ 2420Sstevel@tonic-gate struct filock *v_filocks; /* ptr to filock list */ 2430Sstevel@tonic-gate struct shrlocklist *v_shrlocks; /* ptr to shrlock list */ 2440Sstevel@tonic-gate krwlock_t v_nbllock; /* sync for NBMAND locks */ 2450Sstevel@tonic-gate kcondvar_t v_cv; /* synchronize locking */ 2460Sstevel@tonic-gate void *v_locality; /* hook for locality info */ 2470Sstevel@tonic-gate struct fem_head *v_femhead; /* fs monitoring */ 2480Sstevel@tonic-gate char *v_path; /* cached path */ 2490Sstevel@tonic-gate uint_t v_rdcnt; /* open for read count (VREG only) */ 2500Sstevel@tonic-gate uint_t v_wrcnt; /* open for write count (VREG only) */ 2510Sstevel@tonic-gate u_longlong_t v_mmap_read; /* mmap read count */ 2520Sstevel@tonic-gate u_longlong_t v_mmap_write; /* mmap write count */ 2530Sstevel@tonic-gate void *v_mpssdata; /* info for large page mappings */ 2544863Spraks void *v_fopdata; /* list of file ops event watches */ 2559885SRobert.Mastors@Sun.COM kmutex_t v_vsd_lock; /* protects v_vsd field */ 2565050Sjwahlig struct vsd_node *v_vsd; /* vnode specific data */ 2575331Samw struct vnode *v_xattrdir; /* unnamed extended attr dir (GFS) */ 2586712Stomee uint_t v_count_dnlc; /* dnlc reference count */ 2590Sstevel@tonic-gate } vnode_t; 2600Sstevel@tonic-gate 2610Sstevel@tonic-gate #define IS_DEVVP(vp) \ 2620Sstevel@tonic-gate ((vp)->v_type == VCHR || (vp)->v_type == VBLK || (vp)->v_type == VFIFO) 2630Sstevel@tonic-gate 26412230SFrank.Rival@oracle.com #define VNODE_ALIGN 64 26512230SFrank.Rival@oracle.com /* Count of low-order 0 bits in a vnode *, based on size and alignment. */ 26612268SFrank.Rival@oracle.com #if defined(_LP64) 26712230SFrank.Rival@oracle.com #define VNODE_ALIGN_LOG2 8 26812268SFrank.Rival@oracle.com #else 26912268SFrank.Rival@oracle.com #define VNODE_ALIGN_LOG2 7 27012268SFrank.Rival@oracle.com #endif 27112230SFrank.Rival@oracle.com 2720Sstevel@tonic-gate /* 2730Sstevel@tonic-gate * vnode flags. 2740Sstevel@tonic-gate */ 2750Sstevel@tonic-gate #define VROOT 0x01 /* root of its file system */ 2760Sstevel@tonic-gate #define VNOCACHE 0x02 /* don't keep cache pages on vnode */ 2770Sstevel@tonic-gate #define VNOMAP 0x04 /* file cannot be mapped/faulted */ 2780Sstevel@tonic-gate #define VDUP 0x08 /* file should be dup'ed rather then opened */ 2790Sstevel@tonic-gate #define VNOSWAP 0x10 /* file cannot be used as virtual swap device */ 2800Sstevel@tonic-gate #define VNOMOUNT 0x20 /* file cannot be covered by mount */ 2810Sstevel@tonic-gate #define VISSWAP 0x40 /* vnode is being used for swap */ 2820Sstevel@tonic-gate #define VSWAPLIKE 0x80 /* vnode acts like swap (but may not be) */ 2830Sstevel@tonic-gate 2840Sstevel@tonic-gate #define IS_SWAPVP(vp) (((vp)->v_flag & (VISSWAP | VSWAPLIKE)) != 0) 2850Sstevel@tonic-gate 2860Sstevel@tonic-gate typedef struct vn_vfslocks_entry { 2870Sstevel@tonic-gate rwstlock_t ve_lock; 2880Sstevel@tonic-gate void *ve_vpvfs; 2890Sstevel@tonic-gate struct vn_vfslocks_entry *ve_next; 2900Sstevel@tonic-gate uint32_t ve_refcnt; 2910Sstevel@tonic-gate char pad[64 - sizeof (rwstlock_t) - 2 * sizeof (void *) - \ 2920Sstevel@tonic-gate sizeof (uint32_t)]; 2930Sstevel@tonic-gate } vn_vfslocks_entry_t; 2940Sstevel@tonic-gate 2950Sstevel@tonic-gate /* 2960Sstevel@tonic-gate * The following two flags are used to lock the v_vfsmountedhere field 2970Sstevel@tonic-gate */ 2980Sstevel@tonic-gate #define VVFSLOCK 0x100 2990Sstevel@tonic-gate #define VVFSWAIT 0x200 3000Sstevel@tonic-gate 3010Sstevel@tonic-gate /* 3020Sstevel@tonic-gate * Used to serialize VM operations on a vnode 3030Sstevel@tonic-gate */ 3040Sstevel@tonic-gate #define VVMLOCK 0x400 3050Sstevel@tonic-gate 3060Sstevel@tonic-gate /* 3070Sstevel@tonic-gate * Tell vn_open() not to fail a directory open for writing but 3080Sstevel@tonic-gate * to go ahead and call VOP_OPEN() to let the filesystem check. 3090Sstevel@tonic-gate */ 3100Sstevel@tonic-gate #define VDIROPEN 0x800 3110Sstevel@tonic-gate 3120Sstevel@tonic-gate /* 3130Sstevel@tonic-gate * Flag to let the VM system know that this file is most likely a binary 3140Sstevel@tonic-gate * or shared library since it has been mmap()ed EXEC at some time. 3150Sstevel@tonic-gate */ 3160Sstevel@tonic-gate #define VVMEXEC 0x1000 3170Sstevel@tonic-gate 3180Sstevel@tonic-gate #define VPXFS 0x2000 /* clustering: global fs proxy vnode */ 3190Sstevel@tonic-gate 3200Sstevel@tonic-gate #define IS_PXFSVP(vp) ((vp)->v_flag & VPXFS) 3210Sstevel@tonic-gate 3220Sstevel@tonic-gate #define V_XATTRDIR 0x4000 /* attribute unnamed directory */ 3230Sstevel@tonic-gate 3246492Stimh #define IS_XATTRDIR(vp) ((vp)->v_flag & V_XATTRDIR) 3256492Stimh 3260Sstevel@tonic-gate #define V_LOCALITY 0x8000 /* whether locality aware */ 3270Sstevel@tonic-gate 3280Sstevel@tonic-gate /* 3290Sstevel@tonic-gate * Flag that indicates the VM should maintain the v_pages list with all modified 3300Sstevel@tonic-gate * pages on one end and unmodified pages at the other. This makes finding dirty 3310Sstevel@tonic-gate * pages to write back to disk much faster at the expense of taking a minor 3320Sstevel@tonic-gate * fault on the first store instruction which touches a writable page. 3330Sstevel@tonic-gate */ 3340Sstevel@tonic-gate #define VMODSORT (0x10000) 3350Sstevel@tonic-gate #define IS_VMODSORT(vp) \ 3360Sstevel@tonic-gate (pvn_vmodsort_supported != 0 && ((vp)->v_flag & VMODSORT) != 0) 3370Sstevel@tonic-gate 3380Sstevel@tonic-gate #define VISSWAPFS 0x20000 /* vnode is being used for swapfs */ 3399894SPavel.Tatashin@Sun.COM 3409894SPavel.Tatashin@Sun.COM /* 3419894SPavel.Tatashin@Sun.COM * The mdb memstat command assumes that IS_SWAPFSVP only uses the 3429894SPavel.Tatashin@Sun.COM * vnode's v_flag field. If this changes, cache the additional 3439894SPavel.Tatashin@Sun.COM * fields in mdb; see vn_get in mdb/common/modules/genunix/memory.c 3449894SPavel.Tatashin@Sun.COM */ 3450Sstevel@tonic-gate #define IS_SWAPFSVP(vp) (((vp)->v_flag & VISSWAPFS) != 0) 3460Sstevel@tonic-gate 3475331Samw #define V_SYSATTR 0x40000 /* vnode is a GFS system attribute */ 3485331Samw 3490Sstevel@tonic-gate /* 3500Sstevel@tonic-gate * Vnode attributes. A bit-mask is supplied as part of the 3510Sstevel@tonic-gate * structure to indicate the attributes the caller wants to 3520Sstevel@tonic-gate * set (setattr) or extract (getattr). 3530Sstevel@tonic-gate */ 3540Sstevel@tonic-gate 3550Sstevel@tonic-gate /* 3560Sstevel@tonic-gate * Note that va_nodeid and va_nblocks are 64bit data type. 3570Sstevel@tonic-gate * We support large files over NFSV3. With Solaris client and 3580Sstevel@tonic-gate * Server that generates 64bit ino's and sizes these fields 3590Sstevel@tonic-gate * will overflow if they are 32 bit sizes. 3600Sstevel@tonic-gate */ 3610Sstevel@tonic-gate 3620Sstevel@tonic-gate typedef struct vattr { 3630Sstevel@tonic-gate uint_t va_mask; /* bit-mask of attributes */ 3640Sstevel@tonic-gate vtype_t va_type; /* vnode type (for create) */ 3650Sstevel@tonic-gate mode_t va_mode; /* file access mode */ 3660Sstevel@tonic-gate uid_t va_uid; /* owner user id */ 3670Sstevel@tonic-gate gid_t va_gid; /* owner group id */ 3680Sstevel@tonic-gate dev_t va_fsid; /* file system id (dev for now) */ 3690Sstevel@tonic-gate u_longlong_t va_nodeid; /* node id */ 3700Sstevel@tonic-gate nlink_t va_nlink; /* number of references to file */ 3710Sstevel@tonic-gate u_offset_t va_size; /* file size in bytes */ 3720Sstevel@tonic-gate timestruc_t va_atime; /* time of last access */ 3730Sstevel@tonic-gate timestruc_t va_mtime; /* time of last modification */ 3740Sstevel@tonic-gate timestruc_t va_ctime; /* time of last status change */ 3750Sstevel@tonic-gate dev_t va_rdev; /* device the file represents */ 3760Sstevel@tonic-gate uint_t va_blksize; /* fundamental block size */ 3770Sstevel@tonic-gate u_longlong_t va_nblocks; /* # of blocks allocated */ 3780Sstevel@tonic-gate uint_t va_seq; /* sequence number */ 3790Sstevel@tonic-gate } vattr_t; 3800Sstevel@tonic-gate 3815331Samw #define AV_SCANSTAMP_SZ 32 /* length of anti-virus scanstamp */ 3825331Samw 3835331Samw /* 3845331Samw * Structure of all optional attributes. 3855331Samw */ 3865331Samw typedef struct xoptattr { 3875331Samw timestruc_t xoa_createtime; /* Create time of file */ 3885331Samw uint8_t xoa_archive; 3895331Samw uint8_t xoa_system; 3905331Samw uint8_t xoa_readonly; 3915331Samw uint8_t xoa_hidden; 3925331Samw uint8_t xoa_nounlink; 3935331Samw uint8_t xoa_immutable; 3945331Samw uint8_t xoa_appendonly; 3955331Samw uint8_t xoa_nodump; 3965331Samw uint8_t xoa_opaque; 3975331Samw uint8_t xoa_av_quarantined; 3985331Samw uint8_t xoa_av_modified; 3995331Samw uint8_t xoa_av_scanstamp[AV_SCANSTAMP_SZ]; 40010793Sdai.ngo@sun.com uint8_t xoa_reparse; 40113043STim.Haley@Sun.COM uint64_t xoa_generation; 402*13082SJoyce.McIntosh@Sun.COM uint8_t xoa_offline; 403*13082SJoyce.McIntosh@Sun.COM uint8_t xoa_sparse; 4045331Samw } xoptattr_t; 4055331Samw 4065331Samw /* 4075331Samw * The xvattr structure is really a variable length structure that 4085331Samw * is made up of: 4095331Samw * - The classic vattr_t (xva_vattr) 4105331Samw * - a 32 bit quantity (xva_mapsize) that specifies the size of the 4115331Samw * attribute bitmaps in 32 bit words. 4125331Samw * - A pointer to the returned attribute bitmap (needed because the 4135331Samw * previous element, the requested attribute bitmap) is variable lenth. 4145331Samw * - The requested attribute bitmap, which is an array of 32 bit words. 4155331Samw * Callers use the XVA_SET_REQ() macro to set the bits corresponding to 4165331Samw * the attributes that are being requested. 4175331Samw * - The returned attribute bitmap, which is an array of 32 bit words. 4185331Samw * File systems that support optional attributes use the XVA_SET_RTN() 4195331Samw * macro to set the bits corresponding to the attributes that are being 4205331Samw * returned. 4215331Samw * - The xoptattr_t structure which contains the attribute values 4225331Samw * 4235331Samw * xva_mapsize determines how many words in the attribute bitmaps. 4245331Samw * Immediately following the attribute bitmaps is the xoptattr_t. 4255331Samw * xva_getxoptattr() is used to get the pointer to the xoptattr_t 4265331Samw * section. 4275331Samw */ 4285331Samw 4295331Samw #define XVA_MAPSIZE 3 /* Size of attr bitmaps */ 4305331Samw #define XVA_MAGIC 0x78766174 /* Magic # for verification */ 4315331Samw 4325331Samw /* 4335331Samw * The xvattr structure is an extensible structure which permits optional 4345331Samw * attributes to be requested/returned. File systems may or may not support 4355331Samw * optional attributes. They do so at their own discretion but if they do 4365331Samw * support optional attributes, they must register the VFSFT_XVATTR feature 4375331Samw * so that the optional attributes can be set/retrived. 4385331Samw * 4395331Samw * The fields of the xvattr structure are: 4405331Samw * 4415331Samw * xva_vattr - The first element of an xvattr is a legacy vattr structure 4425331Samw * which includes the common attributes. If AT_XVATTR is set in the va_mask 4435331Samw * then the entire structure is treated as an xvattr. If AT_XVATTR is not 4445331Samw * set, then only the xva_vattr structure can be used. 4455331Samw * 4465331Samw * xva_magic - 0x78766174 (hex for "xvat"). Magic number for verification. 4475331Samw * 4485331Samw * xva_mapsize - Size of requested and returned attribute bitmaps. 4495331Samw * 4505331Samw * xva_rtnattrmapp - Pointer to xva_rtnattrmap[]. We need this since the 4515331Samw * size of the array before it, xva_reqattrmap[], could change which means 4525331Samw * the location of xva_rtnattrmap[] could change. This will allow unbundled 4535331Samw * file systems to find the location of xva_rtnattrmap[] when the sizes change. 4545331Samw * 4555331Samw * xva_reqattrmap[] - Array of requested attributes. Attributes are 4565331Samw * represented by a specific bit in a specific element of the attribute 4575331Samw * map array. Callers set the bits corresponding to the attributes 4585331Samw * that the caller wants to get/set. 4595331Samw * 4605331Samw * xva_rtnattrmap[] - Array of attributes that the file system was able to 4615331Samw * process. Not all file systems support all optional attributes. This map 4625331Samw * informs the caller which attributes the underlying file system was able 4635331Samw * to set/get. (Same structure as the requested attributes array in terms 4645331Samw * of each attribute corresponding to specific bits and array elements.) 4655331Samw * 4665331Samw * xva_xoptattrs - Structure containing values of optional attributes. 4675331Samw * These values are only valid if the corresponding bits in xva_reqattrmap 4685331Samw * are set and the underlying file system supports those attributes. 4695331Samw */ 4705331Samw typedef struct xvattr { 4715331Samw vattr_t xva_vattr; /* Embedded vattr structure */ 4725331Samw uint32_t xva_magic; /* Magic Number */ 4735331Samw uint32_t xva_mapsize; /* Size of attr bitmap (32-bit words) */ 4745331Samw uint32_t *xva_rtnattrmapp; /* Ptr to xva_rtnattrmap[] */ 4755331Samw uint32_t xva_reqattrmap[XVA_MAPSIZE]; /* Requested attrs */ 4765331Samw uint32_t xva_rtnattrmap[XVA_MAPSIZE]; /* Returned attrs */ 4775331Samw xoptattr_t xva_xoptattrs; /* Optional attributes */ 4785331Samw } xvattr_t; 4795331Samw 4800Sstevel@tonic-gate #ifdef _SYSCALL32 4810Sstevel@tonic-gate /* 4820Sstevel@tonic-gate * For bigtypes time_t changed to 64 bit on the 64-bit kernel. 4830Sstevel@tonic-gate * Define an old version for user/kernel interface 4840Sstevel@tonic-gate */ 4850Sstevel@tonic-gate 4860Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 4870Sstevel@tonic-gate #pragma pack(4) 4880Sstevel@tonic-gate #endif 4890Sstevel@tonic-gate 4900Sstevel@tonic-gate typedef struct vattr32 { 4910Sstevel@tonic-gate uint32_t va_mask; /* bit-mask of attributes */ 4920Sstevel@tonic-gate vtype_t va_type; /* vnode type (for create) */ 4930Sstevel@tonic-gate mode32_t va_mode; /* file access mode */ 4940Sstevel@tonic-gate uid32_t va_uid; /* owner user id */ 4950Sstevel@tonic-gate gid32_t va_gid; /* owner group id */ 4960Sstevel@tonic-gate dev32_t va_fsid; /* file system id (dev for now) */ 4970Sstevel@tonic-gate u_longlong_t va_nodeid; /* node id */ 4980Sstevel@tonic-gate nlink_t va_nlink; /* number of references to file */ 4990Sstevel@tonic-gate u_offset_t va_size; /* file size in bytes */ 5000Sstevel@tonic-gate timestruc32_t va_atime; /* time of last access */ 5010Sstevel@tonic-gate timestruc32_t va_mtime; /* time of last modification */ 5020Sstevel@tonic-gate timestruc32_t va_ctime; /* time of last status change */ 5030Sstevel@tonic-gate dev32_t va_rdev; /* device the file represents */ 5040Sstevel@tonic-gate uint32_t va_blksize; /* fundamental block size */ 5050Sstevel@tonic-gate u_longlong_t va_nblocks; /* # of blocks allocated */ 5060Sstevel@tonic-gate uint32_t va_seq; /* sequence number */ 5070Sstevel@tonic-gate } vattr32_t; 5080Sstevel@tonic-gate 5090Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 5100Sstevel@tonic-gate #pragma pack() 5110Sstevel@tonic-gate #endif 5120Sstevel@tonic-gate 5130Sstevel@tonic-gate #else /* not _SYSCALL32 */ 5140Sstevel@tonic-gate #define vattr32 vattr 5150Sstevel@tonic-gate typedef vattr_t vattr32_t; 5160Sstevel@tonic-gate #endif /* _SYSCALL32 */ 5170Sstevel@tonic-gate 5180Sstevel@tonic-gate /* 5190Sstevel@tonic-gate * Attributes of interest to the caller of setattr or getattr. 5200Sstevel@tonic-gate */ 5215331Samw #define AT_TYPE 0x00001 5225331Samw #define AT_MODE 0x00002 5235331Samw #define AT_UID 0x00004 5245331Samw #define AT_GID 0x00008 5255331Samw #define AT_FSID 0x00010 5265331Samw #define AT_NODEID 0x00020 5275331Samw #define AT_NLINK 0x00040 5285331Samw #define AT_SIZE 0x00080 5295331Samw #define AT_ATIME 0x00100 5305331Samw #define AT_MTIME 0x00200 5315331Samw #define AT_CTIME 0x00400 5325331Samw #define AT_RDEV 0x00800 5335331Samw #define AT_BLKSIZE 0x01000 5345331Samw #define AT_NBLOCKS 0x02000 5355331Samw /* 0x04000 */ /* unused */ 5365331Samw #define AT_SEQ 0x08000 5375331Samw /* 5385331Samw * If AT_XVATTR is set then there are additional bits to process in 5395331Samw * the xvattr_t's attribute bitmap. If this is not set then the bitmap 5405331Samw * MUST be ignored. Note that this bit must be set/cleared explicitly. 5415331Samw * That is, setting AT_ALL will NOT set AT_XVATTR. 5425331Samw */ 5435331Samw #define AT_XVATTR 0x10000 5440Sstevel@tonic-gate 5450Sstevel@tonic-gate #define AT_ALL (AT_TYPE|AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|\ 5460Sstevel@tonic-gate AT_NLINK|AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|\ 5470Sstevel@tonic-gate AT_RDEV|AT_BLKSIZE|AT_NBLOCKS|AT_SEQ) 5480Sstevel@tonic-gate 5490Sstevel@tonic-gate #define AT_STAT (AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|AT_NLINK|\ 5500Sstevel@tonic-gate AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|AT_RDEV|AT_TYPE) 5510Sstevel@tonic-gate 5520Sstevel@tonic-gate #define AT_TIMES (AT_ATIME|AT_MTIME|AT_CTIME) 5530Sstevel@tonic-gate 5540Sstevel@tonic-gate #define AT_NOSET (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\ 5550Sstevel@tonic-gate AT_BLKSIZE|AT_NBLOCKS|AT_SEQ) 5560Sstevel@tonic-gate 5570Sstevel@tonic-gate /* 5585331Samw * Attribute bits used in the extensible attribute's (xva's) attribute 5595331Samw * bitmaps. Note that the bitmaps are made up of a variable length number 5605331Samw * of 32-bit words. The convention is to use XAT{n}_{attrname} where "n" 5615331Samw * is the element in the bitmap (starting at 1). This convention is for 5625331Samw * the convenience of the maintainer to keep track of which element each 5635331Samw * attribute belongs to. 5645331Samw * 5655331Samw * NOTE THAT CONSUMERS MUST *NOT* USE THE XATn_* DEFINES DIRECTLY. CONSUMERS 5665331Samw * MUST USE THE XAT_* DEFINES. 5675331Samw */ 5685331Samw #define XAT0_INDEX 0LL /* Index into bitmap for XAT0 attrs */ 5695331Samw #define XAT0_CREATETIME 0x00000001 /* Create time of file */ 5705331Samw #define XAT0_ARCHIVE 0x00000002 /* Archive */ 5715331Samw #define XAT0_SYSTEM 0x00000004 /* System */ 5725331Samw #define XAT0_READONLY 0x00000008 /* Readonly */ 5735331Samw #define XAT0_HIDDEN 0x00000010 /* Hidden */ 5745331Samw #define XAT0_NOUNLINK 0x00000020 /* Nounlink */ 5755331Samw #define XAT0_IMMUTABLE 0x00000040 /* immutable */ 5765331Samw #define XAT0_APPENDONLY 0x00000080 /* appendonly */ 5775331Samw #define XAT0_NODUMP 0x00000100 /* nodump */ 5785331Samw #define XAT0_OPAQUE 0x00000200 /* opaque */ 5795331Samw #define XAT0_AV_QUARANTINED 0x00000400 /* anti-virus quarantine */ 5805331Samw #define XAT0_AV_MODIFIED 0x00000800 /* anti-virus modified */ 5815331Samw #define XAT0_AV_SCANSTAMP 0x00001000 /* anti-virus scanstamp */ 58210793Sdai.ngo@sun.com #define XAT0_REPARSE 0x00002000 /* FS reparse point */ 58313043STim.Haley@Sun.COM #define XAT0_GEN 0x00004000 /* object generation number */ 584*13082SJoyce.McIntosh@Sun.COM #define XAT0_OFFLINE 0x00008000 /* offline */ 585*13082SJoyce.McIntosh@Sun.COM #define XAT0_SPARSE 0x00010000 /* sparse */ 5865331Samw 5875331Samw #define XAT0_ALL_ATTRS (XAT0_CREATETIME|XAT0_ARCHIVE|XAT0_SYSTEM| \ 5885331Samw XAT0_READONLY|XAT0_HIDDEN|XAT0_NOUNLINK|XAT0_IMMUTABLE|XAT0_APPENDONLY| \ 589*13082SJoyce.McIntosh@Sun.COM XAT0_NODUMP|XAT0_OPAQUE|XAT0_AV_QUARANTINED| XAT0_AV_MODIFIED| \ 590*13082SJoyce.McIntosh@Sun.COM XAT0_AV_SCANSTAMP|XAT0_REPARSE|XATO_GEN|XAT0_OFFLINE|XAT0_SPARSE) 5915331Samw 5925331Samw /* Support for XAT_* optional attributes */ 5935331Samw #define XVA_MASK 0xffffffff /* Used to mask off 32 bits */ 5945331Samw #define XVA_SHFT 32 /* Used to shift index */ 5955331Samw 5965331Samw /* 5975331Samw * Used to pry out the index and attribute bits from the XAT_* attributes 5985331Samw * defined below. Note that we're masking things down to 32 bits then 5995331Samw * casting to uint32_t. 6005331Samw */ 6015331Samw #define XVA_INDEX(attr) ((uint32_t)(((attr) >> XVA_SHFT) & XVA_MASK)) 6025331Samw #define XVA_ATTRBIT(attr) ((uint32_t)((attr) & XVA_MASK)) 6035331Samw 6045331Samw /* 6055331Samw * The following defines present a "flat namespace" so that consumers don't 6065331Samw * need to keep track of which element belongs to which bitmap entry. 6075331Samw * 6085331Samw * NOTE THAT THESE MUST NEVER BE OR-ed TOGETHER 6095331Samw */ 6105331Samw #define XAT_CREATETIME ((XAT0_INDEX << XVA_SHFT) | XAT0_CREATETIME) 6115331Samw #define XAT_ARCHIVE ((XAT0_INDEX << XVA_SHFT) | XAT0_ARCHIVE) 6125331Samw #define XAT_SYSTEM ((XAT0_INDEX << XVA_SHFT) | XAT0_SYSTEM) 6135331Samw #define XAT_READONLY ((XAT0_INDEX << XVA_SHFT) | XAT0_READONLY) 6145331Samw #define XAT_HIDDEN ((XAT0_INDEX << XVA_SHFT) | XAT0_HIDDEN) 6155331Samw #define XAT_NOUNLINK ((XAT0_INDEX << XVA_SHFT) | XAT0_NOUNLINK) 6165331Samw #define XAT_IMMUTABLE ((XAT0_INDEX << XVA_SHFT) | XAT0_IMMUTABLE) 6175331Samw #define XAT_APPENDONLY ((XAT0_INDEX << XVA_SHFT) | XAT0_APPENDONLY) 6185331Samw #define XAT_NODUMP ((XAT0_INDEX << XVA_SHFT) | XAT0_NODUMP) 6195331Samw #define XAT_OPAQUE ((XAT0_INDEX << XVA_SHFT) | XAT0_OPAQUE) 6205331Samw #define XAT_AV_QUARANTINED ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_QUARANTINED) 6215331Samw #define XAT_AV_MODIFIED ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_MODIFIED) 6225331Samw #define XAT_AV_SCANSTAMP ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_SCANSTAMP) 62310793Sdai.ngo@sun.com #define XAT_REPARSE ((XAT0_INDEX << XVA_SHFT) | XAT0_REPARSE) 62413043STim.Haley@Sun.COM #define XAT_GEN ((XAT0_INDEX << XVA_SHFT) | XAT0_GEN) 625*13082SJoyce.McIntosh@Sun.COM #define XAT_OFFLINE ((XAT0_INDEX << XVA_SHFT) | XAT0_OFFLINE) 626*13082SJoyce.McIntosh@Sun.COM #define XAT_SPARSE ((XAT0_INDEX << XVA_SHFT) | XAT0_SPARSE) 6275331Samw 6285331Samw /* 6295331Samw * The returned attribute map array (xva_rtnattrmap[]) is located past the 6305331Samw * requested attribute map array (xva_reqattrmap[]). Its location changes 6315331Samw * when the array sizes change. We use a separate pointer in a known location 6325331Samw * (xva_rtnattrmapp) to hold the location of xva_rtnattrmap[]. This is 6335331Samw * set in xva_init() 6345331Samw */ 6355331Samw #define XVA_RTNATTRMAP(xvap) ((xvap)->xva_rtnattrmapp) 6365331Samw 6375331Samw /* 6385331Samw * XVA_SET_REQ() sets an attribute bit in the proper element in the bitmap 6395331Samw * of requested attributes (xva_reqattrmap[]). 6405331Samw */ 6415331Samw #define XVA_SET_REQ(xvap, attr) \ 6425331Samw ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR); \ 6435331Samw ASSERT((xvap)->xva_magic == XVA_MAGIC); \ 6445331Samw (xvap)->xva_reqattrmap[XVA_INDEX(attr)] |= XVA_ATTRBIT(attr) 6458190SMark.Shellenbaum@Sun.COM /* 6468190SMark.Shellenbaum@Sun.COM * XVA_CLR_REQ() clears an attribute bit in the proper element in the bitmap 6478190SMark.Shellenbaum@Sun.COM * of requested attributes (xva_reqattrmap[]). 6488190SMark.Shellenbaum@Sun.COM */ 6498190SMark.Shellenbaum@Sun.COM #define XVA_CLR_REQ(xvap, attr) \ 6508190SMark.Shellenbaum@Sun.COM ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR); \ 6518190SMark.Shellenbaum@Sun.COM ASSERT((xvap)->xva_magic == XVA_MAGIC); \ 6528190SMark.Shellenbaum@Sun.COM (xvap)->xva_reqattrmap[XVA_INDEX(attr)] &= ~XVA_ATTRBIT(attr) 6535331Samw 6545331Samw /* 6555331Samw * XVA_SET_RTN() sets an attribute bit in the proper element in the bitmap 6565331Samw * of returned attributes (xva_rtnattrmap[]). 6575331Samw */ 6585331Samw #define XVA_SET_RTN(xvap, attr) \ 6595331Samw ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR); \ 6605331Samw ASSERT((xvap)->xva_magic == XVA_MAGIC); \ 6615331Samw (XVA_RTNATTRMAP(xvap))[XVA_INDEX(attr)] |= XVA_ATTRBIT(attr) 6625331Samw 6635331Samw /* 6645331Samw * XVA_ISSET_REQ() checks the requested attribute bitmap (xva_reqattrmap[]) 6655331Samw * to see of the corresponding attribute bit is set. If so, returns non-zero. 6665331Samw */ 6675331Samw #define XVA_ISSET_REQ(xvap, attr) \ 6685331Samw ((((xvap)->xva_vattr.va_mask | AT_XVATTR) && \ 6695331Samw ((xvap)->xva_magic == XVA_MAGIC) && \ 6705331Samw ((xvap)->xva_mapsize > XVA_INDEX(attr))) ? \ 6715331Samw ((xvap)->xva_reqattrmap[XVA_INDEX(attr)] & XVA_ATTRBIT(attr)) : 0) 6725331Samw 6735331Samw /* 6745331Samw * XVA_ISSET_RTN() checks the returned attribute bitmap (xva_rtnattrmap[]) 6755331Samw * to see of the corresponding attribute bit is set. If so, returns non-zero. 6765331Samw */ 6775331Samw #define XVA_ISSET_RTN(xvap, attr) \ 6785331Samw ((((xvap)->xva_vattr.va_mask | AT_XVATTR) && \ 6795331Samw ((xvap)->xva_magic == XVA_MAGIC) && \ 6805331Samw ((xvap)->xva_mapsize > XVA_INDEX(attr))) ? \ 6815331Samw ((XVA_RTNATTRMAP(xvap))[XVA_INDEX(attr)] & XVA_ATTRBIT(attr)) : 0) 6825331Samw 6835331Samw /* 6840Sstevel@tonic-gate * Modes. Some values same as S_xxx entries from stat.h for convenience. 6850Sstevel@tonic-gate */ 6860Sstevel@tonic-gate #define VSUID 04000 /* set user id on execution */ 6870Sstevel@tonic-gate #define VSGID 02000 /* set group id on execution */ 6880Sstevel@tonic-gate #define VSVTX 01000 /* save swapped text even after use */ 6890Sstevel@tonic-gate 6900Sstevel@tonic-gate /* 6910Sstevel@tonic-gate * Permissions. 6920Sstevel@tonic-gate */ 6930Sstevel@tonic-gate #define VREAD 00400 6940Sstevel@tonic-gate #define VWRITE 00200 6950Sstevel@tonic-gate #define VEXEC 00100 6960Sstevel@tonic-gate 6970Sstevel@tonic-gate #define MODEMASK 07777 /* mode bits plus permission bits */ 6980Sstevel@tonic-gate #define PERMMASK 00777 /* permission bits */ 6990Sstevel@tonic-gate 7000Sstevel@tonic-gate /* 7015331Samw * VOP_ACCESS flags 7025331Samw */ 7035331Samw #define V_ACE_MASK 0x1 /* mask represents NFSv4 ACE permissions */ 7045331Samw #define V_APPEND 0x2 /* want to do append only check */ 7055331Samw 7065331Samw /* 7070Sstevel@tonic-gate * Check whether mandatory file locking is enabled. 7080Sstevel@tonic-gate */ 7090Sstevel@tonic-gate 7100Sstevel@tonic-gate #define MANDMODE(mode) (((mode) & (VSGID|(VEXEC>>3))) == VSGID) 7110Sstevel@tonic-gate #define MANDLOCK(vp, mode) ((vp)->v_type == VREG && MANDMODE(mode)) 7120Sstevel@tonic-gate 7130Sstevel@tonic-gate /* 7140Sstevel@tonic-gate * Flags for vnode operations. 7150Sstevel@tonic-gate */ 7160Sstevel@tonic-gate enum rm { RMFILE, RMDIRECTORY }; /* rm or rmdir (remove) */ 7170Sstevel@tonic-gate enum symfollow { NO_FOLLOW, FOLLOW }; /* follow symlinks (or not) */ 7180Sstevel@tonic-gate enum vcexcl { NONEXCL, EXCL }; /* (non)excl create */ 7190Sstevel@tonic-gate enum create { CRCREAT, CRMKNOD, CRMKDIR }; /* reason for create */ 7200Sstevel@tonic-gate 7210Sstevel@tonic-gate typedef enum rm rm_t; 7220Sstevel@tonic-gate typedef enum symfollow symfollow_t; 7230Sstevel@tonic-gate typedef enum vcexcl vcexcl_t; 7240Sstevel@tonic-gate typedef enum create create_t; 7250Sstevel@tonic-gate 7260Sstevel@tonic-gate /* Vnode Events - Used by VOP_VNEVENT */ 7270Sstevel@tonic-gate typedef enum vnevent { 7280Sstevel@tonic-gate VE_SUPPORT = 0, /* Query */ 7290Sstevel@tonic-gate VE_RENAME_SRC = 1, /* Rename, with vnode as source */ 7300Sstevel@tonic-gate VE_RENAME_DEST = 2, /* Rename, with vnode as target/destination */ 7310Sstevel@tonic-gate VE_REMOVE = 3, /* Remove of vnode's name */ 7324863Spraks VE_RMDIR = 4, /* Remove of directory vnode's name */ 7334863Spraks VE_CREATE = 5, /* Create with vnode's name which exists */ 7344863Spraks VE_LINK = 6, /* Link with vnode's name as source */ 7354863Spraks VE_RENAME_DEST_DIR = 7, /* Rename with vnode as target dir */ 7364863Spraks VE_MOUNTEDOVER = 8 /* File or Filesystem got mounted over vnode */ 7370Sstevel@tonic-gate } vnevent_t; 7380Sstevel@tonic-gate 7390Sstevel@tonic-gate /* 7400Sstevel@tonic-gate * Values for checking vnode open and map counts 7410Sstevel@tonic-gate */ 7420Sstevel@tonic-gate enum v_mode { V_READ, V_WRITE, V_RDORWR, V_RDANDWR }; 7430Sstevel@tonic-gate 7440Sstevel@tonic-gate typedef enum v_mode v_mode_t; 7450Sstevel@tonic-gate 7460Sstevel@tonic-gate #define V_TRUE 1 7470Sstevel@tonic-gate #define V_FALSE 0 7480Sstevel@tonic-gate 7490Sstevel@tonic-gate /* 7500Sstevel@tonic-gate * Structure used on VOP_GETSECATTR and VOP_SETSECATTR operations 7510Sstevel@tonic-gate */ 7520Sstevel@tonic-gate 7530Sstevel@tonic-gate typedef struct vsecattr { 7540Sstevel@tonic-gate uint_t vsa_mask; /* See below */ 7550Sstevel@tonic-gate int vsa_aclcnt; /* ACL entry count */ 7560Sstevel@tonic-gate void *vsa_aclentp; /* pointer to ACL entries */ 7570Sstevel@tonic-gate int vsa_dfaclcnt; /* default ACL entry count */ 7580Sstevel@tonic-gate void *vsa_dfaclentp; /* pointer to default ACL entries */ 7595331Samw size_t vsa_aclentsz; /* ACE size in bytes of vsa_aclentp */ 7605331Samw uint_t vsa_aclflags; /* ACE ACL flags */ 7610Sstevel@tonic-gate } vsecattr_t; 7620Sstevel@tonic-gate 7630Sstevel@tonic-gate /* vsa_mask values */ 7645331Samw #define VSA_ACL 0x0001 7655331Samw #define VSA_ACLCNT 0x0002 7665331Samw #define VSA_DFACL 0x0004 7675331Samw #define VSA_DFACLCNT 0x0008 7685331Samw #define VSA_ACE 0x0010 7695331Samw #define VSA_ACECNT 0x0020 7705331Samw #define VSA_ACE_ALLTYPES 0x0040 7715331Samw #define VSA_ACE_ACLFLAGS 0x0080 /* get/set ACE ACL flags */ 7720Sstevel@tonic-gate 7730Sstevel@tonic-gate /* 7740Sstevel@tonic-gate * Structure used by various vnode operations to determine 7750Sstevel@tonic-gate * the context (pid, host, identity) of a caller. 7760Sstevel@tonic-gate * 7770Sstevel@tonic-gate * The cc_caller_id is used to identify one or more callers who invoke 7780Sstevel@tonic-gate * operations, possibly on behalf of others. For example, the NFS 7790Sstevel@tonic-gate * server could have it's own cc_caller_id which can be detected by 7800Sstevel@tonic-gate * vnode/vfs operations or (FEM) monitors on those operations. New 7810Sstevel@tonic-gate * caller IDs are generated by fs_new_caller_id(). 7820Sstevel@tonic-gate */ 7830Sstevel@tonic-gate typedef struct caller_context { 7840Sstevel@tonic-gate pid_t cc_pid; /* Process ID of the caller */ 7850Sstevel@tonic-gate int cc_sysid; /* System ID, used for remote calls */ 7860Sstevel@tonic-gate u_longlong_t cc_caller_id; /* Identifier for (set of) caller(s) */ 7875599Sjwahlig ulong_t cc_flags; 7880Sstevel@tonic-gate } caller_context_t; 7890Sstevel@tonic-gate 7900Sstevel@tonic-gate /* 7915599Sjwahlig * Flags for caller context. The caller sets CC_DONTBLOCK if it does not 7925599Sjwahlig * want to block inside of a FEM monitor. The monitor will set CC_WOULDBLOCK 7935599Sjwahlig * and return EAGAIN if the operation would have blocked. 7945599Sjwahlig */ 7955599Sjwahlig #define CC_WOULDBLOCK 0x01 7965599Sjwahlig #define CC_DONTBLOCK 0x02 7975599Sjwahlig 7985599Sjwahlig /* 7990Sstevel@tonic-gate * Structure tags for function prototypes, defined elsewhere. 8000Sstevel@tonic-gate */ 8010Sstevel@tonic-gate struct pathname; 8020Sstevel@tonic-gate struct fid; 8030Sstevel@tonic-gate struct flock64; 8040Sstevel@tonic-gate struct flk_callback; 8050Sstevel@tonic-gate struct shrlock; 8060Sstevel@tonic-gate struct page; 8070Sstevel@tonic-gate struct seg; 8080Sstevel@tonic-gate struct as; 8090Sstevel@tonic-gate struct pollhead; 8109321SNeil.Perrin@Sun.COM struct taskq; 8110Sstevel@tonic-gate 8123898Srsb #ifdef _KERNEL 8133898Srsb 8140Sstevel@tonic-gate /* 8153898Srsb * VNODE_OPS defines all the vnode operations. It is used to define 8163898Srsb * the vnodeops structure (below) and the fs_func_p union (vfs_opreg.h). 8173898Srsb */ 8183898Srsb #define VNODE_OPS \ 8195331Samw int (*vop_open)(vnode_t **, int, cred_t *, \ 8205331Samw caller_context_t *); \ 8215331Samw int (*vop_close)(vnode_t *, int, int, offset_t, cred_t *, \ 8225331Samw caller_context_t *); \ 8233898Srsb int (*vop_read)(vnode_t *, uio_t *, int, cred_t *, \ 8243898Srsb caller_context_t *); \ 8253898Srsb int (*vop_write)(vnode_t *, uio_t *, int, cred_t *, \ 8263898Srsb caller_context_t *); \ 8273898Srsb int (*vop_ioctl)(vnode_t *, int, intptr_t, int, cred_t *, \ 8285331Samw int *, caller_context_t *); \ 8295331Samw int (*vop_setfl)(vnode_t *, int, int, cred_t *, \ 8305331Samw caller_context_t *); \ 8315331Samw int (*vop_getattr)(vnode_t *, vattr_t *, int, cred_t *, \ 8325331Samw caller_context_t *); \ 8333898Srsb int (*vop_setattr)(vnode_t *, vattr_t *, int, cred_t *, \ 8343898Srsb caller_context_t *); \ 8355331Samw int (*vop_access)(vnode_t *, int, int, cred_t *, \ 8365331Samw caller_context_t *); \ 8373898Srsb int (*vop_lookup)(vnode_t *, char *, vnode_t **, \ 8383898Srsb struct pathname *, \ 8395331Samw int, vnode_t *, cred_t *, \ 8405331Samw caller_context_t *, int *, \ 8415331Samw struct pathname *); \ 8423898Srsb int (*vop_create)(vnode_t *, char *, vattr_t *, vcexcl_t, \ 8435331Samw int, vnode_t **, cred_t *, int, \ 8445331Samw caller_context_t *, vsecattr_t *); \ 8455331Samw int (*vop_remove)(vnode_t *, char *, cred_t *, \ 8465331Samw caller_context_t *, int); \ 8475331Samw int (*vop_link)(vnode_t *, vnode_t *, char *, cred_t *, \ 8485331Samw caller_context_t *, int); \ 8493898Srsb int (*vop_rename)(vnode_t *, char *, vnode_t *, char *, \ 8505331Samw cred_t *, caller_context_t *, int); \ 8513898Srsb int (*vop_mkdir)(vnode_t *, char *, vattr_t *, vnode_t **, \ 8525331Samw cred_t *, caller_context_t *, int, \ 8535331Samw vsecattr_t *); \ 8545331Samw int (*vop_rmdir)(vnode_t *, char *, vnode_t *, cred_t *, \ 8555331Samw caller_context_t *, int); \ 8565331Samw int (*vop_readdir)(vnode_t *, uio_t *, cred_t *, int *, \ 8575331Samw caller_context_t *, int); \ 8583898Srsb int (*vop_symlink)(vnode_t *, char *, vattr_t *, char *, \ 8595331Samw cred_t *, caller_context_t *, int); \ 8605331Samw int (*vop_readlink)(vnode_t *, uio_t *, cred_t *, \ 8615331Samw caller_context_t *); \ 8625331Samw int (*vop_fsync)(vnode_t *, int, cred_t *, \ 8635331Samw caller_context_t *); \ 8645331Samw void (*vop_inactive)(vnode_t *, cred_t *, \ 8655331Samw caller_context_t *); \ 8665331Samw int (*vop_fid)(vnode_t *, struct fid *, \ 8675331Samw caller_context_t *); \ 8683898Srsb int (*vop_rwlock)(vnode_t *, int, caller_context_t *); \ 8693898Srsb void (*vop_rwunlock)(vnode_t *, int, caller_context_t *); \ 8705331Samw int (*vop_seek)(vnode_t *, offset_t, offset_t *, \ 8715331Samw caller_context_t *); \ 8725331Samw int (*vop_cmp)(vnode_t *, vnode_t *, caller_context_t *); \ 8733898Srsb int (*vop_frlock)(vnode_t *, int, struct flock64 *, \ 8743898Srsb int, offset_t, \ 8755331Samw struct flk_callback *, cred_t *, \ 8765331Samw caller_context_t *); \ 8773898Srsb int (*vop_space)(vnode_t *, int, struct flock64 *, \ 8783898Srsb int, offset_t, \ 8793898Srsb cred_t *, caller_context_t *); \ 8805331Samw int (*vop_realvp)(vnode_t *, vnode_t **, \ 8815331Samw caller_context_t *); \ 8823898Srsb int (*vop_getpage)(vnode_t *, offset_t, size_t, uint_t *, \ 8833898Srsb struct page **, size_t, struct seg *, \ 8845331Samw caddr_t, enum seg_rw, cred_t *, \ 8855331Samw caller_context_t *); \ 8863898Srsb int (*vop_putpage)(vnode_t *, offset_t, size_t, \ 8875331Samw int, cred_t *, caller_context_t *); \ 8883898Srsb int (*vop_map)(vnode_t *, offset_t, struct as *, \ 8893898Srsb caddr_t *, size_t, \ 8905331Samw uchar_t, uchar_t, uint_t, cred_t *, \ 8915331Samw caller_context_t *); \ 8923898Srsb int (*vop_addmap)(vnode_t *, offset_t, struct as *, \ 8933898Srsb caddr_t, size_t, \ 8945331Samw uchar_t, uchar_t, uint_t, cred_t *, \ 8955331Samw caller_context_t *); \ 8963898Srsb int (*vop_delmap)(vnode_t *, offset_t, struct as *, \ 8973898Srsb caddr_t, size_t, \ 8985331Samw uint_t, uint_t, uint_t, cred_t *, \ 8995331Samw caller_context_t *); \ 9003898Srsb int (*vop_poll)(vnode_t *, short, int, short *, \ 9015331Samw struct pollhead **, \ 9025331Samw caller_context_t *); \ 9036264Srm15945 int (*vop_dump)(vnode_t *, caddr_t, offset_t, offset_t, \ 9045331Samw caller_context_t *); \ 9055331Samw int (*vop_pathconf)(vnode_t *, int, ulong_t *, cred_t *, \ 9065331Samw caller_context_t *); \ 9073898Srsb int (*vop_pageio)(vnode_t *, struct page *, \ 9085331Samw u_offset_t, size_t, int, cred_t *, \ 9095331Samw caller_context_t *); \ 9106264Srm15945 int (*vop_dumpctl)(vnode_t *, int, offset_t *, \ 9115331Samw caller_context_t *); \ 9123898Srsb void (*vop_dispose)(vnode_t *, struct page *, \ 9135331Samw int, int, cred_t *, \ 9145331Samw caller_context_t *); \ 9153898Srsb int (*vop_setsecattr)(vnode_t *, vsecattr_t *, \ 9165331Samw int, cred_t *, caller_context_t *); \ 9173898Srsb int (*vop_getsecattr)(vnode_t *, vsecattr_t *, \ 9185331Samw int, cred_t *, caller_context_t *); \ 9193898Srsb int (*vop_shrlock)(vnode_t *, int, struct shrlock *, \ 9205331Samw int, cred_t *, caller_context_t *); \ 9215331Samw int (*vop_vnevent)(vnode_t *, vnevent_t, vnode_t *, \ 92211539SChunli.Zhang@Sun.COM char *, caller_context_t *); \ 92311539SChunli.Zhang@Sun.COM int (*vop_reqzcbuf)(vnode_t *, enum uio_rw, xuio_t *, \ 92411539SChunli.Zhang@Sun.COM cred_t *, caller_context_t *); \ 92511539SChunli.Zhang@Sun.COM int (*vop_retzcbuf)(vnode_t *, xuio_t *, cred_t *, \ 92611539SChunli.Zhang@Sun.COM caller_context_t *) 9274863Spraks /* NB: No ";" */ 9283898Srsb 9293898Srsb /* 9303898Srsb * Operations on vnodes. Note: File systems must never operate directly 9310Sstevel@tonic-gate * on a 'vnodeops' structure -- it WILL change in future releases! They 9323898Srsb * must use vn_make_ops() to create the structure. 9330Sstevel@tonic-gate */ 9340Sstevel@tonic-gate typedef struct vnodeops { 9350Sstevel@tonic-gate const char *vnop_name; 9363898Srsb VNODE_OPS; /* Signatures of all vnode operations (vops) */ 9370Sstevel@tonic-gate } vnodeops_t; 9380Sstevel@tonic-gate 9393898Srsb typedef int (*fs_generic_func_p) (); /* Generic vop/vfsop/femop/fsemop ptr */ 9400Sstevel@tonic-gate 9415331Samw extern int fop_open(vnode_t **, int, cred_t *, caller_context_t *); 9425331Samw extern int fop_close(vnode_t *, int, int, offset_t, cred_t *, 9435331Samw caller_context_t *); 9440Sstevel@tonic-gate extern int fop_read(vnode_t *, uio_t *, int, cred_t *, caller_context_t *); 9450Sstevel@tonic-gate extern int fop_write(vnode_t *, uio_t *, int, cred_t *, 9460Sstevel@tonic-gate caller_context_t *); 9475331Samw extern int fop_ioctl(vnode_t *, int, intptr_t, int, cred_t *, int *, 9485331Samw caller_context_t *); 9495331Samw extern int fop_setfl(vnode_t *, int, int, cred_t *, caller_context_t *); 9505331Samw extern int fop_getattr(vnode_t *, vattr_t *, int, cred_t *, 9515331Samw caller_context_t *); 9520Sstevel@tonic-gate extern int fop_setattr(vnode_t *, vattr_t *, int, cred_t *, 9530Sstevel@tonic-gate caller_context_t *); 9545331Samw extern int fop_access(vnode_t *, int, int, cred_t *, caller_context_t *); 9550Sstevel@tonic-gate extern int fop_lookup(vnode_t *, char *, vnode_t **, struct pathname *, 9565331Samw int, vnode_t *, cred_t *, caller_context_t *, 9575331Samw int *, struct pathname *); 9580Sstevel@tonic-gate extern int fop_create(vnode_t *, char *, vattr_t *, vcexcl_t, int, 9595331Samw vnode_t **, cred_t *, int, caller_context_t *, 9605331Samw vsecattr_t *); 9615331Samw extern int fop_remove(vnode_t *vp, char *, cred_t *, caller_context_t *, 9625331Samw int); 9635331Samw extern int fop_link(vnode_t *, vnode_t *, char *, cred_t *, 9645331Samw caller_context_t *, int); 9655331Samw extern int fop_rename(vnode_t *, char *, vnode_t *, char *, cred_t *, 9665331Samw caller_context_t *, int); 9675331Samw extern int fop_mkdir(vnode_t *, char *, vattr_t *, vnode_t **, cred_t *, 9685331Samw caller_context_t *, int, vsecattr_t *); 9695331Samw extern int fop_rmdir(vnode_t *, char *, vnode_t *, cred_t *, 9705331Samw caller_context_t *, int); 9715331Samw extern int fop_readdir(vnode_t *, uio_t *, cred_t *, int *, 9725331Samw caller_context_t *, int); 9735331Samw extern int fop_symlink(vnode_t *, char *, vattr_t *, char *, cred_t *, 9745331Samw caller_context_t *, int); 9755331Samw extern int fop_readlink(vnode_t *, uio_t *, cred_t *, caller_context_t *); 9765331Samw extern int fop_fsync(vnode_t *, int, cred_t *, caller_context_t *); 9775331Samw extern void fop_inactive(vnode_t *, cred_t *, caller_context_t *); 9785331Samw extern int fop_fid(vnode_t *, struct fid *, caller_context_t *); 9790Sstevel@tonic-gate extern int fop_rwlock(vnode_t *, int, caller_context_t *); 9800Sstevel@tonic-gate extern void fop_rwunlock(vnode_t *, int, caller_context_t *); 9815331Samw extern int fop_seek(vnode_t *, offset_t, offset_t *, caller_context_t *); 9825331Samw extern int fop_cmp(vnode_t *, vnode_t *, caller_context_t *); 9830Sstevel@tonic-gate extern int fop_frlock(vnode_t *, int, struct flock64 *, int, offset_t, 9845331Samw struct flk_callback *, cred_t *, 9855331Samw caller_context_t *); 9860Sstevel@tonic-gate extern int fop_space(vnode_t *, int, struct flock64 *, int, offset_t, 9870Sstevel@tonic-gate cred_t *, caller_context_t *); 9885331Samw extern int fop_realvp(vnode_t *, vnode_t **, caller_context_t *); 9890Sstevel@tonic-gate extern int fop_getpage(vnode_t *, offset_t, size_t, uint_t *, 9900Sstevel@tonic-gate struct page **, size_t, struct seg *, 9915331Samw caddr_t, enum seg_rw, cred_t *, 9925331Samw caller_context_t *); 9935331Samw extern int fop_putpage(vnode_t *, offset_t, size_t, int, cred_t *, 9945331Samw caller_context_t *); 9950Sstevel@tonic-gate extern int fop_map(vnode_t *, offset_t, struct as *, caddr_t *, size_t, 9965331Samw uchar_t, uchar_t, uint_t, cred_t *cr, 9975331Samw caller_context_t *); 9980Sstevel@tonic-gate extern int fop_addmap(vnode_t *, offset_t, struct as *, caddr_t, size_t, 9995331Samw uchar_t, uchar_t, uint_t, cred_t *, 10005331Samw caller_context_t *); 10010Sstevel@tonic-gate extern int fop_delmap(vnode_t *, offset_t, struct as *, caddr_t, size_t, 10025331Samw uint_t, uint_t, uint_t, cred_t *, 10035331Samw caller_context_t *); 10045331Samw extern int fop_poll(vnode_t *, short, int, short *, struct pollhead **, 10055331Samw caller_context_t *); 10066264Srm15945 extern int fop_dump(vnode_t *, caddr_t, offset_t, offset_t, 10076264Srm15945 caller_context_t *); 10085331Samw extern int fop_pathconf(vnode_t *, int, ulong_t *, cred_t *, 10095331Samw caller_context_t *); 10100Sstevel@tonic-gate extern int fop_pageio(vnode_t *, struct page *, u_offset_t, size_t, int, 10115331Samw cred_t *, caller_context_t *); 10126264Srm15945 extern int fop_dumpctl(vnode_t *, int, offset_t *, caller_context_t *); 10135331Samw extern void fop_dispose(vnode_t *, struct page *, int, int, cred_t *, 10145331Samw caller_context_t *); 10155331Samw extern int fop_setsecattr(vnode_t *, vsecattr_t *, int, cred_t *, 10165331Samw caller_context_t *); 10175331Samw extern int fop_getsecattr(vnode_t *, vsecattr_t *, int, cred_t *, 10185331Samw caller_context_t *); 10195331Samw extern int fop_shrlock(vnode_t *, int, struct shrlock *, int, cred_t *, 10205331Samw caller_context_t *); 10215331Samw extern int fop_vnevent(vnode_t *, vnevent_t, vnode_t *, char *, 10225331Samw caller_context_t *); 102311539SChunli.Zhang@Sun.COM extern int fop_reqzcbuf(vnode_t *, enum uio_rw, xuio_t *, cred_t *, 102411539SChunli.Zhang@Sun.COM caller_context_t *); 102511539SChunli.Zhang@Sun.COM extern int fop_retzcbuf(vnode_t *, xuio_t *, cred_t *, caller_context_t *); 10260Sstevel@tonic-gate 10270Sstevel@tonic-gate #endif /* _KERNEL */ 10280Sstevel@tonic-gate 10295331Samw #define VOP_OPEN(vpp, mode, cr, ct) \ 10305331Samw fop_open(vpp, mode, cr, ct) 10315331Samw #define VOP_CLOSE(vp, f, c, o, cr, ct) \ 10325331Samw fop_close(vp, f, c, o, cr, ct) 10330Sstevel@tonic-gate #define VOP_READ(vp, uiop, iof, cr, ct) \ 10340Sstevel@tonic-gate fop_read(vp, uiop, iof, cr, ct) 10350Sstevel@tonic-gate #define VOP_WRITE(vp, uiop, iof, cr, ct) \ 10360Sstevel@tonic-gate fop_write(vp, uiop, iof, cr, ct) 10375331Samw #define VOP_IOCTL(vp, cmd, a, f, cr, rvp, ct) \ 10385331Samw fop_ioctl(vp, cmd, a, f, cr, rvp, ct) 10395331Samw #define VOP_SETFL(vp, f, a, cr, ct) \ 10405331Samw fop_setfl(vp, f, a, cr, ct) 10415331Samw #define VOP_GETATTR(vp, vap, f, cr, ct) \ 10425331Samw fop_getattr(vp, vap, f, cr, ct) 10430Sstevel@tonic-gate #define VOP_SETATTR(vp, vap, f, cr, ct) \ 10440Sstevel@tonic-gate fop_setattr(vp, vap, f, cr, ct) 10455331Samw #define VOP_ACCESS(vp, mode, f, cr, ct) \ 10465331Samw fop_access(vp, mode, f, cr, ct) 10475331Samw #define VOP_LOOKUP(vp, cp, vpp, pnp, f, rdir, cr, ct, defp, rpnp) \ 10485331Samw fop_lookup(vp, cp, vpp, pnp, f, rdir, cr, ct, defp, rpnp) 10495331Samw #define VOP_CREATE(dvp, p, vap, ex, mode, vpp, cr, flag, ct, vsap) \ 10505331Samw fop_create(dvp, p, vap, ex, mode, vpp, cr, flag, ct, vsap) 10515331Samw #define VOP_REMOVE(dvp, p, cr, ct, f) \ 10525331Samw fop_remove(dvp, p, cr, ct, f) 10535331Samw #define VOP_LINK(tdvp, fvp, p, cr, ct, f) \ 10545331Samw fop_link(tdvp, fvp, p, cr, ct, f) 10555331Samw #define VOP_RENAME(fvp, fnm, tdvp, tnm, cr, ct, f) \ 10565331Samw fop_rename(fvp, fnm, tdvp, tnm, cr, ct, f) 10575331Samw #define VOP_MKDIR(dp, p, vap, vpp, cr, ct, f, vsap) \ 10585331Samw fop_mkdir(dp, p, vap, vpp, cr, ct, f, vsap) 10595331Samw #define VOP_RMDIR(dp, p, cdir, cr, ct, f) \ 10605331Samw fop_rmdir(dp, p, cdir, cr, ct, f) 10615331Samw #define VOP_READDIR(vp, uiop, cr, eofp, ct, f) \ 10625331Samw fop_readdir(vp, uiop, cr, eofp, ct, f) 10635331Samw #define VOP_SYMLINK(dvp, lnm, vap, tnm, cr, ct, f) \ 10645331Samw fop_symlink(dvp, lnm, vap, tnm, cr, ct, f) 10655331Samw #define VOP_READLINK(vp, uiop, cr, ct) \ 10665331Samw fop_readlink(vp, uiop, cr, ct) 10675331Samw #define VOP_FSYNC(vp, syncflag, cr, ct) \ 10685331Samw fop_fsync(vp, syncflag, cr, ct) 10695331Samw #define VOP_INACTIVE(vp, cr, ct) \ 10705331Samw fop_inactive(vp, cr, ct) 10715331Samw #define VOP_FID(vp, fidp, ct) \ 10725331Samw fop_fid(vp, fidp, ct) 10730Sstevel@tonic-gate #define VOP_RWLOCK(vp, w, ct) \ 10740Sstevel@tonic-gate fop_rwlock(vp, w, ct) 10750Sstevel@tonic-gate #define VOP_RWUNLOCK(vp, w, ct) \ 10760Sstevel@tonic-gate fop_rwunlock(vp, w, ct) 10775331Samw #define VOP_SEEK(vp, ooff, noffp, ct) \ 10785331Samw fop_seek(vp, ooff, noffp, ct) 10795331Samw #define VOP_CMP(vp1, vp2, ct) \ 10805331Samw fop_cmp(vp1, vp2, ct) 10815331Samw #define VOP_FRLOCK(vp, cmd, a, f, o, cb, cr, ct) \ 10825331Samw fop_frlock(vp, cmd, a, f, o, cb, cr, ct) 10830Sstevel@tonic-gate #define VOP_SPACE(vp, cmd, a, f, o, cr, ct) \ 10840Sstevel@tonic-gate fop_space(vp, cmd, a, f, o, cr, ct) 10855331Samw #define VOP_REALVP(vp1, vp2, ct) \ 10865331Samw fop_realvp(vp1, vp2, ct) 10875331Samw #define VOP_GETPAGE(vp, of, sz, pr, pl, ps, sg, a, rw, cr, ct) \ 10885331Samw fop_getpage(vp, of, sz, pr, pl, ps, sg, a, rw, cr, ct) 10895331Samw #define VOP_PUTPAGE(vp, of, sz, fl, cr, ct) \ 10905331Samw fop_putpage(vp, of, sz, fl, cr, ct) 10915331Samw #define VOP_MAP(vp, of, as, a, sz, p, mp, fl, cr, ct) \ 10925331Samw fop_map(vp, of, as, a, sz, p, mp, fl, cr, ct) 10935331Samw #define VOP_ADDMAP(vp, of, as, a, sz, p, mp, fl, cr, ct) \ 10945331Samw fop_addmap(vp, of, as, a, sz, p, mp, fl, cr, ct) 10955331Samw #define VOP_DELMAP(vp, of, as, a, sz, p, mp, fl, cr, ct) \ 10965331Samw fop_delmap(vp, of, as, a, sz, p, mp, fl, cr, ct) 10975331Samw #define VOP_POLL(vp, events, anyyet, reventsp, phpp, ct) \ 10985331Samw fop_poll(vp, events, anyyet, reventsp, phpp, ct) 10995331Samw #define VOP_DUMP(vp, addr, bn, count, ct) \ 11005331Samw fop_dump(vp, addr, bn, count, ct) 11015331Samw #define VOP_PATHCONF(vp, cmd, valp, cr, ct) \ 11025331Samw fop_pathconf(vp, cmd, valp, cr, ct) 11035331Samw #define VOP_PAGEIO(vp, pp, io_off, io_len, flags, cr, ct) \ 11045331Samw fop_pageio(vp, pp, io_off, io_len, flags, cr, ct) 11055331Samw #define VOP_DUMPCTL(vp, action, blkp, ct) \ 11065331Samw fop_dumpctl(vp, action, blkp, ct) 11075331Samw #define VOP_DISPOSE(vp, pp, flag, dn, cr, ct) \ 11085331Samw fop_dispose(vp, pp, flag, dn, cr, ct) 11095331Samw #define VOP_GETSECATTR(vp, vsap, f, cr, ct) \ 11105331Samw fop_getsecattr(vp, vsap, f, cr, ct) 11115331Samw #define VOP_SETSECATTR(vp, vsap, f, cr, ct) \ 11125331Samw fop_setsecattr(vp, vsap, f, cr, ct) 11135331Samw #define VOP_SHRLOCK(vp, cmd, shr, f, cr, ct) \ 11145331Samw fop_shrlock(vp, cmd, shr, f, cr, ct) 11155331Samw #define VOP_VNEVENT(vp, vnevent, dvp, fnm, ct) \ 11165331Samw fop_vnevent(vp, vnevent, dvp, fnm, ct) 111711539SChunli.Zhang@Sun.COM #define VOP_REQZCBUF(vp, rwflag, xuiop, cr, ct) \ 111811539SChunli.Zhang@Sun.COM fop_reqzcbuf(vp, rwflag, xuiop, cr, ct) 111911539SChunli.Zhang@Sun.COM #define VOP_RETZCBUF(vp, xuiop, cr, ct) \ 112011539SChunli.Zhang@Sun.COM fop_retzcbuf(vp, xuiop, cr, ct) 11210Sstevel@tonic-gate 11220Sstevel@tonic-gate #define VOPNAME_OPEN "open" 11230Sstevel@tonic-gate #define VOPNAME_CLOSE "close" 11240Sstevel@tonic-gate #define VOPNAME_READ "read" 11250Sstevel@tonic-gate #define VOPNAME_WRITE "write" 11260Sstevel@tonic-gate #define VOPNAME_IOCTL "ioctl" 11270Sstevel@tonic-gate #define VOPNAME_SETFL "setfl" 11280Sstevel@tonic-gate #define VOPNAME_GETATTR "getattr" 11290Sstevel@tonic-gate #define VOPNAME_SETATTR "setattr" 11300Sstevel@tonic-gate #define VOPNAME_ACCESS "access" 11310Sstevel@tonic-gate #define VOPNAME_LOOKUP "lookup" 11320Sstevel@tonic-gate #define VOPNAME_CREATE "create" 11330Sstevel@tonic-gate #define VOPNAME_REMOVE "remove" 11340Sstevel@tonic-gate #define VOPNAME_LINK "link" 11350Sstevel@tonic-gate #define VOPNAME_RENAME "rename" 11360Sstevel@tonic-gate #define VOPNAME_MKDIR "mkdir" 11370Sstevel@tonic-gate #define VOPNAME_RMDIR "rmdir" 11380Sstevel@tonic-gate #define VOPNAME_READDIR "readdir" 11390Sstevel@tonic-gate #define VOPNAME_SYMLINK "symlink" 11400Sstevel@tonic-gate #define VOPNAME_READLINK "readlink" 11410Sstevel@tonic-gate #define VOPNAME_FSYNC "fsync" 11420Sstevel@tonic-gate #define VOPNAME_INACTIVE "inactive" 11430Sstevel@tonic-gate #define VOPNAME_FID "fid" 11440Sstevel@tonic-gate #define VOPNAME_RWLOCK "rwlock" 11450Sstevel@tonic-gate #define VOPNAME_RWUNLOCK "rwunlock" 11460Sstevel@tonic-gate #define VOPNAME_SEEK "seek" 11470Sstevel@tonic-gate #define VOPNAME_CMP "cmp" 11480Sstevel@tonic-gate #define VOPNAME_FRLOCK "frlock" 11490Sstevel@tonic-gate #define VOPNAME_SPACE "space" 11500Sstevel@tonic-gate #define VOPNAME_REALVP "realvp" 11510Sstevel@tonic-gate #define VOPNAME_GETPAGE "getpage" 11520Sstevel@tonic-gate #define VOPNAME_PUTPAGE "putpage" 11530Sstevel@tonic-gate #define VOPNAME_MAP "map" 11540Sstevel@tonic-gate #define VOPNAME_ADDMAP "addmap" 11550Sstevel@tonic-gate #define VOPNAME_DELMAP "delmap" 11560Sstevel@tonic-gate #define VOPNAME_POLL "poll" 11570Sstevel@tonic-gate #define VOPNAME_DUMP "dump" 11580Sstevel@tonic-gate #define VOPNAME_PATHCONF "pathconf" 11590Sstevel@tonic-gate #define VOPNAME_PAGEIO "pageio" 11600Sstevel@tonic-gate #define VOPNAME_DUMPCTL "dumpctl" 11610Sstevel@tonic-gate #define VOPNAME_DISPOSE "dispose" 11620Sstevel@tonic-gate #define VOPNAME_GETSECATTR "getsecattr" 11630Sstevel@tonic-gate #define VOPNAME_SETSECATTR "setsecattr" 11640Sstevel@tonic-gate #define VOPNAME_SHRLOCK "shrlock" 11650Sstevel@tonic-gate #define VOPNAME_VNEVENT "vnevent" 116611539SChunli.Zhang@Sun.COM #define VOPNAME_REQZCBUF "reqzcbuf" 116711539SChunli.Zhang@Sun.COM #define VOPNAME_RETZCBUF "retzcbuf" 11680Sstevel@tonic-gate 11690Sstevel@tonic-gate /* 11700Sstevel@tonic-gate * Flags for VOP_LOOKUP 11715331Samw * 117212789SRoger.Faulkner@Oracle.COM * Defined in file.h, but also possible, FIGNORECASE and FSEARCH 11735331Samw * 11740Sstevel@tonic-gate */ 11750Sstevel@tonic-gate #define LOOKUP_DIR 0x01 /* want parent dir vp */ 11760Sstevel@tonic-gate #define LOOKUP_XATTR 0x02 /* lookup up extended attr dir */ 11770Sstevel@tonic-gate #define CREATE_XATTR_DIR 0x04 /* Create extended attr dir */ 11785331Samw #define LOOKUP_HAVE_SYSATTR_DIR 0x08 /* Already created virtual GFS dir */ 11795331Samw 11805331Samw /* 11815331Samw * Flags for VOP_READDIR 11825331Samw */ 11835331Samw #define V_RDDIR_ENTFLAGS 0x01 /* request dirent flags */ 11849749STim.Haley@Sun.COM #define V_RDDIR_ACCFILTER 0x02 /* filter out inaccessible dirents */ 11850Sstevel@tonic-gate 11860Sstevel@tonic-gate /* 11870Sstevel@tonic-gate * Flags for VOP_RWLOCK/VOP_RWUNLOCK 11880Sstevel@tonic-gate * VOP_RWLOCK will return the flag that was actually set, or -1 if none. 11890Sstevel@tonic-gate */ 11900Sstevel@tonic-gate #define V_WRITELOCK_TRUE (1) /* Request write-lock on the vnode */ 11910Sstevel@tonic-gate #define V_WRITELOCK_FALSE (0) /* Request read-lock on the vnode */ 11920Sstevel@tonic-gate 11930Sstevel@tonic-gate /* 11940Sstevel@tonic-gate * Flags for VOP_DUMPCTL 11950Sstevel@tonic-gate */ 11960Sstevel@tonic-gate #define DUMP_ALLOC 0 11970Sstevel@tonic-gate #define DUMP_FREE 1 11980Sstevel@tonic-gate #define DUMP_SCAN 2 11990Sstevel@tonic-gate 12000Sstevel@tonic-gate /* 12010Sstevel@tonic-gate * Public vnode manipulation functions. 12020Sstevel@tonic-gate */ 12030Sstevel@tonic-gate #ifdef _KERNEL 12040Sstevel@tonic-gate 12050Sstevel@tonic-gate vnode_t *vn_alloc(int); 12060Sstevel@tonic-gate void vn_reinit(vnode_t *); 12070Sstevel@tonic-gate void vn_recycle(vnode_t *); 12080Sstevel@tonic-gate void vn_free(vnode_t *); 12090Sstevel@tonic-gate 12100Sstevel@tonic-gate int vn_is_readonly(vnode_t *); 12110Sstevel@tonic-gate int vn_is_opened(vnode_t *, v_mode_t); 12120Sstevel@tonic-gate int vn_is_mapped(vnode_t *, v_mode_t); 12135331Samw int vn_has_other_opens(vnode_t *, v_mode_t); 12145331Samw void vn_open_upgrade(vnode_t *, int); 12155331Samw void vn_open_downgrade(vnode_t *, int); 12160Sstevel@tonic-gate 12170Sstevel@tonic-gate int vn_can_change_zones(vnode_t *vp); 12180Sstevel@tonic-gate 12190Sstevel@tonic-gate int vn_has_flocks(vnode_t *); 12200Sstevel@tonic-gate int vn_has_mandatory_locks(vnode_t *, int); 12210Sstevel@tonic-gate int vn_has_cached_data(vnode_t *); 12220Sstevel@tonic-gate 12230Sstevel@tonic-gate void vn_setops(vnode_t *, vnodeops_t *); 12240Sstevel@tonic-gate vnodeops_t *vn_getops(vnode_t *); 12250Sstevel@tonic-gate int vn_matchops(vnode_t *, vnodeops_t *); 12260Sstevel@tonic-gate int vn_matchopval(vnode_t *, char *, fs_generic_func_p); 12270Sstevel@tonic-gate int vn_ismntpt(vnode_t *); 12280Sstevel@tonic-gate 12290Sstevel@tonic-gate struct vfs *vn_mountedvfs(vnode_t *); 12300Sstevel@tonic-gate 12316712Stomee int vn_in_dnlc(vnode_t *); 12326712Stomee 12330Sstevel@tonic-gate void vn_create_cache(void); 12340Sstevel@tonic-gate void vn_destroy_cache(void); 12350Sstevel@tonic-gate 12360Sstevel@tonic-gate void vn_freevnodeops(vnodeops_t *); 12370Sstevel@tonic-gate 12380Sstevel@tonic-gate int vn_open(char *pnamep, enum uio_seg seg, int filemode, int createmode, 12390Sstevel@tonic-gate struct vnode **vpp, enum create crwhy, mode_t umask); 12400Sstevel@tonic-gate int vn_openat(char *pnamep, enum uio_seg seg, int filemode, int createmode, 12410Sstevel@tonic-gate struct vnode **vpp, enum create crwhy, 12425331Samw mode_t umask, struct vnode *startvp, int fd); 12430Sstevel@tonic-gate int vn_create(char *pnamep, enum uio_seg seg, struct vattr *vap, 12440Sstevel@tonic-gate enum vcexcl excl, int mode, struct vnode **vpp, 12450Sstevel@tonic-gate enum create why, int flag, mode_t umask); 12460Sstevel@tonic-gate int vn_createat(char *pnamep, enum uio_seg seg, struct vattr *vap, 12470Sstevel@tonic-gate enum vcexcl excl, int mode, struct vnode **vpp, 12480Sstevel@tonic-gate enum create why, int flag, mode_t umask, struct vnode *startvp); 12490Sstevel@tonic-gate int vn_rdwr(enum uio_rw rw, struct vnode *vp, caddr_t base, ssize_t len, 12500Sstevel@tonic-gate offset_t offset, enum uio_seg seg, int ioflag, rlim64_t ulimit, 12510Sstevel@tonic-gate cred_t *cr, ssize_t *residp); 12520Sstevel@tonic-gate void vn_rele(struct vnode *vp); 12539321SNeil.Perrin@Sun.COM void vn_rele_async(struct vnode *vp, struct taskq *taskq); 12546712Stomee void vn_rele_dnlc(struct vnode *vp); 12550Sstevel@tonic-gate void vn_rele_stream(struct vnode *vp); 12560Sstevel@tonic-gate int vn_link(char *from, char *to, enum uio_seg seg); 125712789SRoger.Faulkner@Oracle.COM int vn_linkat(vnode_t *fstartvp, char *from, enum symfollow follow, 125812789SRoger.Faulkner@Oracle.COM vnode_t *tstartvp, char *to, enum uio_seg seg); 12590Sstevel@tonic-gate int vn_rename(char *from, char *to, enum uio_seg seg); 12600Sstevel@tonic-gate int vn_renameat(vnode_t *fdvp, char *fname, vnode_t *tdvp, char *tname, 12610Sstevel@tonic-gate enum uio_seg seg); 12620Sstevel@tonic-gate int vn_remove(char *fnamep, enum uio_seg seg, enum rm dirflag); 12630Sstevel@tonic-gate int vn_removeat(vnode_t *startvp, char *fnamep, enum uio_seg seg, 12640Sstevel@tonic-gate enum rm dirflag); 12650Sstevel@tonic-gate int vn_compare(vnode_t *vp1, vnode_t *vp2); 12660Sstevel@tonic-gate int vn_vfswlock(struct vnode *vp); 12670Sstevel@tonic-gate int vn_vfswlock_wait(struct vnode *vp); 12680Sstevel@tonic-gate int vn_vfsrlock(struct vnode *vp); 12690Sstevel@tonic-gate int vn_vfsrlock_wait(struct vnode *vp); 12700Sstevel@tonic-gate void vn_vfsunlock(struct vnode *vp); 12710Sstevel@tonic-gate int vn_vfswlock_held(struct vnode *vp); 12720Sstevel@tonic-gate vnode_t *specvp(struct vnode *vp, dev_t dev, vtype_t type, struct cred *cr); 12730Sstevel@tonic-gate vnode_t *makespecvp(dev_t dev, vtype_t type); 12740Sstevel@tonic-gate vn_vfslocks_entry_t *vn_vfslocks_getlock(void *); 12750Sstevel@tonic-gate void vn_vfslocks_rele(vn_vfslocks_entry_t *); 127611291SRobert.Thurlow@Sun.COM boolean_t vn_is_reparse(vnode_t *, cred_t *, caller_context_t *); 12770Sstevel@tonic-gate 1278254Seschrock void vn_copypath(struct vnode *src, struct vnode *dst); 1279254Seschrock void vn_setpath_str(struct vnode *vp, const char *str, size_t len); 1280254Seschrock void vn_setpath(vnode_t *rootvp, struct vnode *startvp, struct vnode *vp, 1281254Seschrock const char *path, size_t plen); 12826976Seschrock void vn_renamepath(vnode_t *dvp, vnode_t *vp, const char *nm, size_t len); 1283254Seschrock 12840Sstevel@tonic-gate /* Vnode event notification */ 12855331Samw void vnevent_rename_src(vnode_t *, vnode_t *, char *, caller_context_t *); 12865331Samw void vnevent_rename_dest(vnode_t *, vnode_t *, char *, caller_context_t *); 12875331Samw void vnevent_remove(vnode_t *, vnode_t *, char *, caller_context_t *); 12885331Samw void vnevent_rmdir(vnode_t *, vnode_t *, char *, caller_context_t *); 12895331Samw void vnevent_create(vnode_t *, caller_context_t *); 12905331Samw void vnevent_link(vnode_t *, caller_context_t *); 12915331Samw void vnevent_rename_dest_dir(vnode_t *, caller_context_t *ct); 12925331Samw void vnevent_mountedover(vnode_t *, caller_context_t *); 12935331Samw int vnevent_support(vnode_t *, caller_context_t *); 12940Sstevel@tonic-gate 12955050Sjwahlig /* Vnode specific data */ 12965050Sjwahlig void vsd_create(uint_t *, void (*)(void *)); 12975050Sjwahlig void vsd_destroy(uint_t *); 12985050Sjwahlig void *vsd_get(vnode_t *, uint_t); 12995050Sjwahlig int vsd_set(vnode_t *, uint_t, void *); 13005050Sjwahlig void vsd_free(vnode_t *); 13015050Sjwahlig 13025331Samw /* 13035331Samw * Extensible vnode attribute (xva) routines: 13045331Samw * xva_init() initializes an xvattr_t (zero struct, init mapsize, set AT_XATTR) 13055331Samw * xva_getxoptattr() returns a ponter to the xoptattr_t section of xvattr_t 13065331Samw */ 13075331Samw void xva_init(xvattr_t *); 13085331Samw xoptattr_t *xva_getxoptattr(xvattr_t *); /* Get ptr to xoptattr_t */ 13095331Samw 13105331Samw void xattr_init(void); /* Initialize vnodeops for xattrs */ 13115331Samw 13125331Samw /* GFS tunnel for xattrs */ 13135331Samw int xattr_dir_lookup(vnode_t *, vnode_t **, int, cred_t *); 13145331Samw 131510793Sdai.ngo@sun.com /* Reparse Point */ 131610793Sdai.ngo@sun.com void reparse_point_init(void); 131710793Sdai.ngo@sun.com 13180Sstevel@tonic-gate /* Context identification */ 13190Sstevel@tonic-gate u_longlong_t fs_new_caller_id(); 13200Sstevel@tonic-gate 13210Sstevel@tonic-gate int vn_vmpss_usepageio(vnode_t *); 13220Sstevel@tonic-gate 13230Sstevel@tonic-gate /* 13240Sstevel@tonic-gate * Needed for use of IS_VMODSORT() in kernel. 13250Sstevel@tonic-gate */ 13260Sstevel@tonic-gate extern uint_t pvn_vmodsort_supported; 13270Sstevel@tonic-gate 13280Sstevel@tonic-gate #define VN_HOLD(vp) { \ 13290Sstevel@tonic-gate mutex_enter(&(vp)->v_lock); \ 13300Sstevel@tonic-gate (vp)->v_count++; \ 13310Sstevel@tonic-gate mutex_exit(&(vp)->v_lock); \ 13320Sstevel@tonic-gate } 13330Sstevel@tonic-gate 13340Sstevel@tonic-gate #define VN_RELE(vp) { \ 13350Sstevel@tonic-gate vn_rele(vp); \ 13360Sstevel@tonic-gate } 13370Sstevel@tonic-gate 13389321SNeil.Perrin@Sun.COM #define VN_RELE_ASYNC(vp, taskq) { \ 13399321SNeil.Perrin@Sun.COM vn_rele_async(vp, taskq); \ 13409321SNeil.Perrin@Sun.COM } 13419321SNeil.Perrin@Sun.COM 13420Sstevel@tonic-gate #define VN_SET_VFS_TYPE_DEV(vp, vfsp, type, dev) { \ 13430Sstevel@tonic-gate (vp)->v_vfsp = (vfsp); \ 13440Sstevel@tonic-gate (vp)->v_type = (type); \ 13450Sstevel@tonic-gate (vp)->v_rdev = (dev); \ 13460Sstevel@tonic-gate } 13470Sstevel@tonic-gate 13480Sstevel@tonic-gate /* 13490Sstevel@tonic-gate * Compare two vnodes for equality. In general this macro should be used 13500Sstevel@tonic-gate * in preference to calling VOP_CMP directly. 13510Sstevel@tonic-gate */ 13520Sstevel@tonic-gate #define VN_CMP(VP1, VP2) ((VP1) == (VP2) ? 1 : \ 13530Sstevel@tonic-gate ((VP1) && (VP2) && (vn_getops(VP1) == vn_getops(VP2)) ? \ 13545331Samw VOP_CMP(VP1, VP2, NULL) : 0)) 13550Sstevel@tonic-gate 135611185SSean.McEnroe@Sun.COM /* 135711185SSean.McEnroe@Sun.COM * Some well-known global vnodes used by the VM system to name pages. 135811185SSean.McEnroe@Sun.COM */ 135911185SSean.McEnroe@Sun.COM extern struct vnode kvps[]; 13603290Sjohansen 136111185SSean.McEnroe@Sun.COM typedef enum { 136211185SSean.McEnroe@Sun.COM KV_KVP, /* vnode for all segkmem pages */ 136311185SSean.McEnroe@Sun.COM KV_ZVP, /* vnode for all ZFS pages */ 136411185SSean.McEnroe@Sun.COM #if defined(__sparc) 136511185SSean.McEnroe@Sun.COM KV_MPVP, /* vnode for all page_t meta-pages */ 136611185SSean.McEnroe@Sun.COM KV_PROMVP, /* vnode for all PROM pages */ 136711185SSean.McEnroe@Sun.COM #endif /* __sparc */ 136811185SSean.McEnroe@Sun.COM KV_MAX /* total number of vnodes in kvps[] */ 136911185SSean.McEnroe@Sun.COM } kvps_index_t; 137011185SSean.McEnroe@Sun.COM 137111185SSean.McEnroe@Sun.COM #define VN_ISKAS(vp) ((vp) >= &kvps[0] && (vp) < &kvps[KV_MAX]) 13723290Sjohansen 13730Sstevel@tonic-gate #endif /* _KERNEL */ 13740Sstevel@tonic-gate 13750Sstevel@tonic-gate /* 13760Sstevel@tonic-gate * Flags to VOP_SETATTR/VOP_GETATTR. 13770Sstevel@tonic-gate */ 13780Sstevel@tonic-gate #define ATTR_UTIME 0x01 /* non-default utime(2) request */ 13790Sstevel@tonic-gate #define ATTR_EXEC 0x02 /* invocation from exec(2) */ 13800Sstevel@tonic-gate #define ATTR_COMM 0x04 /* yield common vp attributes */ 13810Sstevel@tonic-gate #define ATTR_HINT 0x08 /* information returned will be `hint' */ 13820Sstevel@tonic-gate #define ATTR_REAL 0x10 /* yield attributes of the real vp */ 13835331Samw #define ATTR_NOACLCHECK 0x20 /* Don't check ACL when checking permissions */ 13845302Sth199096 #define ATTR_TRIGGER 0x40 /* Mount first if vnode is a trigger mount */ 13850Sstevel@tonic-gate /* 13860Sstevel@tonic-gate * Generally useful macros. 13870Sstevel@tonic-gate */ 13880Sstevel@tonic-gate #define VBSIZE(vp) ((vp)->v_vfsp->vfs_bsize) 1389789Sahrens 1390789Sahrens #define VTOZONE(vp) ((vp)->v_vfsp->vfs_zone) 1391789Sahrens 13920Sstevel@tonic-gate #define NULLVP ((struct vnode *)0) 13930Sstevel@tonic-gate #define NULLVPP ((struct vnode **)0) 13940Sstevel@tonic-gate 13950Sstevel@tonic-gate #ifdef _KERNEL 13960Sstevel@tonic-gate 13970Sstevel@tonic-gate /* 13980Sstevel@tonic-gate * Structure used while handling asynchronous VOP_PUTPAGE operations. 13990Sstevel@tonic-gate */ 14000Sstevel@tonic-gate struct async_reqs { 14010Sstevel@tonic-gate struct async_reqs *a_next; /* pointer to next arg struct */ 14020Sstevel@tonic-gate struct vnode *a_vp; /* vnode pointer */ 14030Sstevel@tonic-gate u_offset_t a_off; /* offset in file */ 14040Sstevel@tonic-gate uint_t a_len; /* size of i/o request */ 14050Sstevel@tonic-gate int a_flags; /* flags to indicate operation type */ 14060Sstevel@tonic-gate struct cred *a_cred; /* cred pointer */ 14070Sstevel@tonic-gate ushort_t a_prealloced; /* set if struct is pre-allocated */ 14080Sstevel@tonic-gate }; 14090Sstevel@tonic-gate 14100Sstevel@tonic-gate /* 14110Sstevel@tonic-gate * VN_DISPOSE() -- given a page pointer, safely invoke VOP_DISPOSE(). 14128433SMichael.Corcoran@Sun.COM * Note that there is no guarantee that the page passed in will be 14138433SMichael.Corcoran@Sun.COM * freed. If that is required, then a check after calling VN_DISPOSE would 14148433SMichael.Corcoran@Sun.COM * be necessary to ensure the page was freed. 14150Sstevel@tonic-gate */ 14160Sstevel@tonic-gate #define VN_DISPOSE(pp, flag, dn, cr) { \ 14173290Sjohansen if ((pp)->p_vnode != NULL && !VN_ISKAS((pp)->p_vnode)) \ 14185331Samw VOP_DISPOSE((pp)->p_vnode, (pp), (flag), (dn), (cr), NULL); \ 14190Sstevel@tonic-gate else if ((flag) == B_FREE) \ 14200Sstevel@tonic-gate page_free((pp), (dn)); \ 14210Sstevel@tonic-gate else \ 14220Sstevel@tonic-gate page_destroy((pp), (dn)); \ 14230Sstevel@tonic-gate } 14240Sstevel@tonic-gate 14250Sstevel@tonic-gate #endif /* _KERNEL */ 14260Sstevel@tonic-gate 14270Sstevel@tonic-gate #ifdef __cplusplus 14280Sstevel@tonic-gate } 14290Sstevel@tonic-gate #endif 14300Sstevel@tonic-gate 14310Sstevel@tonic-gate #endif /* _SYS_VNODE_H */ 1432