OSDN Git Service

Update README
[linuxjm/LDP_man-pages.git] / draft / man2 / symlink.2
1 .\" This manpage is Copyright (C) 1992 Drew Eckhardt;
2 .\"             and Copyright (C) 1993 Michael Haardt, Ian Jackson.
3 .\"             and Copyright (C) 2006, 2014 Michael Kerrisk
4 .\"
5 .\" %%%LICENSE_START(VERBATIM)
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 .\" %%%LICENSE_END
26 .\"
27 .\" Modified 1993-07-24 by Rik Faith
28 .\" Modified 1996-04-26 by Nick Duffek <nsd@bbc.com>
29 .\" Modified 1996-11-06 by Eric S. Raymond <esr@thyrsus.com>
30 .\" Modified 1997-01-31 by Eric S. Raymond <esr@thyrsus.com>
31 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
32 .\"
33 .\"*******************************************************************
34 .\"
35 .\" This file was generated with po4a. Translate the source file.
36 .\"
37 .\"*******************************************************************
38 .\"
39 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
40 .\"         all rights reserved.
41 .\" Translated Fri Dec 12 00:32:12 JST 1997
42 .\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
43 .\" Updated & Modifed Sat Feb 12 11:20:18 JST 2005
44 .\"         by Yuichi SATO <ysato444@yahoo.co.jp>
45 .\" Updated 2013-05-06, Akihiro MOTOKI <amotoki@gmail.com>
46 .\"
47 .TH SYMLINK 2 2014\-08\-19 Linux "Linux Programmer's Manual"
48 .SH 名前
49 symlink, symlinkat \- ファイルに新しい名前を付ける
50 .SH 書式
51 .nf
52 \fB#include <unistd.h>\fP
53 .sp
54 \fBint symlink(const char *\fP\fItarget\fP\fB, const char *\fP\fIlinkpath\fP\fB);\fP
55 .sp
56 \fB#include <fcntl.h>           \fP/* AT_* 定数の定義 */
57 \fB#include <unistd.h>\fP
58 .sp
59 \fBint symlinkat(const char *\fP\fItarget\fP\fB, int \fP\fInewdirfd\fP\fB, const char *\fP\fIlinkpath\fP\fB);\fP
60 .sp
61 .fi
62 .in -4n
63 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
64 .in
65 .sp
66 .ad l
67 \fBsymlink\fP():
68 .RS 4
69 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED || _POSIX_C_SOURCE\ >=\ 200112L
70 .RE
71 .sp
72 \fBsymlinkat\fP():
73 .PD 0
74 .ad l
75 .RS 4
76 .TP  4
77 glibc 2.10 以降:
78 _XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L
79 .TP 
80 glibc 2.10 より前:
81 _ATFILE_SOURCE
82 .RE
83 .ad b
84 .PD
85 .SH 説明
86 \fBsymlink\fP()  は \fItarget\fP という文字列をファイルの内容として持つ \fIlinkpath\fP というシンボリックリンク
87 (symbolic link) を作成する。
88
89 シンボリックリンクは実行時に解釈され、 リンクの内容でパスを置き換えて、そのパスを辿ることで、 ファイルやディレクトリに到達する。
90
91 シンボリックリンクはパスの部分に \fI..\fP を含むかもしれない。これは (もしリンクの最初に使用された場合は) リンクの
92 存在するディレクトリの親ディレクトリが参照される。
93
94 シンボリックリンクは (ソフトリンク (soft link) とも呼ばれ)  存在するファイルを指しているかもしれないし、
95 存在しないファイルを指しているかもしれない; 後者の場合は壊れたリンク (dangling link) とも呼ばれる。
96
97 シンボリックリンクの許可 (permission) は無意味である; リンクを追跡する場合には所有権 (ownership) は無視される。
98 ただし、リンクの削除や名前の変更が要求され、かつリンクが存在する ディレクトリにスティッキービット (sticky bit)  (\fBS_ISVTX\fP)
99 が設定されている場合には、所有権のチェックが行われる。
100
101 \fIlinkpath\fP が存在する場合には上書きは\fIされない\fP。
102 .SS symlinkat()
103 \fBsymlinkat\fP() システムコールは \fBsymlink\fP() と全く同様に動作するが、以下で説明する点が異なる。
104
105 \fIlinkpath\fP で指定されたパス名が相対パスの場合、このパス名はファイルディスクリプター \fInewdirfd\fP
106 が参照するディレクトリに対する相対パスと解釈される (\fBsymlink\fP()
107 に相対パス名を渡した場合のように、呼び出したプロセスのカレントワーキングディレクトリに対する相対パスではない)。
108
109 \fIlinkpath\fP で指定されたパス名が相対パスで、 \fInewdirfd\fP が特別な値 \fBAT_FDCWD\fP の場合、
110 (\fBsymlink\fP() と同様に) \fIlinkpath\fP は呼び出したプロセスのカレントワーキングディレクトリに対する相対パスと解釈される。
111
112 \fIlinkpath\fP で指定されたパス名が絶対パスの場合、 \fInewdirfd\fP は無視される。
113 .SH 返り値
114 成功した場合は 0 が返される。エラーの場合は \-1 が返され、 \fIerrno\fP が適切に設定される。
115 .SH エラー
116 .TP 
117 \fBEACCES\fP
118 \fIlinkpath\fP を含んでいるディレクトリへの書き込みが拒否されたか、 \fIlinkpath\fP
119 に含まれているディレクトリのどれかに検索許可が与えられていない (\fBpath_resolution\fP(7)  も参照すること)。
120 .TP 
121 \fBEDQUOT\fP
122 そのファイルシステムのリソース使用量がユーザークォータに達している。対象となるリソースは inode
123 かディスクブロックで、どちらになるかはファイルシステムの実装依存である。
124 .TP 
125 \fBEEXIST\fP
126 \fIlinkpath\fP が既に存在する。
127 .TP 
128 \fBEFAULT\fP
129 \fItarget\fP や \fIlinkpath\fP がアクセス可能なアドレス空間の外を指している。
130 .TP 
131 \fBEIO\fP
132 I/O エラーが発生した。
133 .TP 
134 \fBELOOP\fP
135 \fIlinkpath\fP を解決する際に遭遇したシンボリックリンクが多過ぎる。
136 .TP 
137 \fBENAMETOOLONG\fP
138 \fItarget\fP または \fIlinkpath\fP が長過ぎる。
139 .TP 
140 \fBENOENT\fP
141 \fIlinkpath\fP に含まれるディレクトリ部分が存在しないか、壊れたリンクであるか、 \fItarget\fP が空文字列である。
142 .TP 
143 \fBENOMEM\fP
144 十分なカーネルメモリーがない。
145 .TP 
146 \fBENOSPC\fP
147 そのファイルを含んでいるデバイスに新しいディレクトリエントリーを 作成するための空きがない。
148 .TP 
149 \fBENOTDIR\fP
150 \fIlinkpath\fP に含まれるディレクトリ部分が、実際には、ディレクトリではない。
151 .TP 
152 \fBEPERM\fP
153 \fIlinkpath\fP を含んでいるファイルシステム (file system) が シンボリックリンクの作成をサポートしていない。
154 .TP 
155 \fBEROFS\fP
156 \fIlinkpath\fP が読み込み専用のファイルシステムに存在している。
157 .PP
158 \fBsymlinkat\fP() では以下のエラーも発生する。
159 .TP 
160 \fBEBADF\fP
161 \fInewdirfd\fP が有効なファイルディスクリプターでない。
162 .TP 
163 \fBENOENT\fP
164 \fIlinkpath\fP が相対パス名で、 \fInewdirfd\fP が削除されたディレクトリを参照している。
165 .TP 
166 \fBENOTDIR\fP
167 \fIlinkpath\fP が相対パスで、 \fInewdirfd\fP がディレクトリ以外のファイルを参照しているファイルディスクリプターである。
168 .SH バージョン
169 \fBsymlinkat\fP()  はカーネル 2.6.16 で Linux に追加された。 ライブラリによるサポートはバージョン 2.4 で glibc
170 に追加された。
171 .SH 準拠
172 .\" SVr4 documents additional error codes EDQUOT and ENOSYS.
173 .\" See
174 .\" .BR open (2)
175 .\" re multiple files with the same name, and NFS.
176 \fBsymlink\fP(): SVr4, 4.3BSD, POSIX.1\-2001, POSIX.1\-2008.
177
178 \fBsymlinkat\fP(): POSIX.1\-2008.
179 .SH 注意
180 \fItarget\fP についてのチェックは行なわれない。
181
182 シンボリックリンクによって参照される名前を削除すると (それが他にハードリンク (hard link) を持たなければ) 実際にファイルが削除される。
183 この動作が望んだものでない場合は、 \fBlink\fP(2)  を使用すること。
184 .SS "glibc での注意"
185 \fBsymlinkat\fP() が利用できない古いカーネルでは、 glibc ラッパー関数は \fBsymlink\fP(2)
186 を使用するモードにフォールバックする。 \fIpathname\fP が相対パスの場合、 glibc は \fInewdirfd\fP 引き数に対応する
187 \fI/proc/self/fd\fP のシンボリックリンクに基づいてパス名を構成する。
188 .SH 関連項目
189 \fBln\fP(1), \fBlchown\fP(2), \fBlink\fP(2), \fBlstat\fP(2), \fBopen\fP(2), \fBreadlink\fP(2),
190 \fBrename\fP(2), \fBunlink\fP(2), \fBpath_resolution\fP(7), \fBsymlink\fP(7)
191 .SH この文書について
192 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部
193 である。プロジェクトの説明とバグ報告に関する情報は
194 http://www.kernel.org/doc/man\-pages/ に書かれている。