open_excl(3diet)

open_excl3diet

Open a file for exclusive writing

Usage

#include <open.h>

int open_excl(const char *filename);

Overview

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) it to the lock file. Then stat the lock file and see if the link count is 2).

Releases

4 releases since Debian 3.1 (Sarge); the text changed 1 time.

  1. 3.1–4.0
  2. 5.0–6.0

From libowfat-dev 0.28-2 in Debian 6.0 (Squeeze). Parsed by carta from the page's man source.