NAME
link - Creates an additional directory entry for an existing
file on current file system
SYNOPSIS
int link (
const char *path1,
const char *path2 );
PARAMETERS
path1 Points to the pathname of an existing file.
path2 Points to the pathname for the directory entry to
be created. If the path2 parameter names a sym-
bolic link, an error is returned.
DESCRIPTION
The link() function creates an additional hard link (direc-
tory entry) for an existing file. Both the old and the new
link share equal access rights to the underlying object.
The link() function atomically creates a new link for the
existing file and increments the link count of the file by
one.
Both the path1 and path2 parameters must reside on the same
file system. A hard link to a directory cannot be created.
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.
NOTES
AES Support Level:
Full use
RETURN VALUES
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
If the link() function fails, errno may be set to one of the
following values:
[ENOENT] The file named by the path1 parameter does not
exist or the path1 or path2 parameter is an empty
string.
[EFAULT] Either the path1 or path2 parameter is an invalid
address.
[EEXIST] The link named by the path2 parameter already
exists.
[EPERM] The file named by the path1 parameter is a direc-
tory.
[EXDEV] The link named by the path2 parameter and the file
named by the path1 parameter are on different file
systems.
[EACCES] The requested link requires writing in a directory
with a mode that denies write permission, or a
component of either the path1 or path2 parameter
denies search permission.
[EMLINK] The number of links to the file named by path1
would exceed LINK_MAX.
[EROFS] The requested link requires writing in a directory
on a read-only file system.
[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.
[ELOOP] Too many links were encountered in translating
either path1 or path2.
[ENAMETOOLONG]
The length of the path1 or path2 string exceeds
PATH_MAX or a pathname component is longer than
NAME_MAX.
[ENOTDIR] A component of either path prefix is not a direc-
tory.
[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.
RELATED INFORMATION
Functions: unlink(2)
Commands: link(1)
Acknowledgement and Disclaimer