1/*	$NetBSD: vnode.h,v 1.235 2011/11/21 04:36:06 christos Exp $	*/
2
3/*-
4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/*
30 * Copyright (c) 1989, 1993
31 *	The Regents of the University of California.  All rights reserved.
32 *
33 * Redistribution and use in source and binary forms, with or without
34 * modification, are permitted provided that the following conditions
35 * are met:
36 * 1. Redistributions of source code must retain the above copyright
37 *    notice, this list of conditions and the following disclaimer.
38 * 2. Redistributions in binary form must reproduce the above copyright
39 *    notice, this list of conditions and the following disclaimer in the
40 *    documentation and/or other materials provided with the distribution.
41 * 3. Neither the name of the University nor the names of its contributors
42 *    may be used to endorse or promote products derived from this software
43 *    without specific prior written permission.
44 *
45 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
46 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
49 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55 * SUCH DAMAGE.
56 *
57 *	@(#)vnode.h	8.17 (Berkeley) 5/20/95
58 */
59
60#ifndef _SYS_VNODE_H_
61#define	_SYS_VNODE_H_
62
63#include <sys/event.h>
64#include <sys/queue.h>
65#include <sys/condvar.h>
66#include <sys/rwlock.h>
67#include <sys/mutex.h>
68
69/* XXX: clean up includes later */
70#include <uvm/uvm_param.h>	/* XXX */
71#include <uvm/uvm_pglist.h>	/* XXX */
72#include <uvm/uvm_object.h>	/* XXX */
73#include <uvm/uvm_extern.h>	/* XXX */
74
75struct namecache;
76struct uvm_ractx;
77
78/*
79 * The vnode is the focus of all file activity in UNIX.  There is a
80 * unique vnode allocated for each active file, each current directory,
81 * each mounted-on file, text file, and the root.
82 */
83
84/*
85 * Vnode types.  VNON means no type.  __VTYPE_DEFINED allows other
86 * sources to override this definition.  __VTYPE_DEFINED should be
87 * considered a temporary feature.
88 */
89#ifndef __VTYPE_DEFINED
90#define __VTYPE_DEFINED
91enum vtype	{ VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VBAD };
92#endif /* __VTYPE_DEFINED */
93
94#define	VNODE_TYPES \
95    "VNON", "VREG", "VDIR", "VBLK", "VCHR", "VLNK", "VSOCK", "VFIFO", "VBAD"
96
97/*
98 * Vnode tag types.
99 * These are for the benefit of external programs only (e.g., pstat)
100 * and should NEVER be inspected by the kernel.
101 */
102enum vtagtype	{
103	VT_NON, VT_UFS, VT_NFS, VT_MFS, VT_MSDOSFS, VT_LFS, VT_LOFS,
104	VT_FDESC, VT_PORTAL, VT_NULL, VT_UMAP, VT_KERNFS, VT_PROCFS,
105	VT_AFS, VT_ISOFS, VT_UNION, VT_ADOSFS, VT_EXT2FS, VT_CODA,
106	VT_FILECORE, VT_NTFS, VT_VFS, VT_OVERLAY, VT_SMBFS, VT_PTYFS,
107	VT_TMPFS, VT_UDF, VT_SYSVBFS, VT_PUFFS, VT_HFS, VT_EFS, VT_ZFS,
108	VT_RUMP, VT_NILFS, VT_V7FS, VT_CHFS
109};
110
111#define	VNODE_TAGS \
112    "VT_NON", "VT_UFS", "VT_NFS", "VT_MFS", "VT_MSDOSFS", "VT_LFS", "VT_LOFS", \
113    "VT_FDESC", "VT_PORTAL", "VT_NULL", "VT_UMAP", "VT_KERNFS", "VT_PROCFS", \
114    "VT_AFS", "VT_ISOFS", "VT_UNION", "VT_ADOSFS", "VT_EXT2FS", "VT_CODA", \
115    "VT_FILECORE", "VT_NTFS", "VT_VFS", "VT_OVERLAY", "VT_SMBFS", "VT_PTYFS", \
116    "VT_TMPFS", "VT_UDF", "VT_SYSVBFS", "VT_PUFFS", "VT_HFS", "VT_EFS", \
117    "VT_ZFS", "VT_RUMP", "VT_NILFS", "VT_V7FS", "VT_CHFS"
118
119struct vnode;
120struct buf;
121
122LIST_HEAD(buflists, buf);
123TAILQ_HEAD(vnodelst, vnode);
124
125/*
126 * Reading or writing any of these items requires holding the appropriate
127 * lock.  Field markings and the corresponding locks:
128 *
129 *	:	stable, reference to the vnode is required
130 *	f	vnode_free_list_lock, or vrele_lock if VI_INACTPEND
131 *	i	v_interlock
132 *	m	mntvnode_lock
133 *	n	namecache_lock
134 *	s	syncer_data_lock
135 *	u	locked by underlying filesystem
136 *	v	vnode lock
137 *	x	v_interlock + bufcache_lock to modify, either to inspect
138 *
139 * Each underlying filesystem allocates its own private area and hangs
140 * it from v_data.
141 */
142struct vnode {
143	struct uvm_object v_uobj;		/* i: the VM object */
144	kcondvar_t	v_cv;			/* i: synchronization */
145	voff_t		v_size;			/* i: size of file */
146	voff_t		v_writesize;		/* i: new size after write */
147	int		v_iflag;		/* i: VI_* flags */
148	int		v_vflag;		/* v: VV_* flags */
149	int		v_uflag;		/* u: VU_* flags */
150	int		v_numoutput;		/* i: # of pending writes */
151	int		v_writecount;		/* i: ref count of writers */
152	int		v_holdcnt;		/* i: page & buffer refs */
153	int		v_synclist_slot;	/* s: synclist slot index */
154	struct mount	*v_mount;		/* v: ptr to vfs we are in */
155	int		(**v_op)(void *);	/* :: vnode operations vector */
156	TAILQ_ENTRY(vnode) v_freelist;		/* f: vnode freelist */
157	struct vnodelst	*v_freelisthd;		/* f: which freelist? */
158	TAILQ_ENTRY(vnode) v_mntvnodes;		/* m: vnodes for mount point */
159	struct buflists	v_cleanblkhd;		/* x: clean blocklist head */
160	struct buflists	v_dirtyblkhd;		/* x: dirty blocklist head */
161	TAILQ_ENTRY(vnode) v_synclist;		/* s: vnodes with dirty bufs */
162	LIST_HEAD(, namecache) v_dnclist;	/* n: namecaches (children) */
163	LIST_HEAD(, namecache) v_nclist;	/* n: namecaches (parent) */
164	union {
165		struct mount	*vu_mountedhere;/* v: ptr to vfs (VDIR) */
166		struct socket	*vu_socket;	/* v: unix ipc (VSOCK) */
167		struct specnode	*vu_specnode;	/* v: device (VCHR, VBLK) */
168		struct fifoinfo	*vu_fifoinfo;	/* v: fifo (VFIFO) */
169		struct uvm_ractx *vu_ractx;	/* i: read-ahead ctx (VREG) */
170	} v_un;
171	enum vtype	v_type;			/* :: vnode type */
172	enum vtagtype	v_tag;			/* :: type of underlying data */
173	krwlock_t	v_lock;			/* v: lock for this vnode */
174	void 		*v_data;		/* :: private data for fs */
175	struct klist	v_klist;		/* i: notes attached to vnode */
176};
177#define	v_usecount	v_uobj.uo_refs
178#define	v_interlock	v_uobj.vmobjlock
179#define	v_mountedhere	v_un.vu_mountedhere
180#define	v_socket	v_un.vu_socket
181#define	v_specnode	v_un.vu_specnode
182#define	v_fifoinfo	v_un.vu_fifoinfo
183#define	v_ractx		v_un.vu_ractx
184
185typedef struct vnodelst vnodelst_t;
186typedef struct vnode vnode_t;
187
188/*
189 * Vnode flags.  The first set are locked by vnode lock or are stable.
190 * VSYSTEM is only used to skip vflush()ing quota files.  VISTTY is used
191 * when reading dead vnodes.
192 */
193#define	VV_ROOT		0x00000001	/* root of its file system */
194#define	VV_SYSTEM	0x00000002	/* vnode being used by kernel */
195#define	VV_ISTTY	0x00000004	/* vnode represents a tty */
196#define	VV_MAPPED	0x00000008	/* vnode might have user mappings */
197#define	VV_MPSAFE	0x00000010	/* file system code is MP safe */
198#define	VV_LOCKSWORK	0x00000020	/* FS supports locking discipline */
199
200/*
201 * The second set are locked by vp->v_interlock.
202 */
203#define	VI_TEXT		0x00000100	/* vnode is a pure text prototype */
204#define	VI_EXECMAP	0x00000200	/* might have PROT_EXEC mappings */
205#define	VI_WRMAP	0x00000400	/* might have PROT_WRITE u. mappings */
206#define	VI_WRMAPDIRTY	0x00000800	/* might have dirty pages */
207#define	VI_XLOCK	0x00001000	/* vnode is locked to change type */
208#define	VI_ONWORKLST	0x00004000	/* On syncer work-list */
209#define	VI_MARKER	0x00008000	/* Dummy marker vnode */
210#define	VI_LAYER	0x00020000	/* vnode is on a layer filesystem */
211#define	VI_LOCKSHARE	0x00040000	/* v_interlock is shared */
212#define	VI_CLEAN	0x00080000	/* has been reclaimed */
213#define	VI_INACTPEND	0x00100000	/* inactivation is pending */
214#define	VI_INACTREDO	0x00200000	/* need to redo VOP_INACTIVE() */
215#define	VI_INACTNOW	0x00800000	/* VOP_INACTIVE() in progress */
216
217/*
218 * The third set are locked by the underlying file system.
219 */
220#define	VU_DIROP	0x01000000	/* LFS: involved in a directory op */
221
222#define	VNODE_FLAGBITS \
223    "\20\1ROOT\2SYSTEM\3ISTTY\4MAPPED\5MPSAFE\6LOCKSWORK\11TEXT\12EXECMAP" \
224    "\13WRMAP\14WRMAPDIRTY\15XLOCK\17ONWORKLST\20MARKER" \
225    "\22LAYER\24CLEAN\25INACTPEND\26INACTREDO" \
226    "\30INACTNOW\31DIROP"
227
228#define	VSIZENOTSET	((voff_t)-1)
229
230/*
231 * v_usecount; see the comment near the top of vfs_vnode.c
232 */
233#define	VC_XLOCK	0x80000000
234#define	VC_MASK		0x7fffffff
235
236/*
237 * vnode lock flags
238 */
239#define	LK_SHARED	0x00000001	/* shared lock */
240#define	LK_EXCLUSIVE	0x00000002	/* exclusive lock */
241#define	LK_NOWAIT	0x00000010	/* do not sleep to await lock */
242#define	LK_RETRY	0x00020000	/* vn_lock: retry until locked */
243
244/*
245 * Vnode attributes.  A field value of VNOVAL represents a field whose value
246 * is unavailable (getattr) or which is not to be changed (setattr).
247 */
248struct vattr {
249	enum vtype	va_type;	/* vnode type (for create) */
250	mode_t		va_mode;	/* files access mode and type */
251	nlink_t		va_nlink;	/* number of references to file */
252	uid_t		va_uid;		/* owner user id */
253	gid_t		va_gid;		/* owner group id */
254	dev_t		va_fsid;	/* file system id (dev for now) */
255	ino_t		va_fileid;	/* file id */
256	u_quad_t	va_size;	/* file size in bytes */
257	long		va_blocksize;	/* blocksize preferred for i/o */
258	struct timespec	va_atime;	/* time of last access */
259	struct timespec	va_mtime;	/* time of last modification */
260	struct timespec	va_ctime;	/* time file changed */
261	struct timespec va_birthtime;	/* time file created */
262	u_long		va_gen;		/* generation number of file */
263	u_long		va_flags;	/* flags defined for file */
264	dev_t		va_rdev;	/* device the special file represents */
265	u_quad_t	va_bytes;	/* bytes of disk space held by file */
266	u_quad_t	va_filerev;	/* file modification number */
267	u_int		va_vaflags;	/* operations flags, see below */
268	long		va_spare;	/* remain quad aligned */
269};
270
271/*
272 * Flags for va_vaflags.
273 */
274#define	VA_UTIMES_NULL	0x01		/* utimes argument was NULL */
275#define	VA_EXCLUSIVE	0x02		/* exclusive create request */
276
277#ifdef _KERNEL
278
279/*
280 * Flags for ioflag.
281 */
282#define	IO_UNIT		0x00010		/* do I/O as atomic unit */
283#define	IO_APPEND	0x00020		/* append write to end */
284#define	IO_SYNC		(0x40|IO_DSYNC)	/* sync I/O file integrity completion */
285#define	IO_NODELOCKED	0x00080		/* underlying node already locked */
286#define	IO_NDELAY	0x00100		/* FNDELAY flag set in file table */
287#define	IO_DSYNC	0x00200		/* sync I/O data integrity completion */
288#define	IO_ALTSEMANTICS	0x00400		/* use alternate i/o semantics */
289#define	IO_NORMAL	0x00800		/* operate on regular data */
290#define	IO_EXT		0x01000		/* operate on extended attributes */
291#define	IO_DIRECT	0x02000		/* direct I/O hint */
292#define	IO_JOURNALLOCKED 0x04000	/* journal is already locked */
293#define	IO_ADV_MASK	0x00003		/* access pattern hint */
294
295#define	IO_ADV_SHIFT	0
296#define	IO_ADV_ENCODE(adv)	(((adv) << IO_ADV_SHIFT) & IO_ADV_MASK)
297#define	IO_ADV_DECODE(ioflag)	(((ioflag) & IO_ADV_MASK) >> IO_ADV_SHIFT)
298
299/*
300 *  Modes.
301 */
302#define	VREAD	00004		/* read, write, execute permissions */
303#define	VWRITE	00002
304#define	VEXEC	00001
305
306/*
307 * Token indicating no attribute value yet assigned.
308 */
309#define	VNOVAL	(-1)
310
311/*
312 * Convert between vnode types and inode formats (since POSIX.1
313 * defines mode word of stat structure in terms of inode formats).
314 */
315extern const enum vtype	iftovt_tab[];
316extern const int	vttoif_tab[];
317#define	IFTOVT(mode)	(iftovt_tab[((mode) & S_IFMT) >> 12])
318#define	VTTOIF(indx)	(vttoif_tab[(int)(indx)])
319#define	MAKEIMODE(indx, mode)	(int)(VTTOIF(indx) | (mode))
320
321/*
322 * Flags to various vnode functions.
323 */
324#define	SKIPSYSTEM	0x0001		/* vflush: skip vnodes marked VSYSTEM */
325#define	FORCECLOSE	0x0002		/* vflush: force file closeure */
326#define	WRITECLOSE	0x0004		/* vflush: only close writable files */
327#define	DOCLOSE		0x0008		/* vclean: close active files */
328#define	V_SAVE		0x0001		/* vinvalbuf: sync file first */
329
330/*
331 * Flags to various vnode operations.
332 */
333#define	REVOKEALL	0x0001		/* revoke: revoke all aliases */
334
335#define	FSYNC_WAIT	0x0001		/* fsync: wait for completion */
336#define	FSYNC_DATAONLY	0x0002		/* fsync: hint: sync file data only */
337#define	FSYNC_RECLAIM	0x0004		/* fsync: hint: vnode is being reclaimed */
338#define	FSYNC_LAZY	0x0008		/* fsync: lazy sync (trickle) */
339#define	FSYNC_NOLOG	0x0010		/* fsync: do not flush the log */
340#define	FSYNC_CACHE	0x0100		/* fsync: flush disk caches too */
341
342#define	UPDATE_WAIT	0x0001		/* update: wait for completion */
343#define	UPDATE_DIROP	0x0002		/* update: hint to fs to wait or not */
344#define	UPDATE_CLOSE	0x0004		/* update: clean up on close */
345
346void holdrelel(struct vnode *);
347void vholdl(struct vnode *);
348void vref(struct vnode *);
349
350static __inline void holdrele(struct vnode *) __unused;
351static __inline void vhold(struct vnode *) __unused;
352
353/*
354 * decrease buf or page ref
355 */
356static __inline void
357holdrele(struct vnode *vp)
358{
359
360	mutex_enter(vp->v_interlock);
361	holdrelel(vp);
362	mutex_exit(vp->v_interlock);
363}
364
365/*
366 * increase buf or page ref
367 */
368static __inline void
369vhold(struct vnode *vp)
370{
371
372	mutex_enter(vp->v_interlock);
373	vholdl(vp);
374	mutex_exit(vp->v_interlock);
375}
376
377static __inline bool
378vismarker(struct vnode *vp)
379{
380
381	return (vp->v_iflag & VI_MARKER) != 0;
382}
383
384#define	NULLVP	((struct vnode *)NULL)
385
386static __inline void
387VN_KNOTE(struct vnode *vp, long hint)
388{
389
390	mutex_enter(vp->v_interlock);
391	KNOTE(&vp->v_klist, hint);
392	mutex_exit(vp->v_interlock);
393}
394
395/*
396 * Global vnode data.
397 */
398extern struct vnode	*rootvnode;	/* root (i.e. "/") vnode */
399extern int		desiredvnodes;	/* number of vnodes desired */
400extern u_int		numvnodes;	/* current number of vnodes */
401
402/*
403 * Macro/function to check for client cache inconsistency w.r.t. leasing.
404 */
405#define	LEASE_READ	0x1		/* Check lease for readers */
406#define	LEASE_WRITE	0x2		/* Check lease for modifiers */
407
408#endif /* _KERNEL */
409
410
411/*
412 * Mods for exensibility.
413 */
414
415/*
416 * Flags for vdesc_flags:
417 */
418#define	VDESC_MAX_VPS		8
419/* Low order 16 flag bits are reserved for willrele flags for vp arguments. */
420#define	VDESC_VP0_WILLRELE	0x00000001
421#define	VDESC_VP1_WILLRELE	0x00000002
422#define	VDESC_VP2_WILLRELE	0x00000004
423#define	VDESC_VP3_WILLRELE	0x00000008
424#define	VDESC_VP0_WILLUNLOCK	0x00000100
425#define	VDESC_VP1_WILLUNLOCK	0x00000200
426#define	VDESC_VP2_WILLUNLOCK	0x00000400
427#define	VDESC_VP3_WILLUNLOCK	0x00000800
428#define	VDESC_VP0_WILLPUT	0x00000101
429#define	VDESC_VP1_WILLPUT	0x00000202
430#define	VDESC_VP2_WILLPUT	0x00000404
431#define	VDESC_VP3_WILLPUT	0x00000808
432
433/*
434 * VDESC_NO_OFFSET is used to identify the end of the offset list
435 * and in places where no such field exists.
436 */
437#define	VDESC_NO_OFFSET -1
438
439/*
440 * This structure describes the vnode operation taking place.
441 */
442struct vnodeop_desc {
443	int		vdesc_offset;	/* offset in vector--first for speed */
444	const char	*vdesc_name;	/* a readable name for debugging */
445	int		vdesc_flags;	/* VDESC_* flags */
446
447	/*
448	 * These ops are used by bypass routines to map and locate arguments.
449	 * Creds and procs are not needed in bypass routines, but sometimes
450	 * they are useful to (for example) transport layers.
451	 * Nameidata is useful because it has a cred in it.
452	 */
453	const int	*vdesc_vp_offsets;	/* list ended by VDESC_NO_OFFSET */
454	int		vdesc_vpp_offset;	/* return vpp location */
455	int		vdesc_cred_offset;	/* cred location, if any */
456	int		vdesc_componentname_offset; /* if any */
457};
458
459#ifdef _KERNEL
460
461/*
462 * Interlock for scanning list of vnodes attached to a mountpoint
463 */
464extern kmutex_t		mntvnode_lock;
465
466/*
467 * Union filesystem hook for vn_readdir().
468 */
469extern int (*vn_union_readdir_hook) (struct vnode **, struct file *, struct lwp *);
470
471/*
472 * Macros for offsets in the vdesc struct.
473 */
474#define	VOPARG_OFFSETOF(type, member)	offsetof(type, member)
475#define	VOPARG_OFFSETTO(type,offset,sp)	((type)(((char *)(sp)) + (offset)))
476
477/*
478 * This structure is used to configure the new vnodeops vector.
479 */
480struct vnodeopv_entry_desc {
481	const struct vnodeop_desc *opve_op;	/* which operation this is */
482	int (*opve_impl)(void *);	/* code implementing this operation */
483};
484
485struct vnodeopv_desc {
486			/* ptr to the ptr to the vector where op should go */
487	int (***opv_desc_vector_p)(void *);
488	const struct vnodeopv_entry_desc *opv_desc_ops; /* null terminated list */
489};
490
491/*
492 * A default routine which just returns an error.
493 */
494int vn_default_error(void *);
495
496/*
497 * A generic structure.
498 * This can be used by bypass routines to identify generic arguments.
499 */
500struct vop_generic_args {
501	struct vnodeop_desc *a_desc;
502	/* other random data follows, presumably */
503};
504
505/*
506 * VOCALL calls an op given an ops vector.  We break it out because BSD's
507 * vclean changes the ops vector and then wants to call ops with the old
508 * vector.
509 */
510/*
511 * actually, vclean doesn't use it anymore, but nfs does,
512 * for device specials and fifos.
513 */
514#define	VOCALL(OPSV,OFF,AP) (( *((OPSV)[(OFF)])) (AP))
515
516/*
517 * This call works for vnodes in the kernel.
518 */
519#define	VCALL(VP,OFF,AP) VOCALL((VP)->v_op,(OFF),(AP))
520#define	VDESC(OP) (& __CONCAT(OP,_desc))
521#define	VOFFSET(OP) (VDESC(OP)->vdesc_offset)
522
523/* XXX This include should go away */
524#include <sys/mount.h>
525
526/*
527 * Finally, include the default set of vnode operations.
528 */
529#include <sys/vnode_if.h>
530
531/*
532 * Public vnode manipulation functions.
533 */
534struct file;
535struct filedesc;
536struct nameidata;
537struct proc;
538struct stat;
539struct uio;
540struct vattr;
541struct vnode;
542
543/* see vnode(9) */
544void	vfs_vnode_sysinit(void);
545int 	bdevvp(dev_t, struct vnode **);
546int 	cdevvp(dev_t, struct vnode **);
547int 	getnewvnode(enum vtagtype, struct mount *, int (**)(void *),
548	    kmutex_t *, struct vnode **);
549void	ungetnewvnode(struct vnode *);
550int	vaccess(enum vtype, mode_t, uid_t, gid_t, mode_t, kauth_cred_t);
551void 	vattr_null(struct vattr *);
552void	vdevgone(int, int, int, enum vtype);
553int	vfinddev(dev_t, enum vtype, struct vnode **);
554int	vflush(struct mount *, struct vnode *, int);
555int	vflushbuf(struct vnode *, int);
556int 	vget(struct vnode *, int);
557bool	vtryget(struct vnode *);
558void 	vgone(struct vnode *);
559int	vinvalbuf(struct vnode *, int, kauth_cred_t, struct lwp *, bool, int);
560void	vprint(const char *, struct vnode *);
561void 	vput(struct vnode *);
562int	vrecycle(struct vnode *, kmutex_t *, struct lwp *);
563void 	vrele(struct vnode *);
564void 	vrele_async(struct vnode *);
565void	vrele_flush(void);
566int	vtruncbuf(struct vnode *, daddr_t, bool, int);
567void	vwakeup(struct buf *);
568void	vwait(struct vnode *, int);
569void	vclean(struct vnode *, int);
570void	vrevoke(struct vnode *);
571void	vrelel(struct vnode *, int);
572#define VRELEL_ASYNC_RELE	0x03
573struct vnode *
574	vnalloc(struct mount *);
575void	vnfree(struct vnode *);
576void	vmark(struct vnode *, struct vnode *);
577struct vnode *
578	vunmark(struct vnode *);
579void	vremfree(struct vnode *);
580
581/* see vnsubr(9) */
582int	vn_bwrite(void *);
583int 	vn_close(struct vnode *, int, kauth_cred_t);
584int	vn_isunder(struct vnode *, struct vnode *, struct lwp *);
585int	vn_lock(struct vnode *, int);
586void	vn_markexec(struct vnode *);
587int	vn_marktext(struct vnode *);
588int 	vn_open(struct nameidata *, int, int);
589int 	vn_rdwr(enum uio_rw, struct vnode *, void *, int, off_t, enum uio_seg,
590    int, kauth_cred_t, size_t *, struct lwp *);
591int	vn_readdir(struct file *, char *, int, u_int, int *, struct lwp *,
592    off_t **, int *);
593int	vn_stat(struct vnode *, struct stat *);
594int	vn_kqfilter(struct file *, struct knote *);
595int	vn_writechk(struct vnode *);
596int	vn_openchk(struct vnode *, kauth_cred_t, int);
597int	vn_extattr_get(struct vnode *, int, int, const char *, size_t *,
598	    void *, struct lwp *);
599int	vn_extattr_set(struct vnode *, int, int, const char *, size_t,
600	    const void *, struct lwp *);
601int	vn_extattr_rm(struct vnode *, int, int, const char *, struct lwp *);
602void	vn_ra_allocctx(struct vnode *);
603int	vn_fifo_bypass(void *);
604
605/* initialise global vnode management */
606void	vntblinit(void);
607
608/* misc stuff */
609void	vn_syncer_add_to_worklist(struct vnode *, int);
610void	vn_syncer_remove_from_worklist(struct vnode *);
611int	speedup_syncer(void);
612int	dorevoke(struct vnode *, kauth_cred_t);
613int	rawdev_mounted(struct vnode *, struct vnode **);
614uint8_t	vtype2dt(enum vtype);
615
616/* see vfssubr(9) */
617void	vfs_getnewfsid(struct mount *);
618int	vfs_drainvnodes(long);
619void	vfs_timestamp(struct timespec *);
620#if defined(DDB) || defined(DEBUGPRINT)
621void	vfs_vnode_print(struct vnode *, int, void (*)(const char *, ...)
622    __printflike(1, 2));
623void	vfs_mount_print(struct mount *, int, void (*)(const char *, ...)
624    __printflike(1, 2));
625#endif /* DDB */
626
627#endif /* _KERNEL */
628
629#endif /* !_SYS_VNODE_H_ */
630