---
name: "posix_lock_file"
section: "9"
platform: "linux"
package: "linux-manual-4.9"
version: "4.9.228-1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/posix_lock_file"
---

# posix\_lock\_file(9)

Apply a POSIX-style lock to a file

## NAME

posix\_lock\_file - Apply a POSIX-style lock to a file

## SYNOPSIS

**int posix\_lock\_file(struct file \*** *filp***, struct file\_lock \*** *fl***, struct file\_lock \*** *conflock***);**

## ARGUMENTS

*filp*

The file to apply the lock to

*fl*

The lock to be applied

*conflock*

Place to return a copy of the conflicting lock, if found.

## DESCRIPTION

Add a POSIX style lock to a file. We merge adjacent & overlapping locks whenever possible. POSIX locks are sorted by owner task, then by starting address

Note that if called with an FL\_EXISTS argument, the caller may determine whether or not a lock was successfully freed by testing the return value for -ENOENT.

## COPYRIGHT
