link(2) INTERACTIVE UNIX System link(2)
NAME
link - link to a file
SYNOPSIS
int link (path1, path2)
char *path1, *path2;
DESCRIPTION
The path1 argument points to a path name naming an existing
file. The path2 argument points to a path name naming the
new directory entry to be created. The link system call
creates a new link (directory entry) for the existing file.
The link system call will fail and no link will be created
if one or more of the following is true:
[ENOTDIR] A component of either path prefix is not a
directory.
[ENOENT] A component of either path prefix does not
exist.
[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 and
the effective user ID is not superuser.
[EXDEV] The link named by path2 and the file named by
path1 are on different logical devices (file
systems).
[ENOENT] The path2 variable points to a null path
name.
[EACCES] The requested link requires writing in a
directory with a mode that denies write per-
mission.
[EROFS] The requested link requires writing in a
directory on a read-only file system.
[EFAULT] The path variable points outside the allo-
cated 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
Rev. 1.2 Page 1
link(2) INTERACTIVE UNIX System link(2)
call.
[ENOLINK] The path variable points to a remote machine
and the link to that machine is no longer
active.
[EMULTIHOP] Components of path require hopping to multi-
ple remote machines.
[ENOSPC] The directory containing the link cannot be
extended.
[ENAMETOOLONG] (POSIX Only) The length of the path argument
exceeds {PATH_MAX}, or a path name component
is longer than {NAME_MAX} while
{_POSIX_NO_TRUNC} is in effect.
SEE ALSO
unlink(2).
DIAGNOSTICS
Upon successful completion, a value of 0 is returned. Oth-
erwise, a value of -1 is returned, and errno is set to indi-
cate the error.
Rev. 1.2 Page 2