getrlent(3N) getrlent(3N)
NAME
getrlent, setrlent, endrlent, getrlclient, getrlfile - get remote lock
entry
SYNOPSIS
#include <rpc/types.h>
#include <nfs/nfs.h>
#include <nfs/nfssys.h>
struct remotelock *getrlent(boolt fhonly);
struct remotelock *getrlclient(boolt fhonly);
struct remotelock *getrlfile(char *fname);
void setrlent(void);
void endrlent(void);
DESCRIPTION
On the first call to either getrlent, getrlclient or getrlfile all
remote lock entries are read into a buffer. getrlent, getrlclient and
getrlfile then return a pointer to the first lock entry, the first
lock entry for the given client or the first lock entry for the given
file, respectively. On subsequent calls the routines return a pointer
to the next lock entry for the given criterion (none, client or file).
When the last entry for the given criterion has been processed, a NULL
pointer is returned. Note that the current lock entry is shared
between getrlent, getrlclient and getrlfile, so please exercise cau-
tion when intermixing these functions on a single scan through all
remote lock entries.
The structure remotelock is defined in <nfs/nfssys.h>:
struct remotelock {
union {
struct { /* relevant if this lock is granted */
fhandlet fh; /* file handle of the locked file */
char *fname; /* name of the locked file */
} ufile;
struct { /* relevant if this lock is blocked */
pidt bpid; /* PID of the blocking process */
char *bname; /* name of the blocking client */
} ublk;
} rlu;
char *rlclient; /* sysid or name of the client */
pidt rlpid; /* the client's process ID */
short rltype; /* lock type (excl. or shared) */
short rlstate; /* lockstate (granted or blocked) */
offt rlstart; /* start offset of the lock */
offt rllen; /* length of the lock */
};
Page 1 Reliant UNIX 5.44 Printed 11/98
getrlent(3N) getrlent(3N)
rlstate identifies the lock state. It may be granted (GRANTEDLOCK)
or blocked by another lock (BLOCKEDLOCK). A lock in state
GRANTEDLOCK may at the same time block another lock. Its rlstate
field has then the BLOCKINGLOCK bit set.
rlu.ufile identifies the file for which the lock is set if the lock
is in GRANTEDLOCK state. The file is identified by a 32 byte file
handle (rlu.ufile.fh) and - optionally - by its absolute path name
(rlu.ufile.fname).
The path name is only set if the fhonly flag for getrlent or
getrlclient is set to FALSE. (The getrlfile function already provides
the path name.) The conversion of a file handle into a file name is
time-consuming and should only be avoided where possible. If fhonly is
set to TRUE no conversion is done and the rlu.ufile.fname field is
set to NULL.
If the lock is in BLOCKEDLOCK state, rlu.ublk identifies the
blocker by its process ID (rlu.ublk.bpid) and name of the client on
which the blocking process was started (rlu.ublk.bname).
rlclient contains the host name of the client from which the lock is
set.
rlpid contains the PID of the client process which issued the lock
request.
rltype contains the lock type according to <sys/fcntl.h>.
rlstart and rllen contain the start offset and length of the locked
region within the file.
setrlent sets the current lock entry to the first one in the buffer.
endrlent marks the buffer invalid. The effect is that a subsequent
call to getrlent, getrlclient or getrlfile will behave as if it was
the first call, i.e. the buffer is filled again with lock entries.
SEE ALSO
nfslockadm(1M), removerlock(3N).
Page 2 Reliant UNIX 5.44 Printed 11/98