link(2) link(2)NAME link - link to a file SYNOPSIS int link(path1, path2) char *path1, *path2; DESCRIPTION link creates a new link (directory entry) for an 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, a value of 0 is returned. Oth- erwise, a value of -1 is returned and errno is set to indi- cate 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. [EPERM] A pathname contains a character with the high- order bit set. [ENAMETOOLONG] A component of a pathname exceeded NAME_MAX characters, or an entire pathname exceeded PATH_MAX. [ELOOP] Too many symbolic links were encountered in translating a pathname. [ENOENT] A component of either path prefix does not ex- ist. [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 the superuser. [EXDEV] The link named by path2 and the file named by path1 are on different logical devices (file systems). April, 1990 1
link(2) link(2)[ENOENT] path2 points to a null path name. [EACCES] The requested link requires writing in a direc- tory with a mode that denies write permission. [EROFS] The requested link requires writing in a direc- tory 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. SEE ALSO symlink(2), unlink(2). 2 April, 1990