Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
vnode(9)	       FreeBSD Kernel Developer's Manual	      vnode(9)

NAME
     vnode -- internal representation of a file	or directory

SYNOPSIS
     #include <sys/vnode.h>

     /*
      *	Vnode types.  VNON means no type.
      */
     enum vtype	     { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VBAD };

     /*
      *	Vnode tag types.
      *	These are for the benefit of external programs only (e.g., pstat)
      *	and should NEVER be inspected by the kernel.
      */
     enum vtagtype   {
	     VT_NON, VT_UFS, VT_NFS, VT_MFS, VT_PC, VT_LFS, VT_LOFS, VT_FDESC,
	     VT_PORTAL,	VT_NULL, VT_UMAP, VT_KERNFS, VT_PROCFS,	VT_AFS,	VT_ISOFS,
	     VT_UNION, VT_MSDOSFS, VT_DEVFS
     };

     /*
      *	Each underlying	filesystem allocates its own private area and hangs
      *	it from	v_data.	 If non-null, this area	is freed in getnewvnode().
      */
     LIST_HEAD(buflists, buf);

     typedef int     vop_t __P((void *));

     struct vnode {
	     u_long  v_flag;		     /*	vnode flags (see below)	*/
	     int     v_usecount;	     /*	reference count	of users */
	     int     v_writecount;	     /*	reference count	of writers */
	     int     v_holdcnt;		     /*	page & buffer references */
	     daddr_t v_lastr;		     /*	last read (read-ahead) */
	     u_long  v_id;		     /*	capability identifier */
	     struct  mount *v_mount;	     /*	ptr to vfs we are in */
	     vop_t   **v_op;		     /*	vnode operations vector	*/
	     TAILQ_ENTRY(vnode)	v_freelist;  /*	vnode freelist */
	     LIST_ENTRY(vnode) v_mntvnodes;  /*	vnodes for mount point */
	     struct  buflists v_cleanblkhd;  /*	clean blocklist	head */
	     struct  buflists v_dirtyblkhd;  /*	dirty blocklist	head */
	     long    v_numoutput;	     /*	num of writes in progress */
	     enum    vtype v_type;	     /*	vnode type */
	     union {
		     struct mount    *vu_mountedhere;/*	ptr to mounted vfs (VDIR) */
		     struct socket   *vu_socket;     /*	unix ipc (VSOCK) */
		     struct specinfo *vu_specinfo;   /*	device (VCHR, VBLK) */
		     struct fifoinfo *vu_fifoinfo;   /*	fifo (VFIFO) */
	     } v_un;
	     struct  nqlease *v_lease;	     /*	Soft reference to lease	*/
	     daddr_t v_lastw;		     /*	last write (write cluster) */
	     daddr_t v_cstart;		     /*	start block of cluster */
	     daddr_t v_lasta;		     /*	last allocation	*/
	     int     v_clen;		     /*	length of current cluster */
	     int     v_ralen;		     /*	Read-ahead length */
	     int     v_usage;		     /*	Vnode usage counter */
	     daddr_t v_maxra;		     /*	last readahead block */
	     void    *v_object;		     /*	Place to store VM object */
	     enum    vtagtype v_tag;	     /*	type of	underlying data	*/
	     void    *v_data;		     /*	private	data for fs */
     };
     #define v_mountedhere   v_un.vu_mountedhere
     #define v_socket	     v_un.vu_socket
     #define v_specinfo	     v_un.vu_specinfo
     #define v_fifoinfo	     v_un.vu_fifoinfo

     /*
      *	Vnode flags.
      */
     #define VROOT   0x0001  /*	root of	its file system	*/
     #define VTEXT   0x0002  /*	vnode is a pure	text prototype */
     #define VSYSTEM 0x0004  /*	vnode being used by kernel */
     #define VOLOCK  0x0008  /*	vnode is locked	waiting	for an object */
     #define VOWANT  0x0010  /*	a process is waiting for VOLOCK	*/
     #define VXLOCK  0x0100  /*	vnode is locked	to change underlying type */
     #define VXWANT  0x0200  /*	process	is waiting for vnode */
     #define VBWAIT  0x0400  /*	waiting	for output to complete */
     #define VALIASED 0x0800 /*	vnode has an alias */
     #define VDIROP  0x1000  /*	LFS: vnode is involved in a directory op */
     #define VVMIO   0x2000  /*	VMIO flag */
     #define VNINACT 0x4000  /*	LFS: skip ufs_inactive() in lfs_vunref */
     #define VAGE    0x8000  /*	Insert vnode at	head of	free list */

DESCRIPTION
     The vnode is the focus of all file	activity in UNIX.  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 two	reference counts, v_usecount 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).	 When
     the v_usecount of a vnode reaches zero then the vnode may be reused for
     another file, possibly in another filesystem.  The	second 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.  VFS_GET(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
     filesystem	which owns the vnode, v_type which contains the	type of	object
     the vnode represents and v_data which is used by filesystems to store
     filesystem	specific data with the vnode.  The v_op	field is used by the
     VOP_* macros to call functions in the filesystem which implement the
     vnode's functionality.

SEE ALSO
     VFS(9)

AUTHORS
     This man page was written by Doug Rabson.

FreeBSD	2.2.1			 July 24, 1996			 FreeBSD 2.2.1

NAME | SYNOPSIS | DESCRIPTION | SEE ALSO | AUTHORS

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=vnode&sektion=9&manpath=FreeBSD+2.2.1-RELEASE>

home | help