1 /*	$NetBSD: vnode.h,v 1.263 2016/06/03 15:15:49 dholland 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 #include <sys/time.h>
69 
70 /* XXX: clean up includes later */
71 #include <uvm/uvm_param.h>	/* XXX */
72 #if defined(_KERNEL) || defined(_KMEMUSER)
73 #include <uvm/uvm_pglist.h>	/* XXX */
74 #include <uvm/uvm_object.h>	/* XXX */
75 #include <uvm/uvm_extern.h>	/* XXX */
76 
77 struct namecache;
78 struct uvm_ractx;
79 #endif
80 
81 /*
82  * The vnode is the focus of all file activity in UNIX.  There is a
83  * unique vnode allocated for each active file, each current directory,
84  * each mounted-on file, text file, and the root.
85  */
86 
87 /*
88  * Vnode types.  VNON means no type.
89  */
90 enum vtype	{ VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VBAD };
91 
92 #define	VNODE_TYPES \
93     "VNON", "VREG", "VDIR", "VBLK", "VCHR", "VLNK", "VSOCK", "VFIFO", "VBAD"
94 
95 /*
96  * Vnode tag types.
97  * These are for the benefit of external programs only (e.g., pstat)
98  * and should NEVER be inspected by the kernel.
99  */
100 enum vtagtype	{
101 	VT_NON, VT_UFS, VT_NFS, VT_MFS, VT_MSDOSFS, VT_LFS, VT_LOFS,
102 	VT_FDESC, VT_PORTAL, VT_NULL, VT_UMAP, VT_KERNFS, VT_PROCFS,
103 	VT_AFS, VT_ISOFS, VT_UNION, VT_ADOSFS, VT_EXT2FS, VT_CODA,
104 	VT_FILECORE, VT_NTFS, VT_VFS, VT_OVERLAY, VT_SMBFS, VT_PTYFS,
105 	VT_TMPFS, VT_UDF, VT_SYSVBFS, VT_PUFFS, VT_HFS, VT_EFS, VT_ZFS,
106 	VT_RUMP, VT_NILFS, VT_V7FS, VT_CHFS
107 };
108 
109 #define	VNODE_TAGS \
110     "VT_NON", "VT_UFS", "VT_NFS", "VT_MFS", "VT_MSDOSFS", "VT_LFS", "VT_LOFS", \
111     "VT_FDESC", "VT_PORTAL", "VT_NULL", "VT_UMAP", "VT_KERNFS", "VT_PROCFS", \
112     "VT_AFS", "VT_ISOFS", "VT_UNION", "VT_ADOSFS", "VT_EXT2FS", "VT_CODA", \
113     "VT_FILECORE", "VT_NTFS", "VT_VFS", "VT_OVERLAY", "VT_SMBFS", "VT_PTYFS", \
114     "VT_TMPFS", "VT_UDF", "VT_SYSVBFS", "VT_PUFFS", "VT_HFS", "VT_EFS", \
115     "VT_ZFS", "VT_RUMP", "VT_NILFS", "VT_V7FS", "VT_CHFS"
116 
117 #if defined(_KERNEL) || defined(_KMEMUSER)
118 struct vnode;
119 struct buf;
120 
121 LIST_HEAD(buflists, buf);
122 TAILQ_HEAD(vnodelst, vnode);
123 
124 /*
125  * Reading or writing any of these items requires holding the appropriate
126  * lock.  Field markings and the corresponding locks:
127  *
128  *	:	stable, reference to the vnode is required
129  *	f	vnode_free_list_lock, or vrele_lock for vrele_list
130  *	i	v_interlock
131  *	m	mntvnode_lock
132  *	n	namecache_lock
133  *	s	syncer_data_lock
134  *	u	locked by underlying filesystem
135  *	v	vnode lock
136  *	x	v_interlock + bufcache_lock to modify, either to inspect
137  *
138  * Each underlying filesystem allocates its own private area and hangs
139  * it from v_data.
140  */
141 struct vnode {
142 	struct uvm_object v_uobj;		/* i: the VM object */
143 	kcondvar_t	v_cv;			/* i: synchronization */
144 	voff_t		v_size;			/* i: size of file */
145 	voff_t		v_writesize;		/* i: new size after write */
146 	int		v_iflag;		/* i: VI_* flags */
147 	int		v_vflag;		/* v: VV_* flags */
148 	int		v_uflag;		/* u: VU_* flags */
149 	int		v_numoutput;		/* i: # of pending writes */
150 	int		v_writecount;		/* i: ref count of writers */
151 	int		v_holdcnt;		/* i: page & buffer refs */
152 	int		v_synclist_slot;	/* s: synclist slot index */
153 	struct mount	*v_mount;		/* v: ptr to vfs we are in */
154 	int		(**v_op)(void *);	/* :: vnode operations vector */
155 	TAILQ_ENTRY(vnode) v_freelist;		/* f: vnode freelist */
156 	struct vnodelst	*v_freelisthd;		/* f: which freelist? */
157 	TAILQ_ENTRY(vnode) v_mntvnodes;		/* m: vnodes for mount point */
158 	struct buflists	v_cleanblkhd;		/* x: clean blocklist head */
159 	struct buflists	v_dirtyblkhd;		/* x: dirty blocklist head */
160 	TAILQ_ENTRY(vnode) v_synclist;		/* s: vnodes with dirty bufs */
161 	LIST_HEAD(, namecache) v_dnclist;	/* n: namecaches (children) */
162 	LIST_HEAD(, namecache) v_nclist;	/* n: namecaches (parent) */
163 	union {
164 		struct mount	*vu_mountedhere;/* v: ptr to vfs (VDIR) */
165 		struct socket	*vu_socket;	/* v: unix ipc (VSOCK) */
166 		struct specnode	*vu_specnode;	/* v: device (VCHR, VBLK) */
167 		struct fifoinfo	*vu_fifoinfo;	/* v: fifo (VFIFO) */
168 		struct uvm_ractx *vu_ractx;	/* i: read-ahead ctx (VREG) */
169 	} v_un;
170 	enum vtype	v_type;			/* :: vnode type */
171 	enum vtagtype	v_tag;			/* :: type of underlying data */
172 	krwlock_t	v_lock;			/* v: lock for this vnode */
173 	void 		*v_data;		/* :: private data for fs */
174 	struct klist	v_klist;		/* i: notes attached to vnode */
175 };
176 #define	v_usecount	v_uobj.uo_refs
177 #define	v_interlock	v_uobj.vmobjlock
178 #define	v_mountedhere	v_un.vu_mountedhere
179 #define	v_socket	v_un.vu_socket
180 #define	v_specnode	v_un.vu_specnode
181 #define	v_fifoinfo	v_un.vu_fifoinfo
182 #define	v_ractx		v_un.vu_ractx
183 
184 typedef struct vnodelst vnodelst_t;
185 typedef struct vnode vnode_t;
186 #endif
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_ONWORKLST	0x00004000	/* On syncer work-list */
208 
209 /*
210  * The third set are locked by the underlying file system.
211  */
212 #define	VU_DIROP	0x01000000	/* LFS: involved in a directory op */
213 
214 #define	VNODE_FLAGBITS \
215     "\20\1ROOT\2SYSTEM\3ISTTY\4MAPPED\5MPSAFE\6LOCKSWORK\11TEXT\12EXECMAP" \
216     "\13WRMAP\14WRMAPDIRTY\17ONWORKLST\31DIROP"
217 
218 #define	VSIZENOTSET	((voff_t)-1)
219 
220 /*
221  * vnode lock flags
222  */
223 #define	LK_SHARED	0x00000001	/* shared lock */
224 #define	LK_EXCLUSIVE	0x00000002	/* exclusive lock */
225 #define	LK_NOWAIT	0x00000010	/* do not sleep to await lock */
226 #define	LK_RETRY	0x00020000	/* vn_lock: retry until locked */
227 
228 /*
229  * Vnode attributes.  A field value of VNOVAL represents a field whose value
230  * is unavailable (getattr) or which is not to be changed (setattr).
231  */
232 struct vattr {
233 	enum vtype	va_type;	/* vnode type (for create) */
234 	mode_t		va_mode;	/* files access mode and type */
235 	nlink_t		va_nlink;	/* number of references to file */
236 	uid_t		va_uid;		/* owner user id */
237 	gid_t		va_gid;		/* owner group id */
238 	dev_t		va_fsid;	/* file system id (dev for now) */
239 	ino_t		va_fileid;	/* file id */
240 	u_quad_t	va_size;	/* file size in bytes */
241 	long		va_blocksize;	/* blocksize preferred for i/o */
242 	struct timespec	va_atime;	/* time of last access */
243 	struct timespec	va_mtime;	/* time of last modification */
244 	struct timespec	va_ctime;	/* time file changed */
245 	struct timespec va_birthtime;	/* time file created */
246 	u_long		va_gen;		/* generation number of file */
247 	u_long		va_flags;	/* flags defined for file */
248 	dev_t		va_rdev;	/* device the special file represents */
249 	u_quad_t	va_bytes;	/* bytes of disk space held by file */
250 	u_quad_t	va_filerev;	/* file modification number */
251 	unsigned int	va_vaflags;	/* operations flags, see below */
252 	long		va_spare;	/* remain quad aligned */
253 };
254 
255 /*
256  * Flags for va_vaflags.
257  */
258 #define	VA_UTIMES_NULL	0x01		/* utimes argument was NULL */
259 #define	VA_EXCLUSIVE	0x02		/* exclusive create request */
260 
261 #ifdef _KERNEL
262 
263 /*
264  * Flags for ioflag.
265  */
266 #define	IO_UNIT		0x00010		/* do I/O as atomic unit */
267 #define	IO_APPEND	0x00020		/* append write to end */
268 #define	IO_SYNC		(0x40|IO_DSYNC)	/* sync I/O file integrity completion */
269 #define	IO_NODELOCKED	0x00080		/* underlying node already locked */
270 #define	IO_NDELAY	0x00100		/* FNDELAY flag set in file table */
271 #define	IO_DSYNC	0x00200		/* sync I/O data integrity completion */
272 #define	IO_ALTSEMANTICS	0x00400		/* use alternate i/o semantics */
273 #define	IO_NORMAL	0x00800		/* operate on regular data */
274 #define	IO_EXT		0x01000		/* operate on extended attributes */
275 #define	IO_DIRECT	0x02000		/* direct I/O hint */
276 #define	IO_JOURNALLOCKED 0x04000	/* journal is already locked */
277 #define	IO_ADV_MASK	0x00003		/* access pattern hint */
278 
279 #define	IO_ADV_SHIFT	0
280 #define	IO_ADV_ENCODE(adv)	(((adv) << IO_ADV_SHIFT) & IO_ADV_MASK)
281 #define	IO_ADV_DECODE(ioflag)	(((ioflag) & IO_ADV_MASK) >> IO_ADV_SHIFT)
282 
283 /*
284  *  Modes.
285  */
286 #define	VREAD	00004		/* read, write, execute permissions */
287 #define	VWRITE	00002
288 #define	VEXEC	00001
289 
290 /*
291  * Token indicating no attribute value yet assigned.
292  */
293 #define	VNOVAL	(-1)
294 
295 /*
296  * Convert between vnode types and inode formats (since POSIX.1
297  * defines mode word of stat structure in terms of inode formats).
298  */
299 extern const enum vtype	iftovt_tab[];
300 extern const int	vttoif_tab[];
301 #define	IFTOVT(mode)	(iftovt_tab[((mode) & S_IFMT) >> 12])
302 #define	VTTOIF(indx)	(vttoif_tab[(int)(indx)])
303 #define	MAKEIMODE(indx, mode)	(int)(VTTOIF(indx) | (mode))
304 
305 /*
306  * Flags to various vnode functions.
307  */
308 #define	SKIPSYSTEM	0x0001		/* vflush: skip vnodes marked VSYSTEM */
309 #define	FORCECLOSE	0x0002		/* vflush: force file closeure */
310 #define	WRITECLOSE	0x0004		/* vflush: only close writable files */
311 #define	V_SAVE		0x0001		/* vinvalbuf: sync file first */
312 
313 /*
314  * Flags to various vnode operations.
315  */
316 #define	REVOKEALL	0x0001		/* revoke: revoke all aliases */
317 
318 #define	FSYNC_WAIT	0x0001		/* fsync: wait for completion */
319 #define	FSYNC_DATAONLY	0x0002		/* fsync: hint: sync file data only */
320 #define	FSYNC_RECLAIM	0x0004		/* fsync: hint: vnode is being reclaimed */
321 #define	FSYNC_LAZY	0x0008		/* fsync: lazy sync (trickle) */
322 #define	FSYNC_NOLOG	0x0010		/* fsync: do not flush the log */
323 #define	FSYNC_CACHE	0x0100		/* fsync: flush disk caches too */
324 
325 #define	UPDATE_WAIT	0x0001		/* update: wait for completion */
326 #define	UPDATE_DIROP	0x0002		/* update: hint to fs to wait or not */
327 #define	UPDATE_CLOSE	0x0004		/* update: clean up on close */
328 
329 #define VDEAD_NOWAIT	0x0001		/* vdead_check: do not sleep */
330 
331 void holdrelel(struct vnode *);
332 void vholdl(struct vnode *);
333 void vref(struct vnode *);
334 
335 static __inline void holdrele(struct vnode *) __unused;
336 static __inline void vhold(struct vnode *) __unused;
337 
338 /*
339  * decrease buf or page ref
340  */
341 static __inline void
holdrele(struct vnode * vp)342 holdrele(struct vnode *vp)
343 {
344 
345 	mutex_enter(vp->v_interlock);
346 	holdrelel(vp);
347 	mutex_exit(vp->v_interlock);
348 }
349 
350 /*
351  * increase buf or page ref
352  */
353 static __inline void
vhold(struct vnode * vp)354 vhold(struct vnode *vp)
355 {
356 
357 	mutex_enter(vp->v_interlock);
358 	vholdl(vp);
359 	mutex_exit(vp->v_interlock);
360 }
361 
362 #define	NULLVP	((struct vnode *)NULL)
363 
364 static __inline void
VN_KNOTE(struct vnode * vp,long hint)365 VN_KNOTE(struct vnode *vp, long hint)
366 {
367 
368 	mutex_enter(vp->v_interlock);
369 	KNOTE(&vp->v_klist, hint);
370 	mutex_exit(vp->v_interlock);
371 }
372 
373 /*
374  * Global vnode data.
375  */
376 extern struct vnode	*rootvnode;	/* root (i.e. "/") vnode */
377 extern int		desiredvnodes;	/* number of vnodes desired */
378 extern unsigned int	numvnodes;	/* current number of vnodes */
379 
380 #endif /* _KERNEL */
381 
382 
383 /*
384  * Mods for exensibility.
385  */
386 
387 /*
388  * Flags for vdesc_flags:
389  */
390 #define	VDESC_MAX_VPS		8
391 /* Low order 16 flag bits are reserved for willrele flags for vp arguments. */
392 #define	VDESC_VP0_WILLRELE	0x00000001
393 #define	VDESC_VP1_WILLRELE	0x00000002
394 #define	VDESC_VP2_WILLRELE	0x00000004
395 #define	VDESC_VP3_WILLRELE	0x00000008
396 #define	VDESC_VP0_WILLUNLOCK	0x00000100
397 #define	VDESC_VP1_WILLUNLOCK	0x00000200
398 #define	VDESC_VP2_WILLUNLOCK	0x00000400
399 #define	VDESC_VP3_WILLUNLOCK	0x00000800
400 #define	VDESC_VP0_WILLPUT	0x00000101
401 #define	VDESC_VP1_WILLPUT	0x00000202
402 #define	VDESC_VP2_WILLPUT	0x00000404
403 #define	VDESC_VP3_WILLPUT	0x00000808
404 
405 /*
406  * VDESC_NO_OFFSET is used to identify the end of the offset list
407  * and in places where no such field exists.
408  */
409 #define	VDESC_NO_OFFSET -1
410 
411 /*
412  * This structure describes the vnode operation taking place.
413  */
414 struct vnodeop_desc {
415 	int		vdesc_offset;	/* offset in vector--first for speed */
416 	const char	*vdesc_name;	/* a readable name for debugging */
417 	int		vdesc_flags;	/* VDESC_* flags */
418 
419 	/*
420 	 * These ops are used by bypass routines to map and locate arguments.
421 	 * Creds and procs are not needed in bypass routines, but sometimes
422 	 * they are useful to (for example) transport layers.
423 	 * Nameidata is useful because it has a cred in it.
424 	 */
425 	const int	*vdesc_vp_offsets;	/* list ended by VDESC_NO_OFFSET */
426 	int		vdesc_vpp_offset;	/* return vpp location */
427 	int		vdesc_cred_offset;	/* cred location, if any */
428 	int		vdesc_componentname_offset; /* if any */
429 };
430 
431 #ifdef _KERNEL
432 
433 /*
434  * Interlock for scanning list of vnodes attached to a mountpoint
435  */
436 extern kmutex_t		mntvnode_lock;
437 
438 /*
439  * Union filesystem hook for vn_readdir().
440  */
441 extern int (*vn_union_readdir_hook) (struct vnode **, struct file *, struct lwp *);
442 
443 /*
444  * Macros for offsets in the vdesc struct.
445  */
446 #define	VOPARG_OFFSETOF(type, member)	offsetof(type, member)
447 #define	VOPARG_OFFSETTO(type,offset,sp)	((type)(((char *)(sp)) + (offset)))
448 
449 /*
450  * This structure is used to configure the new vnodeops vector.
451  */
452 struct vnodeopv_entry_desc {
453 	const struct vnodeop_desc *opve_op;	/* which operation this is */
454 	int (*opve_impl)(void *);	/* code implementing this operation */
455 };
456 
457 struct vnodeopv_desc {
458 			/* ptr to the ptr to the vector where op should go */
459 	int (***opv_desc_vector_p)(void *);
460 	const struct vnodeopv_entry_desc *opv_desc_ops; /* null terminated list */
461 };
462 
463 /*
464  * A default routine which just returns an error.
465  */
466 int vn_default_error(void *);
467 
468 /*
469  * A generic structure.
470  * This can be used by bypass routines to identify generic arguments.
471  */
472 struct vop_generic_args {
473 	struct vnodeop_desc *a_desc;
474 	/* other random data follows, presumably */
475 };
476 
477 /*
478  * VOCALL calls an op given an ops vector.  We break it out because BSD's
479  * vclean changes the ops vector and then wants to call ops with the old
480  * vector.
481  */
482 /*
483  * actually, vclean doesn't use it anymore, but nfs does,
484  * for device specials and fifos.
485  */
486 #define	VOCALL(OPSV,OFF,AP) (( *((OPSV)[(OFF)])) (AP))
487 
488 /*
489  * This call works for vnodes in the kernel.
490  */
491 #define	VCALL(VP,OFF,AP) VOCALL((VP)->v_op,(OFF),(AP))
492 #define	VDESC(OP) (& __CONCAT(OP,_desc))
493 #define	VOFFSET(OP) (VDESC(OP)->vdesc_offset)
494 
495 /* XXX This include should go away */
496 #include <sys/mount.h>
497 
498 /*
499  * Finally, include the default set of vnode operations.
500  */
501 #include <sys/vnode_if.h>
502 
503 /*
504  * Public vnode manipulation functions.
505  */
506 struct file;
507 struct filedesc;
508 struct nameidata;
509 struct proc;
510 struct stat;
511 struct uio;
512 struct vattr;
513 struct vnode;
514 
515 /* see vnode(9) */
516 void	vfs_vnode_sysinit(void);
517 int 	bdevvp(dev_t, struct vnode **);
518 int 	cdevvp(dev_t, struct vnode **);
519 int	vaccess(enum vtype, mode_t, uid_t, gid_t, mode_t, kauth_cred_t);
520 void 	vattr_null(struct vattr *);
521 void	vdevgone(int, int, int, enum vtype);
522 int	vfinddev(dev_t, enum vtype, struct vnode **);
523 int	vflush(struct mount *, struct vnode *, int);
524 int	vflushbuf(struct vnode *, int);
525 int 	vget(struct vnode *, int, bool);
526 void 	vgone(struct vnode *);
527 int	vinvalbuf(struct vnode *, int, kauth_cred_t, struct lwp *, bool, int);
528 void	vprint(const char *, struct vnode *);
529 void 	vput(struct vnode *);
530 bool	vrecycle(struct vnode *);
531 void 	vrele(struct vnode *);
532 void 	vrele_async(struct vnode *);
533 void	vrele_flush(void);
534 int	vtruncbuf(struct vnode *, daddr_t, bool, int);
535 void	vwakeup(struct buf *);
536 int	vdead_check(struct vnode *, int);
537 void	vrevoke(struct vnode *);
538 void	vremfree(struct vnode *);
539 int	vcache_get(struct mount *, const void *, size_t, struct vnode **);
540 int	vcache_new(struct mount *, struct vnode *,
541 	    struct vattr *, kauth_cred_t, struct vnode **);
542 int	vcache_rekey_enter(struct mount *, struct vnode *,
543 	    const void *, size_t, const void *, size_t);
544 void	vcache_rekey_exit(struct mount *, struct vnode *,
545 	    const void *, size_t, const void *, size_t);
546 void	vcache_remove(struct mount *, const void *, size_t);
547 
548 /* see vnsubr(9) */
549 int	vn_bwrite(void *);
550 int 	vn_close(struct vnode *, int, kauth_cred_t);
551 int	vn_isunder(struct vnode *, struct vnode *, struct lwp *);
552 int	vn_lock(struct vnode *, int);
553 void	vn_markexec(struct vnode *);
554 int	vn_marktext(struct vnode *);
555 int 	vn_open(struct nameidata *, int, int);
556 int 	vn_rdwr(enum uio_rw, struct vnode *, void *, int, off_t, enum uio_seg,
557     int, kauth_cred_t, size_t *, struct lwp *);
558 int	vn_readdir(struct file *, char *, int, unsigned int, int *,
559     struct lwp *, off_t **, int *);
560 int	vn_stat(struct vnode *, struct stat *);
561 int	vn_kqfilter(struct file *, struct knote *);
562 int	vn_writechk(struct vnode *);
563 int	vn_openchk(struct vnode *, kauth_cred_t, int);
564 int	vn_extattr_get(struct vnode *, int, int, const char *, size_t *,
565 	    void *, struct lwp *);
566 int	vn_extattr_set(struct vnode *, int, int, const char *, size_t,
567 	    const void *, struct lwp *);
568 int	vn_extattr_rm(struct vnode *, int, int, const char *, struct lwp *);
569 void	vn_ra_allocctx(struct vnode *);
570 int	vn_fifo_bypass(void *);
571 
572 /* initialise global vnode management */
573 void	vntblinit(void);
574 
575 /* misc stuff */
576 void	sched_sync(void *);
577 void	vn_syncer_add_to_worklist(struct vnode *, int);
578 void	vn_syncer_remove_from_worklist(struct vnode *);
579 int	dorevoke(struct vnode *, kauth_cred_t);
580 int	rawdev_mounted(struct vnode *, struct vnode **);
581 uint8_t	vtype2dt(enum vtype);
582 
583 /* see vfssubr(9) */
584 void	vfs_getnewfsid(struct mount *);
585 int	vfs_drainvnodes(long);
586 void	vfs_timestamp(struct timespec *);
587 #if defined(DDB) || defined(DEBUGPRINT)
588 void	vfs_vnode_print(struct vnode *, int, void (*)(const char *, ...)
589     __printflike(1, 2));
590 void	vfs_mount_print(struct mount *, int, void (*)(const char *, ...)
591     __printflike(1, 2));
592 #endif /* DDB */
593 
594 #ifdef _VFS_VNODE_PRIVATE
595 /*
596  * Private vnode manipulation functions.
597  */
598 struct vnode *
599 	vnalloc_marker(struct mount *);
600 void	vnfree_marker(vnode_t *);
601 bool	vnis_marker(vnode_t *);
602 void	vcache_print(vnode_t *, const char *,
603     void (*)(const char *, ...) __printflike(1, 2));
604 #endif	/* _VFS_VNODE_PRIVATE */
605 
606 #endif /* _KERNEL */
607 
608 #endif /* !_SYS_VNODE_H_ */
609