LINK(2) SysV LINK(2)
NAME
link - link to a file
SYNOPSIS
int link (path1, path2)
const char *path1, *path2;
DESCRIPTION
link creates a link (directory entry) to the file to which path1 points
and gives it the name pointed to by path2. The file to which path1
points must exist.
link atomically creates a new link for the existing file and increments
the link count of the file by one. If link fails, no link is created and
the link count of the file remains unchanged. If path1 names a
directory, link fails. If path2 names a symbolic link, an error is
returnd.
Domain/OS does not require that the calling process has permission to
access the existing file.
Upon successful completion, the link function marks the st_ctime field of
the file for update, and marks the st_ctime and st_mtime fields of the
directory containing the new entry for update.
DIAGNOSTICS
Upon successful completion, the link function returns a value of 0
(zero). If the link() function fails, a value of -1 is returned, no link
is created, and errno is set to indicate the error.
ERRORS
link will fail and no link will be created if one or more of the
following are true:
[ENOTDIR] A component of either path prefix is not a directory.
[ENOENT] A component of either path prefix does not exist or points
to an empty string.
[EACCES] A component of either path prefix denies search
permission.
[ENOENT] The file named by path1 does not exist.
[EEXIST] The link named by path2 exists.
[EPERM] The file named by path1 is a directory.
[EXDEV] The link named by path2 and the file named by path1 are on
different logical devices (file systems).
[ENOENT] path2 points to a null pathname.
[EACCES] The requested link requires writing in a directory with a
mode that denies write permission.
[EROFS] The requested link requires writing in a directory on a
read-only file system.
[EFAULT] path points outside the allocated address space of the
process.
[EMLINK] The maximum number of links to a file would be exceeded.
[EINTR] A signal was caught during the link system call.
[ENOLINK] path points to a remote machine and the link to that
machine is no longer active.
[EMULTIHOP] Components of path require hopping to multiple remote
machines.
[ENAMETOOLONG] The length of the path1 or path2 string exceeds PATH_MAX
or a pathname component is longer than NAME_MAX.
[ENOSPC] The directory to contain the link cannot be extended.
SEE ALSO
unlink(2) symlink(2) rename(2).