OSDN Git Service

(split) Convert release and draft pages to UTF-8.
[linuxjm/LDP_man-pages.git] / draft / man3 / lockf.3
1 .\" Copyright 1997 Nicolas Lichtmaier <nick@debian.org>
2 .\" Created Thu Aug  7 00:44:00 ART 1997
3 .\"
4 .\" This is free documentation; you can redistribute it and/or
5 .\" modify it under the terms of the GNU General Public License as
6 .\" published by the Free Software Foundation; either version 2 of
7 .\" the License, or (at your option) any later version.
8 .\"
9 .\" The GNU General Public License's references to "object code"
10 .\" and "executables" are to be interpreted as the output of any
11 .\" document formatting or typesetting system, including
12 .\" intermediate and printed output.
13 .\"
14 .\" This manual is distributed in the hope that it will be useful,
15 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
16 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 .\" GNU General Public License for more details.
18 .\"
19 .\" Added section stuff, aeb, 2002-04-22.
20 .\" Corrected include file, drepper, 2003-06-15.
21 .\"
22 .\" Japanese Version Copyright (c) 2000-2002 Yuichi SATO
23 .\"         all rights reserved.
24 .\" Translated Tue Jul 11 19:02:58 JST 2000
25 .\"         by Yuichi SATO <ysato@h4.dion.ne.jp>
26 .\" Updated & Modified Mon Jul 15 02:10:29 JST 2002 by Yuichi SATO
27 .\" Updated 2010-04-18, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.24
28 .\"
29 .\"WORD:        apply           適用
30 .\"WORD:        remove          解除
31 .\"WORD:        exclusive       排他
32 .\"WORD:        descriptor      ディスクリプタ
33 .\"WORD:        
34 .\"
35 .TH LOCKF 3 2011-09-11 "GNU" "Linux Programmer's Manual"
36 .\"O .SH NAME
37 .SH 名前
38 .\"O lockf \- apply, test or remove a POSIX lock on an open file
39 lockf \- オープンされたファイルに対する POSIX ロックの適用・テスト・解除を行う
40 .\"O .SH SYNOPSIS
41 .SH 書式
42 .B #include <unistd.h>
43 .sp
44 .BI "int lockf(int " fd ", int " cmd ", off_t " len );
45 .sp
46 .in -4n
47 .\"O Feature Test Macro Requirements for glibc (see
48 .\"O .BR feature_test_macros (7)):
49 glibc 向けの機能検査マクロの要件
50 .RB ( feature_test_macros (7)
51 参照):
52 .in
53 .sp
54 .BR lockf ():
55 .ad l
56 .RS 4
57 _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
58 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
59 .RE
60 .ad
61 .\"O .SH DESCRIPTION
62 .SH 説明
63 .\"O Apply, test or remove a POSIX lock on a section of an open file.
64 オープンされたファイルのセクションに対して、
65 POSIX ロックの適用・テスト・解除をする。
66 .\"O The file is specified by
67 .\"O .IR fd ,
68 .\"O a file descriptor open for writing, the action by
69 .\"O .IR cmd ,
70 ファイルは
71 .I fd
72 で指定される。
73 .I fd
74 は書き込みのためにオープンしたファイルディスクリプタである。
75 アクションは
76 .I cmd
77 で指定される。
78 .\"O and the section consists of byte positions
79 .\"O .IR pos .. pos + len \-1
80 .\"O if
81 .\"O .I len
82 .\"O is positive, and
83 .\"O .IR pos - len .. pos \-1
84 .\"O if
85 .\"O .I len
86 .\"O is negative, where
87 .\"O .I pos
88 .\"O is the current file position, and if
89 .I pos
90 を現在のファイル位置とすると、
91 .I len
92 が正の場合、セクションはバイト位置
93 .IR pos .. pos + len \-1
94 となり、
95 .I len
96 が負の場合、セクションはバイト位置
97 .IR pos - len .. pos \-1
98 となる。
99 .\"O .I len
100 .\"O is zero, the section extends from the current file position to
101 .\"O infinity, encompassing the present and future end-of-file positions.
102 .I len
103 が 0 の場合、セクションは現在のファイル位置から無限大までとなる
104 (つまり現在の、あるいは変更された場合は将来の、ファイル終端位置まで)。
105 .\"O In all cases, the section may extend past current end-of-file.
106 どの場合においても、セクションは以前のファイル終端よりも拡大されうる。
107 .LP
108 .\"O On Linux,
109 .\"O .BR lockf ()
110 .\"O is just an interface on top of
111 .\"O .BR fcntl (2)
112 .\"O locking.
113 Linux では、
114 .BR lockf ()
115 は単に
116 .BR fcntl (2)
117 のロックへのインターフェースである。
118 .\"O Many other systems implement
119 .\"O .BR lockf ()
120 .\"O in this way, but note that POSIX.1-2001 leaves the relationship between
121 .\"O .BR lockf ()
122 .\"O and
123 .\"O .BR fcntl (2)
124 .\"O locks unspecified.
125 .\"O A portable application should probably avoid mixing calls
126 .\"O to these interfaces.
127 多くの他のシステムで
128 .BR lockf ()
129 はこのように実装されているが、
130 POSIX.1-2001 では
131 .BR lockf ()
132
133 .BR fcntl (2)
134 のロックとの関係は規定されていない。
135 おそらく、移植性が必要なアプリケーションでは、
136 .BR lockf ()
137
138 .BR fcntl (2)
139 のロックを混ぜて呼び出すのは避けるべきであろう。
140 .LP
141 .\"O Valid operations are given below:
142 有効なオプションを以下に挙げる。
143 .TP
144 .B F_LOCK
145 .\"O Set an exclusive lock on the specified section of the file.
146 .\"O If (part of) this section is already locked, the call
147 .\"O blocks until the previous lock is released.
148 ファイルの指定されたセクションに排他ロックを設定する。
149 そのセクション (の一部) が既にロックされていた場合、
150 前のロックが解除されるまで関数の呼び出しがブロックされる。
151 .\"O If this section overlaps an earlier locked section,
152 .\"O both are merged.
153 このセクションが前にロックされているセクションと重なった場合、
154 2 つのセクションは結合される。
155 .\"O File locks are released as soon as the process holding the locks
156 .\"O closes some file descriptor for the file.
157 .\"O A child process does not
158 .\"O inherit these locks.
159 ロックを保持しているプロセスが、
160 そのファイルのファイルディスクリプタをクローズすると、
161 ファイルロックは解放される。
162 子プロセスはロックを継承しない。
163 .TP
164 .B F_TLOCK
165 .\"O Same as
166 .\"O .B F_LOCK
167 .\"O but the call never blocks and returns an error instead if the file is
168 .\"O already locked.
169 .B F_LOCK
170 と同様であるが、ファイルが既にロックされている場合、
171 関数の呼び出しはブロックを行わずにエラーを返す。
172 .TP
173 .B F_ULOCK
174 .\"O Unlock the indicated section of the file.
175 .\"O This may cause a locked section to be split into two locked sections.
176 ファイルの指定されたセクションのロックを解除する。
177 これによりロックされたセクションが 2 つに分割されるかもしれない。
178 .TP
179 .B F_TEST
180 .\"O Test the lock: return 0 if the specified section
181 .\"O is unlocked or locked by this process; return \-1, set
182 .\"O .I errno
183 .\"O to
184 .\"O .B EAGAIN
185 .\"O .RB ( EACCES
186 .\"O on some other systems),
187 .\"O if another process holds a lock.
188 次のようにロックのテストをする。
189 指定されたセクションがロックされていないか、
190 このプロセスによりロックされている場合、0 を返す。
191 他のプロセスがロックを保持している場合、\-1 を返し、
192 .I errno
193
194 .B EAGAIN
195 (いくつかの他のシステムでは
196 .BR EACCES )
197 に設定する。
198 .\"O .SH "RETURN VALUE"
199 .SH 返り値
200 .\"O On success, zero is returned.
201 .\"O On error, \-1 is returned, and
202 .\"O .I errno
203 .\"O is set appropriately.
204 成功した場合、0 が返される。
205 エラーの場合、\-1 が返され、
206 .I errno
207 がエラーに対応した値に設定される。
208 .\"O .SH ERRORS
209 .SH エラー
210 .TP
211 .\"O .BR EACCES " or " EAGAIN
212 .BR EACCES " もしくは " EAGAIN
213 .\"O The file is locked and
214 .\"O .B F_TLOCK
215 .\"O or
216 .\"O .B F_TEST
217 .\"O was specified, or the operation is prohibited because the file has
218 .\"O been memory-mapped by another process.
219 ロックされたファイルに対して、
220 .B F_TLOCK
221 または
222 .B F_TEST
223 が指定されている。
224 または、ファイルが他のプロセスによりメモリーマップされており、
225 指定された操作が禁止されている。
226 .TP
227 .B EBADF
228 .\"O .I fd
229 .\"O is not an open file descriptor; or
230 .\"O .I cmd
231 .\"O is
232 .\"O .B F_LOCK
233 .\"O or
234 .\"O .BR F_TLOCK
235 .\"O and
236 .\"O .I fd
237 .\"O is not a writable file descriptor.
238 .I fd
239 がオープンされたファイルのディスクリプタではない。
240 または、
241 .I cmd
242
243 .B F_LOCK
244
245 .B F_TLOCK
246 で、
247 .I fd
248 が書き込み可能なファイルディスクリプタでない。
249 .TP
250 .B EDEADLK
251 .\"O The command was
252 .\"O .B T_LOCK
253 .\"O and this lock operation would cause a deadlock.
254 コマンドが
255 .B T_LOCK
256 であり、このロック操作を行うとデッドロックが発生してしまう。
257 .TP
258 .B EINVAL
259 .\"O An invalid operation was specified in
260 .\"O .IR fd .
261 .I fd
262 に無効な操作が指定された。
263 .TP
264 .B ENOLCK
265 .\"O Too many segment locks open, lock table is full.
266 非常に多くのセグメントロックが開かれ、ロックテーブルが一杯である。
267 .\"O .SH CONFORMING TO
268 .SH 準拠
269 SVr4, POSIX.1-2001.
270 .\"O .SH "SEE ALSO"
271 .SH 関連項目
272 .\"O .BR fcntl (2),
273 .\"O .BR flock (2)
274 .\"O .br
275 .\"O There are also
276 .\"O .I locks.txt
277 .\"O and
278 .\"O .I mandatory-locking.txt
279 .\"O in the kernel source directory
280 .\"O .IR Documentation/filesystems .
281 .\"O (On older kernels, these files are directly under the
282 .\"O .I Documentation/
283 .\"O directory, and
284 .\"O .I mandatory-locking.txt
285 .\"O is called
286 .\"O .IR mandatory.txt .)
287 .BR fcntl (2),
288 .BR flock (2)
289 .br
290 カーネルソースの
291 .I Documentation/filesystems
292 ディレクトリにある
293 .I locks.txt
294
295 .I mandatory-locking.txt
296 (以前のカーネルでは、これらのファイルは
297 .I Documentation
298 ディレクトリ直下にあり、
299 .I mandatory-locking.txt
300
301 .I mandatory.txt
302 という名前であった。)