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

FreeBSD Manual Pages

  
 
  

home | help
VOP_OPEN(9)		    Kernel Developer's Manual		     VOP_OPEN(9)

NAME
     VOP_OPEN, VOP_CLOSE -- open or close a file

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

     int
     VOP_OPEN(struct vnode *vp, int mode, struct ucred *cred, struct thread *td,
	 struct file *fp);

     int
     VOP_CLOSE(struct vnode *vp, int mode, struct ucred *cred,
	 struct thread *td);

DESCRIPTION
     The VOP_OPEN() entry point is called before a file is accessed by a process
     and  the VOP_CLOSE() entry point is called after a file is finished with by
     the process.

     The arguments are:

     vp    The vnode of the file.

     mode  The access mode required by the calling process.

     cred  The caller's credentials.

     td    The thread which is accessing the file.

     fp    The file being opened.

     Pointer to the file fp is useful for file systems which require such infor-
     mation, e.g., fdescfs(5).	Use `NULL' as fp argument to VOP_OPEN() for  in-
     kernel opens.

     The  access  mode	is  a set of flags, including FREAD, FWRITE, O_NONBLOCK,
     O_APPEND.

     The thread td passed to VOP_CLOSE() may be `NULL' if the last reference  to
     the open file is released from a kernel context, e.g., the destruction of a
     socket buffer containing the file reference in a SCM_RIGHTS message.

LOCKS
     VOP_OPEN() expects vp to be locked on entry and will leave it locked on re-
     turn.

     VOP_CLOSE()  expects  at  least a reference to be associated with the vnode
     and does not care whether the vnode is locked or not.  The lock and  refer-
     ence  state is left unchanged on return.  Note that vn_close expects an un-
     locked, referenced vnode and will dereference the vnode prior to returning.

RETURN VALUES
     Zero is returned on success, otherwise an error code is returned.

SEE ALSO
     vnode(9), VOP_LOOKUP(9)

AUTHORS
     This manual page was written by Doug Rabson.

FreeBSD ports 15.quarterly	October 17, 2025		     VOP_OPEN(9)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=VOP_CLOSE&sektion=9&manpath=FreeBSD+15.1-RELEASE+and+Ports.quarterly>

home | help