*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->FreeBSD man pages -> vnode (9)              
Title
Content
Arch
Section
 

VNODE(9)

Contents


NAME    [Toc]    [Back]

     vnode -- internal representation of a file or directory

SYNOPSIS    [Toc]    [Back]

     #include <sys/param.h>
     #include <sys/vnode.h>

DESCRIPTION    [Toc]    [Back]

     The vnode is the focus of all file activity in UNIX.  A vnode is
     described by struct vnode.  There is a unique vnode allocated for each
     active file, each current directory, each mounted-on file, text file, and
     the root.

     Each vnode has three reference counts, v_usecount, v_holdcnt and
     v_writecount.  The first is the number of clients within the kernel which
     are using this vnode.  This count is maintained by vref(9), vrele(9) and
     vput(9).  The second is the number of clients within the kernel who veto
     the recycling of this vnode.  This count is maintained by vhold(9) and
     vdrop(9).	When both the v_usecount and the v_holdcnt of a vnode reaches
     zero then the vnode will be put on the freelist and may be reused for
     another file, possibly in another file system.  The transition to and
     from the freelist is handled by getnewvnode(9), vfree(9) and vbusy(9).
     The third is a count of the number of clients which are writing into the
     file.  It is maintained by the open(2) and close(2) system calls.

     Any call which returns a vnode (e.g. vget(9), VOP_LOOKUP(9) etc.)	will
     increase the v_usecount of the vnode by one.  When the caller is finished
     with the vnode, it should release this reference by calling vrele(9) (or
     vput(9) if the vnode is locked).

     Other commonly used members of the vnode structure are v_id which is used
     to maintain consistency in the name cache, v_mount which points at the
     file system which owns the vnode, v_type which contains the type of
     object the vnode represents and v_data which is used by file systems to
     store file system specific data with the vnode.  The v_op field is used
     by the VOP_* macros to call functions in the file system which implement
     the vnode's functionality.

VNODE TYPES    [Toc]    [Back]

     VNON   No type.

     VREG   A regular file; may be with or without VM object backing.  If you
	    want to make sure this get a backing object, call
	    vfs_object_create(9).

     VDIR   A directory.

     VBLK   A block device; may be with or without VM object backing.  If you
	    want to make sure this get a backing object, call
	    vfs_object_create(9).

     VCHR   A character device.

     VLNK   A symbolic link.

     VSOCK  A socket.  Advisory locking won't work on this.

     VFIFO  A FIFO (named pipe).  Advisory locking won't work on this.

     VBAD   An old style bad sector map

IMPLEMENTATION NOTES    [Toc]    [Back]

     VFIFO uses the "struct fileops" from /sys/kern/sys_pipe.c.  VSOCK uses
     the "struct fileops" from /sys/kern/sys_socket.c.	Everything else uses
     the one from /sys/kern/vfs_vnops.c.

     The VFIFO/VSOCK code, which is why "struct fileops" is used at all, is an
     artifact of an incomplete integration of the VFS code into the kernel.

     Calls to malloc(9) or free(9) when holding a vnode interlock, will cause
     a LOR (Lock Order Reversal) due to the intertwining of VM Objects and
     Vnodes.

SEE ALSO    [Toc]    [Back]

      
      
     malloc(9), VFS(9)

AUTHORS    [Toc]    [Back]

     This man page was written by Doug Rabson.


FreeBSD 5.2.1			 May 20, 2003			 FreeBSD 5.2.1
[ Back ]
 Similar pages
Name OS Title
gss_canonicalize_name HP-UX convert an internal name to an internal mechanism name (MN) representation of an opaque internal name
ungetnewvnode NetBSD kernel representation of a file or directory
getnewvnode NetBSD kernel representation of a file or directory
HOLDRELE NetBSD kernel representation of a file or directory
holdrele NetBSD kernel representation of a file or directory
VHOLD NetBSD kernel representation of a file or directory
vhold NetBSD kernel representation of a file or directory
vput NetBSD kernel representation of a file or directory
vget NetBSD kernel representation of a file or directory
checkalias NetBSD kernel representation of a file or directory
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service