If the pathname does not start with the ’/’ character, the starting lookup directory of the resolution process is the current working directory of the process. (This is also inherited from the parent. It can be changed by use of the chdir(2) system call.)
Pathnames starting with a ’/’ character are called absolute pathnames. Pathnames not starting with a ’/’ are called relative pathnames.
If the process does not have search permission on the current lookup directory, an EACCES error is returned ("Permission denied").
If the component is not found, an ENOENT error is returned ("No such file or directory").
If the component is found, but is neither a directory nor a symbolic link, an ENOTDIR error is returned ("Not a directory").
If the component is found and is a directory, we set the current lookup directory to that directory, and go to the next component.
If the component is found and is a symbolic link (symlink), we first resolve this symbolic link (with the current lookup directory as starting lookup directory). Upon error, that error is returned. If the result is not a directory, an ENOTDIR error is returned. If the resolution of the symlink is successful and returns a directory, we set the current lookup directory to that directory, and go to the next component. Note that the resolution process here involves recursion. In order to protect the kernel against stack overflow, and also to protect against denial of service, there are limits on the maximum recursion depth, and on the maximum number of symlinks followed. An ELOOP error is returned when the maximum is exceeded ("Too many levels of symbolic links").
The path resolution process will assume that these entries have their conventional meanings, regardless of whether they are actually present in the physical filesystem.
One cannot walk down past the root: "/.." is the same as "/".
One can walk out of a mounted filesystem: "path/.." refers to the parent directory of "path", outside of the filesystem hierarchy on "dev".
Of the three bits used, the first bit determines read permission, the second write permission, and the last execute permission in case of ordinary files, or search permission in case of directories.
Linux uses the fsuid instead of the effective user ID in permission checks. Ordinarily the fsuid will equal the effective user ID, but the fsuid can be changed by the system callsetfsuid(2).
(Here "fsuid" stands for something like "file system user ID". The concept was required for the implementation of a user space NFS server at a time when processes could send a signal to a process with the same effective user ID. It is obsolete now. Nobody should use setfsuid(2).)
Similarly, Linux uses the fsgid ("file system group ID") instead of the effective group ID. See setfsgid(2).
On Linux, superuser privileges are divided into capabilities (see capabilities(7)). Two capabilities are relevant for file permissions checks: CAP_DAC_OVERRIDE and CAP_DAC_READ_SEARCH. (A process has these capabilities if its fsuid is 0.)
The CAP_DAC_OVERRIDE capability overrides all permission checking, but only grants execute permission when at least one of the file’s three execute permission bits is set.
The CAP_DAC_READ_SEARCH capability grants read and search permission on directories, and read permission on ordinary files.