VOP_LOCK(9) | Kernel Developer's Manual | VOP_LOCK(9) |
VOP_LOCK
,
VOP_UNLOCK
, VOP_ISLOCKED
,
vn_lock
— serialize access
to a vnode
#include
<sys/param.h>
#include <sys/lock.h>
#include <sys/vnode.h>
int
VOP_LOCK
(struct
vnode *vp, int
flags);
int
VOP_UNLOCK
(struct
vnode *vp, int
flags);
int
VOP_ISLOCKED
(struct
vnode *vp);
int
vn_lock
(struct
vnode *vp, int
flags);
These calls are used to serialize access to the file system, such as to prevent two writes to the same file from happening at the same time.
The arguments are:
LK_SHARED
LK_EXCLUSIVE
LK_UPGRADE
LK_DOWNGRADE
LK_RELEASE
LK_DRAIN
The lock type may be or'ed with these lock flags:
LK_NOWAIT
LK_SLEEPFAIL
LK_CANRECURSE
LK_NOWITNESS
The lock type may be or'ed with these control flags:
LK_INTERLOCK
VOP_LOCK
()
will unlock the simple lock after getting the lock).LK_RETRY
Kernel code should use
vn_lock
()
to lock a vnode rather than calling VOP_LOCK
()
directly. vn_lock
() also does not want a thread
specified as argument but it assumes curthread to be used.
Zero is returned on success, otherwise an error is returned.
This manual page was written by Doug Rabson.
February 25, 2008 | Debian |