flock64

Contains information about a 64-bit advisory lock.

Service:File and Directory

Structure

  #include <fcntl.h>
  
  struct flock64 
  {
     pid_t     l_pid;
     pid_t     l_tid;
     short     l_type; 
     short     l_whence; 
     long      ________spare; 
     off64_t   l_start; 
     off64_t   l_len;
  };
  

Fields

l_pid

Specifies the process ID of the owner of the lock.

l_tid

Specifies the thread ID of the owner of the lock.

l_type

Specifies the lock type:

Flag

Value

Description

F_RDLCK

1

Indicates a read lock, which is a sharable lock

F_WRLCK

2

Indicates a write lock, which is an exclusive lock

F_UNLCK

3

Indicates unlock, which is used to remove a lock.

l_whence

Specifies the flag for the starting offset of the lock:

Flag

Value

Description

SEEK_SET

0

Indicates the start of the file plus the offset

SEEK_CUR

1

Indicates the current position in the file plus the offset

SEEK_END

2

Indicates the end of the file plus the offset

________spare

Unused.

l_start

Specifies the relative offset, in bytes, for the lock.

l_len

Specifies the length for the byte range lock. If zero, specifies until EOF.

Remarks

File locking with the fcntl function is constrained to per-process and is not shared across processes. As long as this remains the case, the value in the l_pid field is a copy of the value in the l_tid field.