---
name: "rfio_lockf"
section: "3"
platform: "linux"
package: "libdpm-dev"
version: "1.10.0-2+b3"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/rfio_lockf"
---

# rfio\_lockf(3)

provide record locking on files

## NAME

rfio\_lockf - provide record locking on files

## SYNOPSIS

**#include \<sys/types.h\>**\
 **#include "rfio\_api.h"**

**int rfio\_lockf (int** *sd***, int** *op***, long** *siz***);**

Under Linux, for large files:\
 **#define \_LARGEFILE64\_SOURCE**\
 **#include \<sys/types.h\>**\
 **#include "rfio\_api.h"**

**int rfio\_lockf64 (int** *sd***, int** *op***, off64\_t** *siz***);**\

For large files, under other systems:\
 **#include \<sys/types.h\>**\
 **#include "rfio\_api.h"**

**int rfio\_lockf64 (int** *sd***, int** *op***, off64\_t** *siz***);**

## DESCRIPTION

**rfio\_lockf** restricts access to regions of files to the calling process.

*sd* is the file descriptor returned by a previous **rfio\_open**.

*op* specifies the action to be taken:

- **F\_ULOCK**

  unlock a region.

- **F\_LOCK**

  lock a region.

- **F\_TLOCK**

  test and lock a region.

- **F\_TEST**

  test a region for other locks.

*siz* gives the size of the region to be locked, starting at the current file offset.

**rfio\_lockf64** must be used for large files and uses an off64\_t instead of a long to specify the size of the region to be locked.

## RETURN VALUE

This routine returns 0 if the operation was successful or -1 if the operation failed. In the latter case, **serrno** is set appropriately.

## ERRORS

- **EBADF**

  *sd* is not a valid descriptor.

- **EACCES**

  The file region is locked and F\_TEST or F\_TLOCK was specified.

- **EINVAL**

  incorrect value for *op* or *siz*.

- **SENOSHOST**

  Host unknown.

- **SENOSSERV**

  Service unknown.

- **SETIMEDOUT**

  Timed out.

- **SECONNDROP**

  Connection closed by remote end.

- **SECOMERR**

  Communication error.

## SEE ALSO

**[rfio\_open(3)](/rfio_open/3.md)**

## AUTHOR

**LCG Grid Deployment** Team
