Sets, checks, and queries record locks.
int vn_lockctl (vp, offset, lckdat, cmd, retry_fn, retry_id, crp) struct vnode *vp; offset_t offset; struct eflock *lckdat; int cmd; int (*retry_fn)(); caddr_t retry_id; struct ucred *crp;
vp | Points to the file's virtual node (v-node). |
offset | Indicates the file offset from the open file structure. This parameter is used to establish where the lock region begins. |
lckdat | Points to the elock structure. This structure describes the lock operation to perform. |
cmd | Identifies the type of lock operation the vn_lockctl entry point is to perform. It is a bit mask that takes the following lock-control values: |
retry_fn | Points to a subroutine that is called when a lock is retried. This subroutine is not used if the lock is granted immediately.
Note: If the retry_fn parameter is not a null value, the vn_lockctl entry point will not sleep, regardless of the SLPFLCK flag. |
retry_id | Points to the location where a value can be stored. This value can be used to correlate a retry operation with a specific lock or set of locks. The retry value is only used in conjunction with the retry_fn parameter.
Note: This value is an opaque value and should not be used by the caller for any purpose other than a lock correlation. (This value should not be used as a pointer.) |
crp | Points to the cred structure. This structure contains data that the file system can use to validate access permission. |
The vn_lockctl entry point is used to request record locking. This entry point uses the information in the eflock structure to implement record locking.
If a requested lock is blocked by an existing lock, the vn_lockctl entry point should establish a sleeping lock with the retry subroutine address (specified by the retry_fn parameter) stored in the entry point. The vn_lockctl entry point then returns a correlating ID value to the caller (in the retry_id parameter), along with an exit value of EAGAIN. When the sleeping lock is later awakened, the retry subroutine is called with the retry_id parameter as its argument.
The eflock structure is defined in the /usr/include/sys/flock.h file and includes the following fields:
l_type | Specifies type of lock. This field takes the following values: |
l_whence | Specifies location that the l_start field offsets. |
l_start | Specifies offset from the l_whence field. |
l_len | Specifies length of record. If this field is 0, the remainder of the file is specified. |
l_vfs | Specifies virtual file system that contains the file. |
l_sysid | Specifies value that uniquely identifies the host for a given virtual file system. This field must be filled in before the call to the vn_lockctl entry point. |
l_pid | Specifies process ID (PID) of the lock owner. This field must be filled in before the call to the vn_lockctl entry point. |
The vn_lockctl entry point can be called from the process environment only.
0 | Indicates success. |
Nonzero return values are returned from the /usr/include/sys/errno.h file to indicate failure. Valid values include:
Virtual File System Overview, Virtual File System Kernel Extensions Overview, Logical File System Overview, Understanding Virtual Nodes (V-nodes) in AIX Kernel Extensions and Device Support Programming Concepts.
List of Virtual File System Operations.