OSDN Git Service

5ad9e55df27ad462378e2597e00a93bf63d84672
[linuxjm/LDP_man-pages.git] / draft / man2 / link.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" This manpage is Copyright (C) 1992 Drew Eckhardt;
4 .\"                               1993 Michael Haardt, Ian Jackson.
5 .\"
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
9 .\"
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
14 .\"
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein.  The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .\"
26 .\" Modified 1993-07-23 by Rik Faith <faith@cs.unc.edu>
27 .\" Modified 1994-08-21 by Michael Haardt
28 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
29 .\" Modified 2005-04-04, as per suggestion by Michael Hardt for rename.2
30 .\"
31 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
32 .\"         all rights reserved.
33 .\" Translated Thu Dec 11 23:47:55 JST 1997
34 .\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
35 .\" Updated & Modified Tue Feb  8 06:36:08 JST 2005
36 .\"         by Yuichi SATO <ysato444@yahoo.co.jp>
37 .\" Updated & Modified Fri Apr 22 02:05:00 JST 2005 by Yuichi SATO
38 .\" Updated 2008-09-07, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.08
39 .\"
40 .\"WORD:        link                    リンク
41 .\"WORD:        hard link               ハード・リンク
42 .\"WORD:        overwrite               上書き
43 .\"WORD:        permission              許可(permission)
44 .\"WORD:        ownership               所有者(ownership)
45 .\"WORD:        file system             ファイル・システム
46 .\"WORD:        effective uid           実効ユーザーID
47 .\"WORD:        kernel                  カーネル
48 .\"WORD:        symbolic link           シンボリック・リンク
49 .\"WORD:        dangling symbolic link  壊れたシンボリック・リンク
50 .\"WORD:        directory entry         ディレクトリ・エントリ
51 .\"
52 .TH LINK 2 2008-08-21 "Linux" "Linux Programmer's Manual"
53 .\"O .SH NAME
54 .SH 名前
55 .\"O link \- make a new name for a file
56 link \- ファイルの新しい名前を作成する
57 .\"O .SH SYNOPSIS
58 .SH 書式
59 .B #include <unistd.h>
60 .sp
61 .BI "int link(const char *" oldpath ", const char *" newpath );
62 .\"O .SH DESCRIPTION
63 .SH 説明
64 .\"O .BR link ()
65 .\"O creates a new link (also known as a hard link) to an existing file.
66 .BR link ()
67 は存在するファイルへの新しいリンク (link)
68 (ハード・リンク (hard link) ともいう) を作成する。
69
70 .\"O If
71 .\"O .I newpath
72 .\"O exists it will
73 .\"O .I not
74 .\"O be overwritten.
75 .I newpath
76 が存在する場合には上書きは\fIされない\fR。
77
78 .\"O This new name may be used exactly as the old one for any operation;
79 .\"O both names refer to the same file (and so have the same permissions
80 .\"O and ownership) and it is impossible to tell which name was the
81 .\"O original.
82 この新しい名前は全ての操作において古い名前と完全に同じように使用される;
83 両方の名前は同じファイルを参照しており
84 (それで同じ許可 (permission) や所有者 (ownership) となるので)、
85 どちらの名前が本来のものであるか判別できない。
86 .\"O .SH "RETURN VALUE"
87 .SH 返り値
88 .\"O On success, zero is returned.
89 .\"O On error, \-1 is returned, and
90 .\"O .I errno
91 .\"O is set appropriately.
92 成功した場合は 0 が返される。エラーの場合は \-1 が返され、
93 .I errno
94 が適切に設定される。
95 .\"O .SH ERRORS
96 .SH エラー
97 .TP
98 .B EACCES
99 .\"O Write access to the directory containing
100 .\"O .I newpath
101 .\"O is denied, or search permission is denied for one of the directories
102 .\"O in the path prefix of
103 .\"O .I oldpath
104 .\"O or
105 .\"O .IR newpath .
106 .\"O (See also
107 .\"O .BR path_resolution (7).)
108 .I newpath
109 を含んでいるディレクトリへの書き込みが許されていないか、
110 .I oldpath
111 または
112 .I newpath
113 へのディレクトリのどれかに検索許可がない
114 .RB ( path_resolution (7)
115 を参照)。
116 .TP
117 .B EEXIST
118 .\"O .I newpath
119 .\"O already exists.
120 .I newpath
121 が既に存在する。
122 .TP
123 .B EFAULT
124 .\"O .IR oldpath " or " newpath " points outside your accessible address space."
125 .IR oldpath " または " newpath "
126 がアクセス可能なアドレス空間の外を指している。
127 .TP
128 .B EIO
129 .\"O An I/O error occurred.
130 I/O エラーが発生した。
131 .TP
132 .B ELOOP
133 .\"O Too many symbolic links were encountered in resolving
134 .\"O .IR oldpath " or " newpath .
135 .IR oldpath " または " newpath
136 を解決する際に遭遇したシンボリック・リンクが多過ぎる。
137 .TP
138 .B EMLINK
139 .\"O The file referred to by
140 .\"O .I oldpath
141 .\"O already has the maximum number of links to it.
142 .I oldpath
143 によって参照されるファイルは
144 既に最大数までのリンクを持っている。
145 .TP
146 .B ENAMETOOLONG
147 .\"O .IR oldpath " or " newpath " was too long."
148 .IR oldpath " または " newpath "
149 が長過ぎる。
150 .TP
151 .B ENOENT
152 .\"O A directory component in
153 .\"O .IR oldpath " or " newpath
154 .\"O does not exist or is a dangling symbolic link.
155 .IR oldpath " または " newpath
156 のディレクトリ部分が存在しないか、
157 壊れた(dangling)シンボリック・リンクである。
158 .TP
159 .B ENOMEM
160 .\"O Insufficient kernel memory was available.
161 カーネルに十分なメモリがない。
162 .TP
163 .B ENOSPC
164 .\"O The device containing the file has no room for the new directory
165 .\"O entry.
166 そのファイルを含んでいるデバイスに新しいディレクトリ・エントリを
167 作成するための空きがない。
168 .TP
169 .B ENOTDIR
170 .\"O A component used as a directory in
171 .\"O .IR oldpath " or " newpath
172 .\"O is not, in fact, a directory.
173 .IR oldpath " または " newpath
174 のディレクトリ部分が、実際には、ディレクトリでない。
175 .TP
176 .B EPERM
177 .\"O .I oldpath
178 .\"O is a directory.
179 .I oldpath
180 がディレクトリである。
181 .TP
182 .B EPERM
183 .\"O The file system containing
184 .\"O .IR oldpath " and " newpath
185 .\"O does not support the creation of hard links.
186 .IR oldpath " と " newpath
187 を含んでいるファイル・システムがハード・リンクをサポートしていない。
188 .TP
189 .B EROFS
190 .\"O The file is on a read-only file system.
191 ファイルが読み込み専用のファイル・システムに存在する。
192 .TP
193 .B EXDEV
194 .\"O .IR oldpath " and " newpath
195 .\"O are not on the same mounted file system.
196 .IR oldpath " と " newpath
197 が同じマウントされたファイル・システムに存在しない。
198 .\"O (Linux permits a file system to be mounted at multiple points, but
199 .\"O .BR link ()
200 .\"O does not work across different mount points,
201 .\"O even if the same file system is mounted on both.)
202 (Linux は 1 つのファイル・システムを複数のマウント位置に
203 マウントすることを許可している。
204 しかし
205 .BR link ()
206 は、たとえ同じファイル・システムであっても、
207 別々のマウント位置を跨いでは動作しない。)
208 .\"O .SH "CONFORMING TO"
209 .SH 準拠
210 .\"O SVr4, 4.3BSD, POSIX.1-2001 (but see NOTES)
211 .\"O .\" SVr4 documents additional ENOLINK and
212 .\"O .\" EMULTIHOP error conditions; POSIX.1 does not document ELOOP.
213 .\"O .\" X/OPEN does not document EFAULT, ENOMEM or EIO.
214 SVr4, 4.3BSD, POSIX.1-2001 (但し「注意」を参照)。
215 .\" SVr4 は他に ENOLINK, EMULTIHOP エラー状態についても記述している。
216 .\" POSIX.1 には ELOOP についての記述はない。
217 .\" X/OPEN には EFAULT, ENOMEM, EIO についての記述はない。
218 .\"O .SH NOTES
219 .SH 注意
220 .\"O Hard links, as created by
221 .\"O .BR link (),
222 .\"O cannot span file systems.
223 .\"O Use
224 .\"O .BR symlink (2)
225 .\"O if this is required.
226 .BR link ()
227 でファイル・システムを超えてハード・リンクを作成することはできない。
228 このような場合は
229 .BR symlink (2)
230 を使用すること。
231
232 .\"O POSIX.1-2001 says that
233 .\"O .BR link ()
234 .\"O should dereference
235 .\"O .I oldpath
236 .\"O if it is a symbolic link.
237 POSIX.1-2001 では、
238 .I oldpath
239 がシンボリック・リンクである場合、
240 .BR link ()
241
242 .I oldpath
243 の参照を解決すべきであると記述されている。
244 .\"O However, since kernel 2.0,
245 .\"O .\" more precisely: since kernel 1.3.56
246 .\"O Linux does not do so: if
247 .\"O .I oldpath
248 .\"O is a symbolic link, then
249 .\"O .I newpath
250 .\"O is created as a (hard) link to the same symbolic link file
251 しかし、カーネル 2.0 以降の
252 .\" 正確にはカーネル 1.3.56 以降
253 Linux ではそのようになっていない。
254 .I oldpath
255 がシンボリック・リンクである場合、
256 .I newpath
257 は同じシンボリック・リンクファイルへの (ハード) リンクとして作成される
258 .\"O (i.e.,
259 .\"O .I newpath
260 .\"O becomes a symbolic link to the same file that
261 .\"O .I oldpath
262 .\"O refers to).
263 (つまり
264 .I newpath
265
266 .I oldpath
267 が参照していた同じファイルへのシンボリックリンクになる)。
268 .\"O Some other implementations behave in the same manner as Linux.
269 他のいくつかの実装でも Linux と同じように動作する。
270 .\"O .\" For example, the default Solaris compilation environment
271 .\"O .\" behaves like Linux, and contributors to a March 2005
272 .\"O .\" thread in the Austin mailing list reported that some
273 .\"O .\" other (System V) implementations did/do the same -- MTK, Apr 05
274 .\" 例えば、デフォルトの Solaris のコンパイル環境では
275 .\" Linux と同じように動作する。そして Austin メーリングリストの
276 .\" 2005 年 3 月のスレッドに投稿した人たちは、
277 .\" その他のいくつかの (System V) 実装でも同じであった/ある、
278 .\" と報告している -- MTK, Apr 05
279 .\"O POSIX.1-2008 changes the specification of
280 .\"O .BR link (),
281 .\"O making it implementation-dependent whether or not
282 .\"O .I oldpath
283 .\"O is dereferenced if it is a symbolic link.
284 .\"O For precise control over the treatment of symbolic links when
285 .\"O creating a link, see
286 .\"O .BR linkat (2).
287 POSIX.1-2008 では
288 .BR link ()
289 の仕様が変更され、
290 .I oldpath
291 がシンボリック・リンクの場合にシンボリック・リンクの参照を
292 解決するかどうかは実装依存となった。
293 リンク作成時のシンボリック・リンクの扱いについての詳細な制御に
294 関しては
295 .BR linkat (2)
296 を参照のこと。
297 .\"O .SH BUGS
298 .SH バグ
299 .\"O On NFS file systems, the return code may be wrong in case the NFS server
300 .\"O performs the link creation and dies before it can say so.
301 .\"O Use
302 .\"O .BR stat (2)
303 .\"O to find out if the link got created.
304 NFS ファイル・システムでは、NFS サーバーがリンクを作成した後に、
305 それを伝える前に死んだ場合には返り値が不正な場合がある。
306 リンクが作成できたかどうか見つけるためには
307 .BR stat (2)
308 を使用すること。
309 .\"O .SH "SEE ALSO"
310 .SH 関連項目
311 .BR ln (1),
312 .BR linkat (2),
313 .BR open (2),
314 .BR rename (2),
315 .BR stat (2),
316 .BR symlink (2),
317 .BR unlink (2),
318 .BR path_resolution (7),
319 .BR symlink (7)