NFSLOCK(3)

NAME
nfslock - apply or remove an advisory lock on an open file (across remote mounted network file systems, if necessary)

SYNOPSIS
#include <sys/file.h>

#define	LOCK_SH	1	/* shared lock */
#define	LOCK_EX	2	/* exclusive lock */
#define	LOCK_NB	4	/* don't block when locking */
#define	LOCK_UN	8	/* unlock */

nfslock(file, operation)
int file, operation;

DESCRIPTION
nfslock() applies or removes an advisory lock on the named file in the same way as flock(2) does, but does it correctly on remote mounted filesystems across the network by communicating with the in.rlockd daemon running on the appropriate file server.

When using nfslock(), link the calling program with -lnfslock.

RETURN VALUE
Zero is returned on success, -1 on error, with an error code stored in errno.

ERRORS
The nfslock() call fails with:

EINVAL
    if the file cannot be accessed by the process requesting the lock, or is not writable by the process if the lock is remote, if the file is not a regular file, if the file is remote and the flock service (or TCP!) is not available, or if any of the system calls related to opening the network socket fail.

It returns the errno of flock() if the file is local.

AUTHOR
Rayan Zachariassen, Dennis Ferguson, University of Toronto

SEE ALSO
in.rlockd(8) flock(2), fcntl(2V), lockf(3), lockd(8C)

BUGS
Locks obtained with this mechanism are not compatible with those obtained using fcntl(2V) or lockf(3).