Information Technology Reference
In-Depth Information
Hard links, soft links, symbolic links, shortcuts, and aliases
A hard link is a directory mapping from a file name directly to an underlying file. As
we will see in Chapter 13, directories will be implemented by storing mappings from
file names to file numbers that uniquely identify each file. When you first create a file
(e.g., /a/b ), the directory entry you create is a hard link the the new file. If you then use
link() to add another hard link to the file (e.g., link(``/a/b'',``/c/d'') ,) then both
names are equally valid, independent names for the same underlying file. You could, for
example, unlink(``/a/b'') , and /c/d would remain a valid name for the file.
Many systems also support symbolic links also known as soft links. A symbolic link
is a directory mappings from a file name to another file name. If a file is opened via a
symbolic link, the file system first translates the name in the symbolic link to the target
name and then uses the target name to open the file. So, if you create /a/b , create a
symbolic link from /c/d/ to /a/b , and then unlink /a/b , the file is no longer accessible
and open(``/c/d'') will fail.
Although the potential for such dangling links is a disadvantage, symbolic links have
a number of advantages over hard links. First, systems usually allow symbolic links to
directories, not just regular files. Second, a symbolic link can refer to a file stored in a
different file system or volume.
Some operating systems such as Microsoft Windows also support shortcuts, which
appear similar to symbolic links but which are interpreted by the windowing system
rather than by the file system. From the file system's point of view, a shortcut is just a
regular file. The windowing system, however, treats shortcut files specially: when the
shortcut file is selected via the windowing system, the windowing system opens that
file, identifies the target file referenced by the shortcut, and acts as if the target file had
been selected.
A MacOS file alias is similar to a symbolic link but with an added feature: if the target
file is moved to have a new path name, the alias can still be used to reference the file.
USB Volume
/
Movies
vacation.mov
Backup
Figure11.4: This USB disk holds a volume that is the physical storage for a
file system.
Search WWH ::




Custom Search