|VNSUBR(9)||Kernel Developer's Manual||VNSUBR(9)|
vnode *vp, int
flags, struct ucred
*cred, struct proc
vnode *dvp, struct vnode
*rvp, struct proc
vnode *vp, int
nameidata *ndp, int
vn_rdwr(enum uio_rw rw,
struct vnode *vp, caddr_t base,
int len, off_t offset,
enum uio_seg segflg, int ioflg,
struct ucred *cred, size_t
*aresid, struct proc *p);
vnode *vp, struct stat
*sb, struct proc
vn_close(vp, flags, cred, p)
vn_close() simply locks the vnode, invokes the vnode operation
VOP_CLOSE() and calls vput(9) to return the vnode to the freelist or holdlist. Note that
vn_close() expects an unlocked, referenced vnode and will dereference the vnode prior to returning. If the operation is successful, zero is returned; otherwise an appropriate error is returned.
vn_isunder(dvp, rvp, p)
vn_isunder() is intended to be used in chroot(2), chdir(2), fchdir(2), etc., to ensure that chroot(2) actually means something. If the operation is successful, zero is returned; otherwise 1 is returned.
vn_lock() function must not be
called when the vnode's reference count is zero. Instead, the
vget(9) function should be used.
In addition to the flags accepted by
LK_RETRY flag may be used.
vn_lock() to return the vnode even if it has
been reclaimed. It must not be used with
vn_lock() function can sleep.
vn_open(ndp, fmode, cmode)
vn_open() checks permissions and invokes the VOP_OPEN(9) or VOP_CREATE(9) vnode operations. If the operation is successful, zero is returned; otherwise an appropriate error code is returned.
vn_rdwr(rw, vp, base, len, offset, segflg, ioflg, cred, aresid, p);
UIO_READ) or write (
UIO_WRITE) operation. The unlocked vnode is specified by vp. The arguments p and cred are the calling process and its credentials. The remaining arguments specify the uio parameters. For further information on these parameters, see uiomove(9).
vn_stat(vp, sb, p)
vn_stat() basically calls the vnode operation VOP_GETATTR(9) and transfers the contents of a vattr structure into a struct stat. If the operation is successful, zero is returned; otherwise an appropriate error code is returned.
ETXTBSYis returned; otherwise zero is returned to indicate that the vnode can be written to.
The high-level convenience functions are implemented within the files sys/kern/vfs_vnops.c and sys/sys/vnode.h.
The locking discipline is used in some places to attempt to make a series of operations atomic (e.g., permissions check + operation). This does not work for non-local file systems that do not support locking (e.g., NFS).
Are vnode locks even necessary? The security checks can be moved into the individual file systems. Each file system can have the responsibility of ensuring that vnode operations are suitably atomic.
LK_NOWAIT flag does prevent the caller
The locking discipline as it relates to shared locks has yet to be defined.
|May 2, 2018||OpenBSD-current|