Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)

fcntl(2) OSS System Calls Reference Manual
F_GETLK64 Similar to F_GETLK, except that it takes a pointer to a flock64 structure instead
of a pointer to a flock structure.
F_SETLK Sets or clears a file segment lock according to the lock description pointed to by
the argument2 parameter. F_SETLK is used to establish shared locks
(F_RDLCK) or exclusive locks (F_WRLCK) and, additionally, to remove
either type of lock (F_UNLCK). If a shared (read) or exclusive (write) lock can-
not be set, the fcntl( ) function returns immediately with the value -1.
F_SETLK64 Similar to F_SETLK, except that it takes a pointer to a flock64 structure instead
of a pointer to a flock structure.
F_SETLKW Same as F_SETLK except that, if a shared or exclusive lock is blocked by other
locks, the process waits until it is unblocked. If a signal is received while fcntl()
is waiting for a region, the function is interrupted, -1 is returned, and errno is set
to [EINTR].
For regular files, if a thread-aware fcntl() function needs to wait for
F_SETLKW requests, the thread-aware fcntl( ) blocks the thread that called the
function (instead of blocking the entire process).
F_SETLKW64
Similar to F_SETLKW, except that it takes a pointer to a flock64 structure
instead of a pointer to a flock structure.
For regular files, if a thread-aware fcntl() function needs to wait for
F_SETLKW64 requests, the thread-aware fcntl() blocks the thread that called
the function (instead of blocking the entire process).
The O_NONBLOCK file status flag affects only operations against file descriptors derived from
the same open() function.
When a shared lock is set on a segment of a file, other processes can set shared locks on that seg-
ment or a portion of it. A shared lock prevents any other process from setting an exclusive lock
on any portion of the protected area. A request for a shared lock fails if the file descriptor is not
opened with read access.
An exclusive lock prevents any other process from setting a shared lock or an exclusive lock on
any portion of the protected area. A request for an exclusive lock fails if the file descriptor was
not opened with write access.
The flock and flock64 structures describe the type (l_type field), starting offset (l_whence), rela-
tive offset (l_start), size (l_len), and process ID (l_pid) of the segment of the file to be affected.
The value of
l_whence is
set to SEEK_SET, SEEK_CUR,orSEEK_END to indicate that the
relative offset of l_start bytes is measured from the start of the file, from the current position, or
from the end of the file, respectively. The value of l_len is the number of consecutive bytes to be
locked. The l_len value can be negative (where the definition of type off_t permits negative
values of l_len). The l_pid field is used only with F_GETLK or F_GETLK64 to return the pro-
cess ID of the process holding a blocking lock. After a successful F_GETLK or F_GETLK64
request, the value of l_whence becomes SEEK_SET.
If l_len is positive, the area affected starts at l_start and ends at l_start + l_len - 1.Ifl_len is
negative, the area affected starts at l_start + l_len and ends at l_start - 1. Lock lengths can be
negative.
Locks can start and extend beyond the current end of a file, but they cannot be negative relative
to the beginning of the file. If l_len is set to 0 (zero), a lock can be set to always extend to the
largest possible value of the file offset for that file. If such a lock also has l_start set to 0 (zero)
and l_whence is set to SEEK_SET, the whole file is locked.
314 Hewlett-Packard Company 527186-023