link(2)link(2)NAMElink() - link to a file
SYNOPSISDESCRIPTION
The system call creates a new link (directory entry) for the existing
file. path1 points to a path name naming an existing file. path2
points to a path name naming the new directory entry to be created.
RETURN VALUE
Upon successful completion, returns zero. Otherwise, it returns −1 and
sets (see errno(2)) to indicate the error.
ERRORS
The system call fails and no link is created if one or more of the fol‐
lowing is true:
A component of either path prefix denies search permission.
The requested link requires writing in a directory
that does not permit writing.
The user's or group's disk quota block limit has been reached
for this file system.
The link named by
path2 exists.
path points outside the allocated address space of the
process. The reliable detection of this error is
implementation dependent.
Too many symbolic links were encountered in translating either
path name.
The maximum number of links to a file would be exceeded.
Either the specified path exceeds
bytes, or a component of either specified path
exceeds while is in effect.
The file named by
path1 does not exist.
A component of either path prefix does not exist.
path2 points to a null path name.
path1 or path2 is null.
The directory to contain the file cannot be extended.
A component of either path prefix is not a directory.
The file named by
path1 is a directory and the effective user ID is
not a user who has appropriate privileges. Some
file systems return this error whenever path1
names a directory, regardless of the user ID.
The requested link requires writing in a directory
on a read-only file system.
The link named by
path2 and the file named by path1 are on differ‐
ent logical devices (file systems).
SEE ALSOcp(1), link(1M), symlink(2), unlink(2), symlink(4), privileges(5).
STANDARDS CONFORMANCElink(2)