1 .\" Copyright (c) 1996 Doug Rabson
3 .\" All rights reserved.
5 .\" This program is free software.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
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.
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.
34 .Nd internal representation of a file or directory
39 The vnode is the focus of all file activity in
41 A vnode is described by
44 unique vnode allocated for each active file, each current directory,
45 each mounted-on file, text file, and the root.
47 Each vnode has three reference counts,
52 The first is the number of clients within the kernel which are
54 This count is maintained by
59 The second is the number of clients within the kernel who veto
60 the recycling of this vnode.
70 of a vnode reaches zero then the vnode will be put on the freelist
71 and may be reused for another file, possibly in another file system.
72 The transition from the freelist is handled by
74 The third is a count of the number of clients which are writing into
76 It is maintained by the
82 Any call which returns a vnode (e.g.,\&
89 When the caller is finished with the vnode, it
90 should release this reference by calling
94 if the vnode is locked).
96 Other commonly used members of the vnode structure are
98 which is used to maintain consistency in the name cache,
100 which points at the file system which owns the vnode,
102 which contains the type of object the vnode represents and
104 which is used by file systems to store file system specific data with
110 macros to call functions in the file system which implement the vnode's
113 .Bl -tag -width VSOCK
117 A regular file; may be with or without VM object backing.
118 If you want to make sure this get a backing object, call
119 .Fn vnode_create_vobject .
123 A block device; may be with or without VM object backing.
124 If you want to make sure this get a backing object, call
125 .Fn vnode_create_vobject .
132 Advisory locking will not work on this.
135 Advisory locking will not work on this.
137 Indicates that the vnode has been reclaimed.
139 .Sh IMPLEMENTATION NOTES
140 VFIFO uses the "struct fileops" from
141 .Pa /sys/kern/sys_pipe.c .
142 VSOCK uses the "struct fileops" from
143 .Pa /sys/kern/sys_socket.c .
144 Everything else uses the one from
145 .Pa /sys/kern/vfs_vnops.c .
147 The VFIFO/VSOCK code, which is why "struct fileops" is used at all, is
148 an artifact of an incomplete integration of the VFS code into the
157 interlock, will cause a LOR (Lock Order Reversal) due to the
158 intertwining of VM Objects and Vnodes.
172 .Xr VOP_GETEXTATTR 9 ,
177 .Xr VOP_LISTEXTATTR 9 ,
180 .Xr VOP_OPENCLOSE 9 ,
186 .Xr VOP_REALLOCBLKS 9 ,
191 .Xr VOP_SETEXTATTR 9 ,
196 This manual page was written by