| <html lang="en"> |
| <head> |
| <title>File Name Resolution - The GNU C Library</title> |
| <meta http-equiv="Content-Type" content="text/html"> |
| <meta name="description" content="The GNU C Library"> |
| <meta name="generator" content="makeinfo 4.13"> |
| <link title="Top" rel="start" href="index.html#Top"> |
| <link rel="up" href="File-Names.html#File-Names" title="File Names"> |
| <link rel="prev" href="Directories.html#Directories" title="Directories"> |
| <link rel="next" href="File-Name-Errors.html#File-Name-Errors" title="File Name Errors"> |
| <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> |
| <!-- |
| This file documents the GNU C library. |
| |
| This is Edition 0.12, last updated 2007-10-27, |
| of `The GNU C Library Reference Manual', for version |
| 2.8 (Sourcery G++ Lite 2011.03-41). |
| |
| Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, |
| 2003, 2007, 2008, 2010 Free Software Foundation, Inc. |
| |
| Permission is granted to copy, distribute and/or modify this document |
| under the terms of the GNU Free Documentation License, Version 1.3 or |
| any later version published by the Free Software Foundation; with the |
| Invariant Sections being ``Free Software Needs Free Documentation'' |
| and ``GNU Lesser General Public License'', the Front-Cover texts being |
| ``A GNU Manual'', and with the Back-Cover Texts as in (a) below. A |
| copy of the license is included in the section entitled "GNU Free |
| Documentation License". |
| |
| (a) The FSF's Back-Cover Text is: ``You have the freedom to |
| copy and modify this GNU manual. Buying copies from the FSF |
| supports it in developing GNU and promoting software freedom.''--> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <style type="text/css"><!-- |
| pre.display { font-family:inherit } |
| pre.format { font-family:inherit } |
| pre.smalldisplay { font-family:inherit; font-size:smaller } |
| pre.smallformat { font-family:inherit; font-size:smaller } |
| pre.smallexample { font-size:smaller } |
| pre.smalllisp { font-size:smaller } |
| span.sc { font-variant:small-caps } |
| span.roman { font-family:serif; font-weight:normal; } |
| span.sansserif { font-family:sans-serif; font-weight:normal; } |
| --></style> |
| <link rel="stylesheet" type="text/css" href="../cs.css"> |
| </head> |
| <body> |
| <div class="node"> |
| <a name="File-Name-Resolution"></a> |
| <p> |
| Next: <a rel="next" accesskey="n" href="File-Name-Errors.html#File-Name-Errors">File Name Errors</a>, |
| Previous: <a rel="previous" accesskey="p" href="Directories.html#Directories">Directories</a>, |
| Up: <a rel="up" accesskey="u" href="File-Names.html#File-Names">File Names</a> |
| <hr> |
| </div> |
| |
| <h4 class="subsection">11.2.2 File Name Resolution</h4> |
| |
| <p>A file name consists of file name components separated by slash |
| (‘<samp><span class="samp">/</span></samp>’) characters. On the systems that the GNU C library supports, |
| multiple successive ‘<samp><span class="samp">/</span></samp>’ characters are equivalent to a single |
| ‘<samp><span class="samp">/</span></samp>’ character. |
| |
| <p><a name="index-file-name-resolution-908"></a>The process of determining what file a file name refers to is called |
| <dfn>file name resolution</dfn>. This is performed by examining the |
| components that make up a file name in left-to-right order, and locating |
| each successive component in the directory named by the previous |
| component. Of course, each of the files that are referenced as |
| directories must actually exist, be directories instead of regular |
| files, and have the appropriate permissions to be accessible by the |
| process; otherwise the file name resolution fails. |
| |
| <p><a name="index-root-directory-909"></a><a name="index-absolute-file-name-910"></a>If a file name begins with a ‘<samp><span class="samp">/</span></samp>’, the first component in the file |
| name is located in the <dfn>root directory</dfn> of the process (usually all |
| processes on the system have the same root directory). Such a file name |
| is called an <dfn>absolute file name</dfn>. |
| <!-- !!! xref here to chroot, if we ever document chroot. -rm --> |
| |
| <p><a name="index-relative-file-name-911"></a>Otherwise, the first component in the file name is located in the |
| current working directory (see <a href="Working-Directory.html#Working-Directory">Working Directory</a>). This kind of |
| file name is called a <dfn>relative file name</dfn>. |
| |
| <p><a name="index-parent-directory-912"></a>The file name components <samp><span class="file">.</span></samp> (“dot”) and <samp><span class="file">..</span></samp> (“dot-dot”) |
| have special meanings. Every directory has entries for these file name |
| components. The file name component <samp><span class="file">.</span></samp> refers to the directory |
| itself, while the file name component <samp><span class="file">..</span></samp> refers to its |
| <dfn>parent directory</dfn> (the directory that contains the link for the |
| directory in question). As a special case, <samp><span class="file">..</span></samp> in the root |
| directory refers to the root directory itself, since it has no parent; |
| thus <samp><span class="file">/..</span></samp> is the same as <samp><span class="file">/</span></samp>. |
| |
| <p>Here are some examples of file names: |
| |
| <dl> |
| <dt><samp><span class="file">/a</span></samp><dd>The file named <samp><span class="file">a</span></samp>, in the root directory. |
| |
| <br><dt><samp><span class="file">/a/b</span></samp><dd>The file named <samp><span class="file">b</span></samp>, in the directory named <samp><span class="file">a</span></samp> in the root directory. |
| |
| <br><dt><samp><span class="file">a</span></samp><dd>The file named <samp><span class="file">a</span></samp>, in the current working directory. |
| |
| <br><dt><samp><span class="file">/a/./b</span></samp><dd>This is the same as <samp><span class="file">/a/b</span></samp>. |
| |
| <br><dt><samp><span class="file">./a</span></samp><dd>The file named <samp><span class="file">a</span></samp>, in the current working directory. |
| |
| <br><dt><samp><span class="file">../a</span></samp><dd>The file named <samp><span class="file">a</span></samp>, in the parent directory of the current working |
| directory. |
| </dl> |
| |
| <!-- An empty string may ``work'', but I think it's confusing to --> |
| <!-- try to describe it. It's not a useful thing for users to use-rms. --> |
| <p>A file name that names a directory may optionally end in a ‘<samp><span class="samp">/</span></samp>’. |
| You can specify a file name of <samp><span class="file">/</span></samp> to refer to the root directory, |
| but the empty string is not a meaningful file name. If you want to |
| refer to the current working directory, use a file name of <samp><span class="file">.</span></samp> or |
| <samp><span class="file">./</span></samp>. |
| |
| <p>Unlike some other operating systems, the GNU system doesn't have any |
| built-in support for file types (or extensions) or file versions as part |
| of its file name syntax. Many programs and utilities use conventions |
| for file names—for example, files containing C source code usually |
| have names suffixed with ‘<samp><span class="samp">.c</span></samp>’—but there is nothing in the file |
| system itself that enforces this kind of convention. |
| |
| </body></html> |
| |