1 .\" Copyright (C) 2003 Andries Brouwer (aeb@cwi.nl)
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" Japanese Version Copyright (c) 2005 Yuichi SATO
24 .\" all rights reserved.
25 .\" Translated 2005-01-26, Yuichi SATO <ysato444@yahoo.co.jp>
26 .\" Updated and Modified 2005-10-27, Akihiro MOTOKI
27 .\" Updated and Modified 2005-11-04, Akihiro MOTOKI
29 .TH PATH_RESOLUTION 7 2009-12-05 "Linux" "Linux Programmer's Manual"
32 .\"O path_resolution \- how a pathname is resolved to a file
33 path_resolution \- ファイルのパス名の解決方法
36 .\"O Some UNIX/Linux system calls have as parameter one or more filenames.
37 .\"O A filename (or pathname) is resolved as follows.
38 いくつかの UNIX/Linux システムコールは、
40 ファイル名 (またはパス名) は以下のようにして解決される。
41 .\"O .SS "Step 1: Start of the resolution process"
42 .SS "ステップ 1: 解決過程を開始する"
43 .\"O If the pathname starts with the \(aq/\(aq character,
44 .\"O the starting lookup directory
45 .\"O is the root directory of the calling process.
46 .\"O (A process inherits its
47 .\"O root directory from its parent.
48 .\"O Usually this will be the root directory
49 .\"O of the file hierarchy.
50 .\"O A process may get a different root directory
54 .\"O A process may get an entirely private mount namespace in case
55 .\"O it\(emor one of its ancestors\(emwas started by an invocation of the
57 .\"O system call that had the
60 .\"O This handles the \(aq/\(aq part of the pathname.
61 パス名が \(aq/\(aq 文字で始まっている場合、
62 ディレクトリ検索の開始点は呼び出し元のプロセスのルートディレクトリになる。
63 (プロセスはルートディレクトリを親プロセスから継承する。
64 通常は、これがファイル階層のルートディレクトリになる。
67 システムコールを使って別のルートディレクトリを取得することもできる。
72 を呼び出すことによって開始されたそのプロセスの子孫は、
73 完全にプライベートなマウント名前空間を取得できる。)
74 パス名の \(aq/\(aq の部分は、このようにして扱われる。
76 .\"O If the pathname does not start with the \(aq/\(aq character, the
77 .\"O starting lookup directory of the resolution process is the current working
78 .\"O directory of the process.
79 .\"O (This is also inherited from the parent.
80 .\"O It can be changed by use of the
83 パス名が \(aq/\(aq 文字で始まっていない場合、
84 解決過程におけるディレクトリ検索の開始点は、
85 プロセスの現在の作業 (working) ディレクトリとなる。
91 .\"O Pathnames starting with a \(aq/\(aq character are called absolute pathnames.
92 .\"O Pathnames not starting with a \(aq/\(aq are called relative pathnames.
93 \(aq/\(aq 文字で始まるパス名は絶対パス名と呼ばれ、
94 \(aq/\(aq 文字で始まらないパス名は相対パス名と呼ばれる。
95 .\"O .SS "Step 2: Walk along the path"
97 .\"O Set the current lookup directory to the starting lookup directory.
98 .\"O Now, for each nonfinal component of the pathname, where a component
99 .\"O is a substring delimited by \(aq/\(aq characters, this component is looked up
100 .\"O in the current lookup directory.
101 現在の検索ディレクトリをディレクトリ検索の開始点とする。
102 そして、パス名の最後の構成要素 (component) でない各構成要素について、
104 ここで構成要素は \(aq/\(aq で区切られた部分文字列である。
106 .\"O If the process does not have search permission on
107 .\"O the current lookup directory,
110 .\"O error is returned ("Permission denied").
111 プロセスが現在の検索ディレクトリの検索許可を持たない場合、
113 エラーが返される ("Permission denied")。
115 .\"O If the component is not found, an
117 .\"O error is returned
118 .\"O \"O ("No such file or directory").
122 ("No such file or directory")。
124 .\"O If the component is found, but is neither a directory nor a symbolic link,
127 .\"O error is returned ("Not a directory").
128 構成要素は見つかったが、ディレクトリでもシンボリックリンクでもない場合、
130 エラーが返される ("Not a directory")。
132 .\"O If the component is found and is a directory, we set the
133 .\"O current lookup directory to that directory, and go to the
135 構成要素が見つかって、かつディレクトリである場合、
136 現在の検索ディレクトリをそのディレクトリに設定し、
139 .\"O If the component is found and is a symbolic link (symlink), we first
140 .\"O resolve this symbolic link (with the current lookup directory
141 .\"O as starting lookup directory).
142 .\"O Upon error, that error is returned.
143 構成要素が見つかって、かつシンボリックリンク (symlink) である場合、
144 (現在の検索ディレクトリをディレクトリ検索の開始点として)
146 .\"O If the result is not a directory, an
148 .\"O error is returned.
152 .\"O If the resolution of the symlink is successful and returns a directory,
153 .\"O we set the current lookup directory to that directory, and go to
154 .\"O the next component.
155 シンボリックリンクの解決が成功してディレクトリが返された場合、
156 そのディレクトリを現在の検索ディレクトリとして設定し、
158 .\"O Note that the resolution process here involves recursion.
159 解決過程に再帰が含まれる点に注意すること。
160 .\"O In order to protect the kernel against stack overflow, and also
161 .\"O to protect against denial of service, there are limits on the
162 .\"O maximum recursion depth, and on the maximum number of symbolic links
166 .\"O error is returned when the maximum is
167 .\"O exceeded ("Too many levels of symbolic links").
169 サービス拒否 (denial of service) から守るため、
170 再帰の最大の深さとシンボリックリンクを辿る最大回数に制限がある。
174 ("Too many levels of symbolic links")。
176 .\"O .\" presently: max recursion depth during symlink resolution: 5
177 .\"O .\" max total number of symbolic links followed: 40
178 .\"O .\" _POSIX_SYMLOOP_MAX is 8
179 .\" 現在のところ: シンボリックリンク解決における再帰の最大の深さは 5 である。
180 .\" シンボリックリンクを辿る最大回数は 40 である。
181 .\" _POSIX_SYMLOOP_MAX は 8 である。
182 .\"O .SS "Step 3: Find the final entry"
183 .SS "ステップ 3: 最後のエントリを見つける"
184 .\"O The lookup of the final component of the pathname goes just like
185 .\"O that of all other components, as described in the previous step,
186 .\"O with two differences: (i) the final component need not be a
187 .\"O directory (at least as far as the path resolution process is
188 .\"O concerned\(emit may have to be a directory, or a nondirectory, because of
189 .\"O the requirements of the specific system call), and (ii) it
190 .\"O is not necessarily an error if the component is not found\(emmaybe
191 .\"O we are just creating it.
192 .\"O The details on the treatment
193 .\"O of the final entry are described in the manual pages of the specific
195 パス名の最後の構成要素の検索は、前のステップで説明した
196 他の全ての構成要素と同じように実行されるが、2 つの違いがある。
197 (i) 最後の構成要素はディレクトリである必要がない
198 (パス解決過程に関する限りはどちらでも構わない \(em
199 特定のシステムコールが要求するものによって、
200 ディレクトリでなければならない場合もあるし、
201 ディレクトリ以外でなければならない場合もある)。
202 (ii) 構成要素が見つからない場合にエラーにする必要はない \(em
203 その構成要素を作成するだけでよい場合もある。
205 特定のシステムコールの man ページで説明されている。
208 .\"O By convention, every directory has the entries "." and "..",
209 .\"O which refer to the directory itself and to its parent directory,
211 慣習として、全てのディレクトリはエントリ "." と ".." を持つ。
212 これらはそれぞれ、そのディレクトリ自身とその親ディレクトリを参照する。
214 .\"O The path resolution process will assume that these entries have
215 .\"O their conventional meanings, regardless of whether they are
216 .\"O actually present in the physical file system.
217 パス解決過程では、これらのエントリが物理的なファイルシステムに
218 実際に存在するか否かに関わらず、慣習的な意味を持つと仮定する。
220 .\"O One cannot walk down past the root: "/.." is the same as "/".
221 ルートより上に辿ることはできない: "/.." は "/" と同じである。
222 .\"O .SS "Mount points"
224 .\"O After a "mount dev path" command, the pathname "path" refers to
225 .\"O the root of the file system hierarchy on the device "dev", and no
226 .\"O longer to whatever it referred to earlier.
227 "mount dev path" コマンドを実行した後、
228 パス名 "path" はデバイス "dev" 上のファイルシステム階層の
229 ルートディレクトリを参照するようになり、以前の位置を参照しない。
231 .\"O One can walk out of a mounted file system: "path/.." refers to
232 .\"O the parent directory of "path",
233 .\"O outside of the file system hierarchy on "dev".
234 マウントされたファイルシステムの外に出ることができる:
235 "path/.." は "dev" 上のファイルシステム階層の外である
236 "path" の親ディレクトリを参照する。
237 .\"O .SS "Trailing slashes"
239 .\"O If a pathname ends in a \(aq/\(aq, that forces resolution of the preceding
240 .\"O component as in Step 2: it has to exist and resolve to a directory.
241 .\"O Otherwise a trailing \(aq/\(aq is ignored.
242 .\"O (Or, equivalently, a pathname with a trailing \(aq/\(aq is equivalent to
243 .\"O the pathname obtained by appending \(aq.\(aq to it.)
244 パス名が \(aq/\(aq で終わっている場合、
245 ステップ 2 において、その前にある構成要素の解決法を次のように強制する:
246 その構成要素が存在しなければならず、ディレクトリとして解決される。
247 存在しない場合は、末尾の \(aq/\(aq が無視される。
248 (また同様に、末尾に \(aq/\(aq があるパス名は、
249 \(aq.\(aq を末尾に加えて得られるパス名と等しい。)
250 .\"O .SS "Final symlink"
251 .SS "最後がシンボリックリンクのとき"
252 .\"O If the last component of a pathname is a symbolic link, then it
253 .\"O depends on the system call whether the file referred to will be
254 .\"O the symbolic link or the result of path resolution on its contents.
255 パス名の最後の構成要素がシンボリックリンクである場合、
256 参照されるファイルをシンボリックリンクとするか、
257 その内容についてパスを解決した結果とするかは、
259 .\"O For example, the system call
261 .\"O will operate on the symlink, while
263 .\"O operates on the file pointed to by the symlink.
269 はシンボリックリンクで指されたファイルに作用する。
270 .\"O .SS "Length limit"
272 .\"O There is a maximum length for pathnames.
273 .\"O If the pathname (or some
274 .\"O intermediate pathname obtained while resolving symbolic links)
277 .\"O error is returned ("Filename too long").
279 パス名 (またはシンボリックリンクを解決するときに得られる中間パス名) が
282 エラーが返される ("Filename too long")。
283 .\"O .SS "Empty pathname"
285 .\"O In the original UNIX, the empty pathname referred to the current directory.
286 .\"O Nowadays POSIX decrees that an empty pathname must not be resolved
291 元々の UNIX では、空のパス名は現在のディレクトリを参照していた。
292 最近、POSIX では空のパス名を解決するべきではないという決定がなされた。
296 .\"O .SS "Permissions"
298 .\"O The permission bits of a file consist of three groups of three bits, cf.\&
302 ファイルの許可ビットは、3 組の 3 ビットから構成される。
307 .\"O The first group of three is used when the effective user ID of
308 .\"O the calling process equals the owner ID of the file.
309 .\"O The second group
310 .\"O of three is used when the group ID of the file either equals the
311 .\"O effective group ID of the calling process, or is one of the
312 .\"O supplementary group IDs of the calling process (as set by
313 .\"O .BR setgroups (2)).
314 .\"O When neither holds, the third group is used.
315 呼び出し元のプロセスの実効ユーザ ID がファイルの所有者 ID と等しい場合、
317 ファイルのグループ ID が呼び出し元のプロセスの実効グループ ID または
319 で設定される) 呼び出し元のプロセスの補助 (supplementary) グループ ID と
320 等しい場合、3 つのうち 2 番目のグループが使われる。
321 どちらにも当てはまらない場合、3 番目のグループが使われる。
323 .\"O Of the three bits used, the first bit determines read permission,
324 .\"O the second write permission, and the last execute permission
325 .\"O in case of ordinary files, or search permission in case of directories.
326 3 ビットが使われる場合、最初のビットは読み込み許可を決定し、
327 2 番目のビットは書き込み許可を決定する。
328 また 3 番目のビットは、通常のファイルの場合は実行許可を表し、
331 .\"O Linux uses the fsuid instead of the effective user ID in permission checks.
332 .\"O Ordinarily the fsuid will equal the effective user ID, but the fsuid can be
333 .\"O changed by the system call
334 .\"O .BR setfsuid (2).
335 Linux は、許可のチェックにおいて、実効ユーザ ID ではなく fsuid を使う。
336 通常は fsuid は実効ユーザ ID と等しいが、fsuid はシステムコール
340 .\"O (Here "fsuid" stands for something like "file system user ID".
341 .\"O The concept was required for the implementation of a user space
342 .\"O NFS server at a time when processes could send a signal to a process
343 .\"O with the same effective user ID.
344 .\"O It is obsolete now.
345 .\"O Nobody should use
346 .\"O .BR setfsuid (2).)
347 (ここで "fsuid" は "file system user ID" を表している。
348 この概念は「プロセスが同じ実効ユーザ ID を持つプロセスに
349 同時にシグナルを送ることができる」というユーザ空間 NFS サーバを
355 .\"O Similarly, Linux uses the fsgid ("file system group ID")
356 .\"O instead of the effective group ID.
358 .\"O .BR setfsgid (2).
359 同様に、Linux では実効グループ ID の代わりに
360 fsgid ("ファイルシステム・グループID") を使う。
363 .\" FIXME say something about file system mounted read-only ?
364 .\"O .SS "Bypassing permission checks: superuser and capabilities"
365 .SS "許可の確認をスキップする: スーパーユーザとケーパビリティ"
366 .\"O On a traditional UNIX system, the superuser
368 .\"O user ID 0) is all-powerful, and bypasses all permissions restrictions
369 .\"O when accessing files.
370 伝統的な UNIX システムでは、スーパーユーザ
372 ユーザ ID 0) は非常に強力であり、ファイルアクセス時の
374 .\" (but for exec at least one x bit must be set) -- AEB
375 .\" but there is variation across systems on this point: for
376 .\" example, HP-UX and Tru64 are as described by AEB. However,
377 .\" on some implementations (e.g., Solaris, FreeBSD),
378 .\" access(X_OK) by superuser will report success, regardless
379 .\" of the file's execute permission bits. -- MTK (Oct 05)
381 .\"O On Linux, superuser privileges are divided into capabilities (see
382 .\"O .BR capabilities (7)).
383 .\"O Two capabilities are relevant for file permissions checks:
384 .\"O \fBCAP_DAC_OVERRIDE\fP and \fBCAP_DAC_READ_SEARCH\fP.
385 .\"O (A process has these capabilities if its fsuid is 0.)
386 Linux では、スーパーユーザ権限が複数のケーパビリティに分割されている
387 .RB ( capabilities (7)
391 .B CAP_DAC_READ_SEARCH
393 (プロセスの fsuid が 0 の場合、そのプロセスはこれらのケーパビリティを持つ)。
395 .\"O The \fBCAP_DAC_OVERRIDE\fP capability overrides all permission checking,
396 .\"O but only grants execute permission when at least one
397 .\"O of the file's three execute permission bits is set.
399 ケーパビリティは全ての許可チェックを上書きする。
400 実際には、対象となるファイルの 3 つの実行許可ビットのうちの
401 少なくとも 1 つが設定されていれば、実行を許可するだけである。
403 .\"O The \fBCAP_DAC_READ_SEARCH\fP capability grants read and search permission
404 .\"O on directories, and read permission on ordinary files.
405 .B CAP_DAC_READ_SEARCH
406 ケーパビリティは、ディレクトリに対して読み込みと検索を許可し、
407 通常のファイルに対して読み込みを許可する。
408 .\" FIXME say something about immutable files
409 .\" FIXME say something about ACLs
413 .BR capabilities (7),