dflock, dflockw, dfunlock - lock/unlock an RMSfile for exclusive use


#include <cbase/dirio.h>

int dflock (fcb)

DFILE *fcb;

int dflockw (fcb)

DFILE *fcb;

int dfunlock (fcb)

DFILE *fcb;


Dflock attempts to lock an RMSfile for exclusive use and returns immediately with a status code. If the RMSfile was locked successfully, then dflock returns a positive value. If the RMSfile could not be locked, perhaps because it was already locked by another process, a zero value is returned.

Dflockw attempts to lock an RMSfile for exclusive use, and waits until the entire RMSfile can be locked before returning. Dflockw normally returns a positive value.

Dfunlock unlocks an RMSfile that was locked using dflock or dflockw.

Fcb is the file block pointer returned by dlopen(C-3) or dopen(C-3).

These routines must be used in a multi-user environment when calling RMS file functions to prevent simultaneous access to data by more than one process. The RMS file functions do not automatically lock files or records to prevent simultaneous access to data.


drlock(C-3), dclock(C-3), dilock(C-3), dlopen(C-3), dopen(C-3)

Chapter 4,

RMS Programming Guide


Dflock and Dflockw return a value of zero (0) if fcb is not an opened file block pointer or if locking the RMSfile would cause a deadlock.