lock

Locks a portion of a file

Local Servers:blocking
Remote Servers:blocking
Platform:NLM
Service:Operating System I/O

Syntax

  #include <nwfileio.h>  
   
  int lock  (  
     int    fildes,   
     LONG   offset,   
     LONG   length);
  

Parameters

handle
(IN) Specifies a file handle.
offset
(IN) Specifies the starting byte that is to be locked.
length
(IN) Specifies the amount of data (in bytes) to be locked.

Return Values

Returns a value of 0 if successful, and a value of -1 when an error occurs.

If an error occurs, errno is set to:

4

EBADF

Bad file number.

Remarks

lock locks the amount of data specified by the length parameter in the file specified by the handle parameter, starting at the byte specified by the offset parameter in the file.

lock prevents other open handles from reading or writing into the locked region until an unlock has been done for this locked region of the file. All locked regions of a file must be unlocked before a file is closed.

See Also

open, sopen, unlock