The cmd argument will be either F_GETLK, F_SETLK or F_SETLKW.
For the meaning of fields in 'struct flock' see the man page
for fcntl(2). The l_whence field will always be set to
SEEK_SET.
For checking lock ownership, the 'fi.owner' argument must be used.
For F_GETLK operation, the library will first check currently
held locks, and if a conflicting lock is found it will return
information without calling this method.
This ensures, that for local locks the l_pid field is correctly
filled in. The results may not be accurate in case of race conditions
and in the presence of hard links, but it's unlikely that an
application would rely on accurate GETLK results in these
cases. If a conflicting lock is not found, this method will be
called, and the filesystem may fill out l_pid by a meaningful
value, or it may leave this field zero.
For F_SETLK and F_SETLKW the l_pid field will be set to the pid
of the process performing the locking operation.
Note: if this method is not implemented, the kernel will still
allow file locking to work locally. Hence it is only
interesting for network filesystems and similar.
Perform POSIX file locking operation.
The cmd argument will be either F_GETLK, F_SETLK or F_SETLKW.
For the meaning of fields in 'struct flock' see the man page for fcntl(2). The l_whence field will always be set to SEEK_SET.
For checking lock ownership, the 'fi.owner' argument must be used.
For F_GETLK operation, the library will first check currently held locks, and if a conflicting lock is found it will return information without calling this method. This ensures, that for local locks the l_pid field is correctly filled in. The results may not be accurate in case of race conditions and in the presence of hard links, but it's unlikely that an application would rely on accurate GETLK results in these cases. If a conflicting lock is not found, this method will be called, and the filesystem may fill out l_pid by a meaningful value, or it may leave this field zero.
For F_SETLK and F_SETLKW the l_pid field will be set to the pid of the process performing the locking operation.
Note: if this method is not implemented, the kernel will still allow file locking to work locally. Hence it is only interesting for network filesystems and similar.