xref: /dragonfly/share/man/man9/vnode.9 (revision 3f5e28f4)
1.\" Copyright (c) 1996 Doug Rabson
2.\"
3.\" All rights reserved.
4.\"
5.\" This program is free software.
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 DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
17.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
20.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26.\"
27.\" $FreeBSD: src/share/man/man9/vnode.9,v 1.10.2.5 2001/12/17 11:30:19 ru Exp $
28.\" $DragonFly: src/share/man/man9/vnode.9,v 1.8 2007/05/17 08:19:02 swildner Exp $
29.\"
30.Dd May 5, 2007
31.Os
32.Dt VNODE 9
33.Sh NAME
34.Nm vnode
35.Nd internal representation of a file, directory, or other VFS entity
36.Sh SYNOPSIS
37.In sys/param.h
38.In sys/vnode.h
39.Sh DESCRIPTION
40The vnode is the focus of all file activity in
41.Ux .
42The
43.Nm
44is described by
45.Vt "struct vnode" .
46There is a
47unique vnode allocated for each active file, each current directory,
48each mounted-on file, text file, and the root.
49.Pp
50Each vnode has numerous reference counts,
51.Fa v_sysref ,
52.Fa v_auxrefs ,
53.Fa v_opencount ,
54and
55.Fa v_writecount .
56.Pp
57.Fa v_sysref
58represents the number of primary references to the vnode.
59It is actually
60a structure which utilizes the SYSREF API and also manages allocation and
61deallocation of the vnode.
62Primary references keep a vnode ready for I/O and prevent it from being
63deactivated.
64Primary references are managed by
65.Xr vref 9
66and
67.Xr vrele 9 .
68.Pp
69.Fa v_auxrefs
70represents the number of auxiliary references to a vnode.
71Auxiliary references prevent a vnode from being reclaimed (if not already being
72reclaimed), reused for other purposes, or otherwise destroyed, but
73do not activate or deactivate the vnode.
74Auxiliary references are managed by
75.Xr vhold 9
76and
77.Xr vdrop 9 .
78.Pp
79.Fa v_opencount
80represents the number of discrete
81.Fn open
82calls made on the vnode (reading or writing).
83.Fa v_writecount
84represents the number of discrete
85.Fn open
86calls made on the vnode for the purpose of writing.
87This field will be a subset of
88.Fa v_opencount .
89These fields are managed primarily by calls to
90.Xr vn_open 9
91and
92.Xr vn_close 9 .
93.Pp
94A deactivated vnode or a vnode in an unknown state accessed from an
95Auxiliary data structure can be reactivated, referenced, and locked using
96.Xr vget 9
97and
98.Xr vput 9 .
99.Pp
100An actively referenced and possibly locked vnode must be passed
101to most kernel procedures taking a vnode as an argument.
102Most kernel procedures returning a vnode will return one that is actively
103referenced.
104.Pp
105Other commonly used members of the vnode structure are
106.Fa v_mount
107which points at the filesystem which owns the vnode,
108.Fa v_type
109which contains the type of object the vnode represents and
110.Fa v_data
111which is used by filesystems to store filesystem specific data with
112the vnode.
113The
114.Fa v_ops
115field is used by the
116.Dv VOP_*
117macros to call functions in the filesystem which implement the vnode's
118functionality.
119.Sh VNODE TYPES
120.Bl -tag -width ".Dv VSOCK"
121.It Dv VNON
122No type.
123.It Dv VREG
124A regular file; may be with or without VM object backing.
125If you want to make sure this get a backing object, call
126.Xr vfs_object_create 9 .
127.It Dv VDIR
128A directory.
129.It Dv VBLK
130A block device; may be with or without VM object backing.
131If you want to make sure this get a backing object, call
132.Xr vfs_object_create 9 .
133.It Dv VCHR
134A character device.
135.It Dv VLNK
136A symbolic link.
137.It Dv VSOCK
138A socket.
139Advisory locking won't work on this.
140.It Dv VFIFO
141A FIFO (named pipe).
142Advisory locking won't work on this.
143.It Dv VBAD
144An old style bad sector map.
145.El
146.Sh IMPLEMENTATION NOTES
147.Dv VFIFO
148uses the
149.Vt struct fileops
150from
151.Pa /sys/kern/sys_pipe.c .
152.Dv VSOCK
153uses the
154.Vt struct fileops
155from
156.Pa /sys/kern/sys_socket.c .
157Everything else uses the one from
158.Pa /sys/kern/vfs_vnops.c .
159.Pp
160The VFIFO/VSOCK code, which is why
161.Vt struct fileops
162is used at all, is an artifact of an incomplete integration of
163the VFS code into the kernel.
164.Sh SEE ALSO
165.Xr VFS 9
166.Sh AUTHORS
167This manual page was written by
168.An Doug Rabson .
169