File: open_excl.3

package info (click to toggle)
libowfat 0.34-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,288 kB
  • sloc: ansic: 20,181; makefile: 16
file content (22 lines) | stat: -rw-r--r-- 886 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
.TH open_excl 3
.SH NAME
open_excl \- open a file for exclusive writing
.SH SYNTAX
.B #include <libowfat/open.h>

int \fBopen_excl\fP(const char *\fIfilename\fR);
.SH DESCRIPTION
open_excl opens the file \fIfilename\fR for writing and returns the file
handle.  The file may not exist before the call to \fBopen_excl\fR.  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).
.SH "SEE ALSO"
open(2), open_append(3), open_read(3), open_rw(3), open_trunc(3), open_write(3), openreadclose(3), readclose(3), readclose_append(3)