link(2)
NAME
link − link to a file
SYNOPSIS
int link (path1, path2)
char ∗path1, ∗path2;
DESCRIPTION
Path1 points to a path name naming an existing file. Path2 points to a path name naming the new directory entry to be created. link creates a new link (directory entry) for the existing file.
link creates hard links. With hard links, both path1 and path2 must be in the same file system. Unless the caller is the super-user, path1 must not be a directory. Both the old and the new link share equal access and rights to the underlying object.
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 The file named by path1 does not exist, or either path1 or path2 points to an empty string.
[EACCES] A component of either path prefix denies search permission, or the requested link requires writing in a directory with a mode that denies write permission.
[EEXIST] The link named by path2 exists.
[ENAMETOOLONG] Either the path1 or path2 argument exceeds {PATH_MAX} in length, or a pathname component is longer than {NAME_MAX} (see pathconf(2)).
[ENOSPC] The directory that would contain the link cannot be extended.
[EPERM] The file named by path1 is a directory and the effective user ID is not super-user.
[EXDEV] The link named by path2 and the file named by path1 are on different logical devices (file systems).
[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.
RETURN VALUE
Upon successful completion, a value of 0 is returned. Otherwise, a value of −1 is returned and errno is set to indicate the error.
SEE ALSO
CX/UX Programmer’s Reference Manual