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