In POSIX systems, one file can have many names at the same time. All of the names are equally real, and no one of them is preferred to the others.
To add a name to a file, use the
link function. (The new name is
also called a hard link to the file.) Creating a new link to a
file does not copy the contents of the file; it simply makes a new name
by which the file can be known, in addition to the file's existing name
One file can have names in several directories, so the the organization of the file system is not a strict hierarchy or tree.
In most implementations, it is not possible to have hard links to the
same file in multiple file systems.
link reports an error if you
try to make a hard link to the file from another file system when this
cannot be done.
The prototype for the
link function is declared in the header
linkfunction makes a new link to the existing file named by oldname, under the new name newname.
This function returns a value of
0 if it is successful and
-1 on failure. In addition to the usual file name errors
(see section File Name Errors) for both oldname and newname, the
errno error conditions are defined for this function:
LINK_MAX; see section Limits on File System Capacity.)
Go to the first, previous, next, last section, table of contents.