OSDN Git Service

df2d5822ba7f9204de666d8bba0bd3ba2742a0e7
[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 2010-09-20 "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.
230 .I fd
231 ¤¬¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤Î¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤Ï¤Ê¤¤¡£
232 .TP
233 .B EDEADLK
234 .\"O The command was
235 .\"O .B T_LOCK
236 .\"O and this lock operation would cause a deadlock.
237 ¥³¥Þ¥ó¥É¤¬
238 .B T_LOCK
239 ¤Ç¤¢¤ê¡¢¤³¤Î¥í¥Ã¥¯Áàºî¤ò¹Ô¤¦¤È¥Ç¥Ã¥É¥í¥Ã¥¯¤¬È¯À¸¤·¤Æ¤·¤Þ¤¦¡£
240 .TP
241 .B EINVAL
242 .\"O An invalid operation was specified in
243 .\"O .IR fd .
244 .I fd
245 ¤Ë̵¸ú¤ÊÁàºî¤¬»ØÄꤵ¤ì¤¿¡£
246 .TP
247 .B ENOLCK
248 .\"O Too many segment locks open, lock table is full.
249 Èó¾ï¤Ë¿¤¯¤Î¥»¥°¥á¥ó¥È¥í¥Ã¥¯¤¬³«¤«¤ì¡¢¥í¥Ã¥¯¥Æ¡¼¥Ö¥ë¤¬°ìÇդǤ¢¤ë¡£
250 .\"O .SH CONFORMING TO
251 .SH ½àµò
252 SVr4, POSIX.1-2001.
253 .\"O .SH "SEE ALSO"
254 .SH ´ØÏ¢¹àÌÜ
255 .\"O .BR fcntl (2),
256 .\"O .BR flock (2)
257 .\"O .br
258 .\"O There are also
259 .\"O .I locks.txt
260 .\"O and
261 .\"O .I mandatory-locking.txt
262 .\"O in the kernel source directory
263 .\"O .IR Documentation/filesystems .
264 .\"O (On older kernels, these files are directly under the
265 .\"O .I Documentation/
266 .\"O directory, and
267 .\"O .I mandatory-locking.txt
268 .\"O is called
269 .\"O .IR mandatory.txt .)
270 .BR fcntl (2),
271 .BR flock (2)
272 .br
273 ¥«¡¼¥Í¥ë¥½¡¼¥¹¤Î
274 .I Documentation/filesystems
275 ¥Ç¥£¥ì¥¯¥È¥ê¤Ë¤¢¤ë
276 .I locks.txt
277 ¤È
278 .I mandatory-locking.txt
279 (°ÊÁ°¤Î¥«¡¼¥Í¥ë¤Ç¤Ï¡¢¤³¤ì¤é¤Î¥Õ¥¡¥¤¥ë¤Ï
280 .I Documentation
281 ¥Ç¥£¥ì¥¯¥È¥êľ²¼¤Ë¤¢¤ê¡¢
282 .I mandatory-locking.txt
283 ¤Ï
284 .I mandatory.txt
285 ¤È¤¤¤¦Ì¾Á°¤Ç¤¢¤Ã¤¿¡£)