LINK
Section: System Calls (2)
Updated: August 1, 1992
Index
Return to Main Contents
NAME
link - make a hard link to a file
SYNOPSIS
int link(const char *existing, const char *new);
DESCRIPTION
The
link
function creates a hard link whose pathname is specified by the new
argument, to an existing file whose pathname is specified by existing.
Both the file and its link share equal access and rights to
the underlying object.
Both pathnames must reside in the same file system---linking across
file systems is not permitted.
Further, for BSD applications,
the existing argument may not name a directory
unless the calling process'
ID is that of the super-user.
POSIX applications can never link a directory.
Upon successful completion, the
link
function increments the link count of the file by one.
It also marks for update the st_ctime field of the file, and the
st_ctime and st_mtime fields of the directory in which the
link is created.
RETURN VALUE
Upon successful completion, the
link
function returns a value of zero. Otherwise, a value of -1 is returned and
errno is set to indicate the error.
ERRORS
If any of the following conditions occurs, the
link
function returns -1 and sets errno to the corresponding value:
- [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.
- [EDQUOT]
-
The directory in which the entry for the new link
is being placed cannot be extended because the
user's quota of disk blocks on the file system
containing the directory has been exhausted.
- [EEXIST]
-
The link named by new already exists.
- [EFAULT]
-
One of the pathnames specified
is outside the process's allocated address space.
- [EINVAL]
-
Either pathname contains a character with the high-order bit set.
- [EIO]
-
An I/O error occurred while reading from or writing to
the file system to make the directory entry.
- [ELOOP]
-
Too many symbolic links were encountered in translating one of the pathnames.
- [EMLINK]
-
The number of links to existing would exceed {LINK_MAX} (POSIX only).
- [ENAMETOOLONG]
-
A component of
path
exceeds 255 characters,
or the entire pathname exceeds 1023 characters.
For POSIX applications these values are given
by the constants {NAME_MAX} and {PATH_MAX}, respectively.
- [ENOENT]
-
A component of either path prefix does not exist,
the file named by existing does not exist,
or either existing or new points to an empty string.
- [ENOSPC]
-
The directory in which the entry for the new link is being placed
cannot be extended because there is no space left on the file
system containing the directory.
- [ENOTDIR]
-
A component of either path prefix is not a directory.
- [EPERM]
-
The file named by existing is a directory
(and for BSD applications the calling process' ID
isn't that of the super-user).
- [EROFS]
-
The requested link requires writing in a directory on a read-only file
system.
- [EXDEV]
-
The link named by new and the file named by existing
are on different file systems.
SEE ALSO
rename(2),
symlink(2),
unlink(2)
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- RETURN VALUE
-
- ERRORS
-
- SEE ALSO
-
This document was created by
man2html,
using the manual pages.
Time: 00:59:15 GMT, September 26, 2024