---
name: "open_excl"
section: "3"
platform: "linux"
package: "libowfat-dev"
version: "0.32-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/open_excl"
---

# open\_excl(3)

open a file for exclusive writing

## NAME

open\_excl - open a file for exclusive writing

## SYNTAX

**#include \<libowfat/open.h\>**

int **open\_excl**(const char \**filename*);

## DESCRIPTION

open\_excl opens the file *filename* for writing and returns the file handle.  The file may not exist before the call to **open\_excl**.  The file will be created with mode 0600.

If there was an error creating the file, open\_excl returns -1 and sets errno accordingly.

Since open\_excl relies on the O\_EXCL flag to open, it does not work reliably over NFS (the NFS protocol is broken) and must be emulated using a lock file (create a file with a unique file name and [link(2)](/link/2.md) it to the lock file.  Then stat the lock file and see if the link count is 2).

## SEE ALSO

[open(2)](/open/2.md)
