186d7f5d3SJohn Marino.\" Copyright (c) 1996 Doug Rabson 286d7f5d3SJohn Marino.\" 386d7f5d3SJohn Marino.\" All rights reserved. 486d7f5d3SJohn Marino.\" 586d7f5d3SJohn Marino.\" This program is free software. 686d7f5d3SJohn Marino.\" 786d7f5d3SJohn Marino.\" Redistribution and use in source and binary forms, with or without 886d7f5d3SJohn Marino.\" modification, are permitted provided that the following conditions 986d7f5d3SJohn Marino.\" are met: 1086d7f5d3SJohn Marino.\" 1. Redistributions of source code must retain the above copyright 1186d7f5d3SJohn Marino.\" notice, this list of conditions and the following disclaimer. 1286d7f5d3SJohn Marino.\" 2. Redistributions in binary form must reproduce the above copyright 1386d7f5d3SJohn Marino.\" notice, this list of conditions and the following disclaimer in the 1486d7f5d3SJohn Marino.\" documentation and/or other materials provided with the distribution. 1586d7f5d3SJohn Marino.\" 1686d7f5d3SJohn Marino.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 1786d7f5d3SJohn Marino.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1886d7f5d3SJohn Marino.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1986d7f5d3SJohn Marino.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 2086d7f5d3SJohn Marino.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2186d7f5d3SJohn Marino.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2286d7f5d3SJohn Marino.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2386d7f5d3SJohn Marino.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2486d7f5d3SJohn Marino.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2586d7f5d3SJohn Marino.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2686d7f5d3SJohn Marino.\" 2786d7f5d3SJohn Marino.\" $FreeBSD: src/share/man/man9/vnode.9,v 1.10.2.5 2001/12/17 11:30:19 ru Exp $ 2886d7f5d3SJohn Marino.\" 2986d7f5d3SJohn Marino.Dd May 5, 2007 3086d7f5d3SJohn Marino.Dt VNODE 9 3186d7f5d3SJohn Marino.Os 3286d7f5d3SJohn Marino.Sh NAME 3386d7f5d3SJohn Marino.Nm vnode 3486d7f5d3SJohn Marino.Nd internal representation of a file, directory, or other VFS entity 3586d7f5d3SJohn Marino.Sh SYNOPSIS 3686d7f5d3SJohn Marino.In sys/param.h 3786d7f5d3SJohn Marino.In sys/vnode.h 3886d7f5d3SJohn Marino.Sh DESCRIPTION 3986d7f5d3SJohn MarinoThe vnode is the focus of all file activity in 4086d7f5d3SJohn Marino.Ux . 4186d7f5d3SJohn MarinoThe 4286d7f5d3SJohn Marino.Nm 4386d7f5d3SJohn Marinois described by 4486d7f5d3SJohn Marino.Vt "struct vnode" . 4586d7f5d3SJohn MarinoThere is a 4686d7f5d3SJohn Marinounique vnode allocated for each active file, each current directory, 4786d7f5d3SJohn Marinoeach mounted-on file, text file, and the root. 4886d7f5d3SJohn Marino.Pp 4986d7f5d3SJohn MarinoEach vnode has numerous reference counts, 5086d7f5d3SJohn Marino.Fa v_sysref , 5186d7f5d3SJohn Marino.Fa v_auxrefs , 5286d7f5d3SJohn Marino.Fa v_opencount , 5386d7f5d3SJohn Marinoand 5486d7f5d3SJohn Marino.Fa v_writecount . 5586d7f5d3SJohn Marino.Pp 5686d7f5d3SJohn Marino.Fa v_sysref 5786d7f5d3SJohn Marinorepresents the number of primary references to the vnode. 5886d7f5d3SJohn MarinoIt is actually 5986d7f5d3SJohn Marinoa structure which utilizes the SYSREF API and also manages allocation and 6086d7f5d3SJohn Marinodeallocation of the vnode. 6186d7f5d3SJohn MarinoPrimary references keep a vnode ready for I/O and prevent it from being 6286d7f5d3SJohn Marinodeactivated. 6386d7f5d3SJohn MarinoPrimary references are managed by 6486d7f5d3SJohn Marino.Xr vref 9 6586d7f5d3SJohn Marinoand 6686d7f5d3SJohn Marino.Xr vrele 9 . 6786d7f5d3SJohn Marino.Pp 6886d7f5d3SJohn Marino.Fa v_auxrefs 6986d7f5d3SJohn Marinorepresents the number of auxiliary references to a vnode. 7086d7f5d3SJohn MarinoAuxiliary references prevent a vnode from being reclaimed (if not already being 7186d7f5d3SJohn Marinoreclaimed), reused for other purposes, or otherwise destroyed, but 7286d7f5d3SJohn Marinodo not activate or deactivate the vnode. 7386d7f5d3SJohn MarinoAuxiliary references are managed by 7486d7f5d3SJohn Marino.Xr vhold 9 7586d7f5d3SJohn Marinoand 7686d7f5d3SJohn Marino.Xr vdrop 9 . 7786d7f5d3SJohn Marino.Pp 7886d7f5d3SJohn Marino.Fa v_opencount 7986d7f5d3SJohn Marinorepresents the number of discrete 8086d7f5d3SJohn Marino.Fn open 8186d7f5d3SJohn Marinocalls made on the vnode (reading or writing). 8286d7f5d3SJohn Marino.Fa v_writecount 8386d7f5d3SJohn Marinorepresents the number of discrete 8486d7f5d3SJohn Marino.Fn open 8586d7f5d3SJohn Marinocalls made on the vnode for the purpose of writing. 8686d7f5d3SJohn MarinoThis field will be a subset of 8786d7f5d3SJohn Marino.Fa v_opencount . 8886d7f5d3SJohn MarinoThese fields are managed primarily by calls to 8986d7f5d3SJohn Marino.Xr vn_open 9 9086d7f5d3SJohn Marinoand 9186d7f5d3SJohn Marino.Xr vn_close 9 . 9286d7f5d3SJohn Marino.Pp 9386d7f5d3SJohn MarinoA deactivated vnode or a vnode in an unknown state accessed from an 9486d7f5d3SJohn MarinoAuxiliary data structure can be reactivated, referenced, and locked using 9586d7f5d3SJohn Marino.Xr vget 9 9686d7f5d3SJohn Marinoand 9786d7f5d3SJohn Marino.Xr vput 9 . 9886d7f5d3SJohn Marino.Pp 9986d7f5d3SJohn MarinoAn actively referenced and possibly locked vnode must be passed 10086d7f5d3SJohn Marinoto most kernel procedures taking a vnode as an argument. 10186d7f5d3SJohn MarinoMost kernel procedures returning a vnode will return one that is actively 10286d7f5d3SJohn Marinoreferenced. 10386d7f5d3SJohn Marino.Pp 10486d7f5d3SJohn MarinoOther commonly used members of the vnode structure are 10586d7f5d3SJohn Marino.Fa v_mount 10686d7f5d3SJohn Marinowhich points at the filesystem which owns the vnode, 10786d7f5d3SJohn Marino.Fa v_type 10886d7f5d3SJohn Marinowhich contains the type of object the vnode represents and 10986d7f5d3SJohn Marino.Fa v_data 11086d7f5d3SJohn Marinowhich is used by filesystems to store filesystem specific data with 11186d7f5d3SJohn Marinothe vnode. 11286d7f5d3SJohn MarinoThe 11386d7f5d3SJohn Marino.Fa v_ops 11486d7f5d3SJohn Marinofield is used by the 11586d7f5d3SJohn Marino.Dv VOP_* 11686d7f5d3SJohn Marinomacros to call functions in the filesystem which implement the vnode's 11786d7f5d3SJohn Marinofunctionality. 11886d7f5d3SJohn Marino.Sh VNODE TYPES 11986d7f5d3SJohn Marino.Bl -tag -width ".Dv VSOCK" 12086d7f5d3SJohn Marino.It Dv VNON 12186d7f5d3SJohn MarinoNo type. 12286d7f5d3SJohn Marino.It Dv VREG 12386d7f5d3SJohn MarinoA regular file; may be with or without VM object backing. 12486d7f5d3SJohn MarinoIf you want to make sure this get a backing object, call 12586d7f5d3SJohn Marino.Xr vfs_object_create 9 . 12686d7f5d3SJohn Marino.It Dv VDIR 12786d7f5d3SJohn MarinoA directory. 12886d7f5d3SJohn Marino.It Dv VBLK 12986d7f5d3SJohn MarinoA block device; may be with or without VM object backing. 13086d7f5d3SJohn MarinoIf you want to make sure this get a backing object, call 13186d7f5d3SJohn Marino.Xr vfs_object_create 9 . 13286d7f5d3SJohn Marino.It Dv VCHR 13386d7f5d3SJohn MarinoA character device. 13486d7f5d3SJohn Marino.It Dv VLNK 13586d7f5d3SJohn MarinoA symbolic link. 13686d7f5d3SJohn Marino.It Dv VSOCK 13786d7f5d3SJohn MarinoA socket. 13886d7f5d3SJohn MarinoAdvisory locking won't work on this. 13986d7f5d3SJohn Marino.It Dv VFIFO 14086d7f5d3SJohn MarinoA FIFO (named pipe). 14186d7f5d3SJohn MarinoAdvisory locking won't work on this. 14286d7f5d3SJohn Marino.It Dv VBAD 14386d7f5d3SJohn MarinoAn old style bad sector map. 14486d7f5d3SJohn Marino.El 14586d7f5d3SJohn Marino.Sh IMPLEMENTATION NOTES 14686d7f5d3SJohn Marino.Dv VFIFO 14786d7f5d3SJohn Marinouses the 14886d7f5d3SJohn Marino.Vt struct fileops 14986d7f5d3SJohn Marinofrom 15086d7f5d3SJohn Marino.Pa /sys/kern/sys_pipe.c . 15186d7f5d3SJohn Marino.Dv VSOCK 15286d7f5d3SJohn Marinouses the 15386d7f5d3SJohn Marino.Vt struct fileops 15486d7f5d3SJohn Marinofrom 15586d7f5d3SJohn Marino.Pa /sys/kern/sys_socket.c . 15686d7f5d3SJohn MarinoEverything else uses the one from 15786d7f5d3SJohn Marino.Pa /sys/kern/vfs_vnops.c . 15886d7f5d3SJohn Marino.Pp 15986d7f5d3SJohn MarinoThe VFIFO/VSOCK code, which is why 16086d7f5d3SJohn Marino.Vt struct fileops 16186d7f5d3SJohn Marinois used at all, is an artifact of an incomplete integration of 16286d7f5d3SJohn Marinothe VFS code into the kernel. 16386d7f5d3SJohn Marino.Sh SEE ALSO 16486d7f5d3SJohn Marino.Xr VFS 9 16586d7f5d3SJohn Marino.Sh AUTHORS 16686d7f5d3SJohn MarinoThis manual page was written by 16786d7f5d3SJohn Marino.An Doug Rabson . 168