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