File: lockf.3

package info (click to toggle)
manpages-pt 20040726-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,988 kB
  • sloc: sh: 45; makefile: 16
file content (96 lines) | stat: -rw-r--r-- 2,464 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
.\" Copyright 1997 Nicols Lichtmaier <nick@debian.org>
.\" Created Thu Aug  7 00:44:00 ART 1997
.\"
.\" This is free documentation; you can redistribute it and/or
.\" modify it under the terms of the GNU General Public License as
.\" published by the Free Software Foundation; either version 2 of
.\" the License, or (at your option) any later version.
.\"
.\" The GNU General Public License's references to "object code"
.\" and "executables" are to be interpreted as the output of any
.\" document formatting or typesetting system, including
.\" intermediate and printed output.
.\"
.\" This manual is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
.\" GNU General Public License for more details.
.\"
.TH LOCKF 3 "6 August 1997" "Linux 2.0" "Linux Programmer's Manual"
.SH NAME
lockf \- apply, test or remove a POSIX lock on an open file
.SH SYNOPSIS
.B #include <sys/file.h>
.sp
.BR "int lockf(int " fd ", int " cmd ", off_t " len );
.SH DESCRIPTION
Apply, test or remove a POSIX lock on an open file.  The file is specified by
.IR fd .
This call is just an interface for
.BR fcntl "(2)."
Valid operations are given below:
.RS
.sp
.TP 1.0i
.B F_LOCK
Set an exclusive lock to the file. Only one process may hold an exclusive
lock for a given file at a given time. If the file is already locked it
blocks until the previous lock is released.
.TP
.B F_TLOCK
Same as
.B F_LOCK
but never blocks and return error instead if the file is
already locked.
.TP
.B F_ULOCK
Unlock the file.
.TP
.B F_TEST
Test the lock: return 0 if
.I fd
is unlocked or locked by this
process; return -1, set
.I errno
to
.BR EACCES ,
if another process holds the lock.
.sp
.RE

.SH "RETURN VALUE"
On success, zero is returned.  On error, \-1 is returned, and
.I errno
is set appropriately.
.SH ERRORS
.TP
.B EAGAIN
The file is locked and the
.B LOCK_NB
flag was selected, or operation is prohibited because the file has
been memory-mapped by another process.
.TP
.B EBADF
.I fd
is not an open file descriptor.
.TP
.B EDEADLK
Specified lock operation would cause a deadlock.
.TP
.B EINVAL
An invalid operation was specified in
.IR fd .
.TP
.B ENOLCK
Too many segment locks open, lock table is full.  
.SH CONFORMING TO
SYSV
.SH "SEE ALSO"
.BR fcntl (2),
.BR flock (2).
There are also
.I locks.txt
and
.I mandatory.txt
in
.IR /usr/src/linux/Documentation .