Symbolic link
From Free net encyclopedia
In computing, a symbolic link (often shortened to symlink) is a special type of file that serves as a reference to another file. Unlike hard links, a symbolic link points to a symbolic path, known as its target, relative to the directory in which it is contained. As a result, they can be used to refer to files on other mounted file systems. A symbolic link whose target does not exist is known as an orphan.
Symbolic links are transparent, which means that their implementation is invisible to applications. When opened, read, or written, a symbolic link will automatically cause the action to be redirected to its target. The fact that a file is a symbolic link is not hidden, so an application can perform operations on the link itself.
Careful attention must be given to maintenance of symbolic links. Unlike hard links, if the target of a symbolic link is removed, the data is lost and all links to it become orphans. Conversely, removing a symbolic link has no effect on its target.
Storage of symbolic links
Early implementations of symbolic links would store the symbolic link information in standard disk blocks, much like regular files. The file contained the textual reference to the link's target, and an indicator denoting it as a symbolic link.
This arrangement proved to be somewhat slow and could waste disk space on small systems. An alternative called fast symlinks was created in which the link text could be stored within the standard data structures used for storing file information on disk and called inodes. This space is generally used for storing the chain of disk blocks composing a file (60 bytes on the standard Unix file system). This simply means that shorter symbolic links can be referenced quickly. Systems with fast symlinks often fall back to using the older method if the path and filename stored in symlink is larger than the available inode space, or for disk compatibility with other or older versions of the operating system. The original style has been retroactively termed slow symlinks.
Although storing the link value inside the inode saves a disk block and a disk read, it is still necessary to parse the pathname information in the link, which always requires reading an additional inode and generally requires reading other—potentially many—directories, both the list of files and the inodes of each of them until matches are found with link pathname components. Only when a link points to a file inside the same directory are the performance gains significant.
The POSIX standard does not require very many struct stat
values to be meaningful for symlinks. This allows implementations to avoid symlink inodes entirely by storing the symlink data in directories.
Other operating systems
For people familiar with the Microsoft Windows operating system, a symbolic link is similar to a shortcut. However, a program accessing a shortcut with the standard Windows API will end up reading, writing and querying information for the actual shortcut file (.lnk), not the file the shortcut points to. So, unlike symbolic links, shortcuts are not transparent for I/O functions.
Microsoft has indicated that true symbolic linking will be supported in Windows as of the release of Windows Vista/Windows Longhorn Server. Another option under Windows are junction points (this requires NTFS 5.0), which are more similar to symbolic links than Windows shortcuts.
Symbolic links are also similar to aliases in the Mac OS operating system, though they do not track movement of the link target.
Symbolic links are also similar to shadows in the graphical Workplace Shell of the OS/2 operating system.
See also
- Hard link
- Ln (Unix)—The ln command, which is used to create new links on Unix-like systems.
- Modified Directory Structure
- This article was originally based on material from the Free On-line Dictionary of Computing, which is licensed under the GFDL.