int
link(
const char *name1
, const char *name2
)
)
function call
atomically creates the specified directory entry (hard link)
name2
with the attributes of the underlying object pointed at by
name1
.
If the link is successful: the link count of the underlying object
is incremented;
name1
and
name2
share equal access and rights
to the
underlying object.
If
name1
is removed, the file
name2
is not deleted and the link count of the
underlying object is
decremented.
name1
must exist for the hard link to
succeed and
both
name1
and
name2
must be in the same file system.
name1
may not be a directory unless the caller is the super-user
and the file system containing it supports linking to directories.
)
will fail and no link will be created if:
ENOTDIR
]
ENAMETOOLONG
]
{NAME_MAX}
characters, or an entire path name exceeded
{PATH_MAX}
characters.
ENOENT
]
EACCES
]
ELOOP
]
ENOENT
]
name1
does not exist.
EOPNOTSUPP
]
name1
does not support links.
EMLINK
]
name1
would exceed
{LINK_MAX}
.
EEXIST
]
name2
does exist.
EPERM
]
name1
is a directory and the effective
user ID is not super-user,
or the file system containing the file does not permit the use of
link(
)
on a directory.
EXDEV
]
name2
and the file named by
name1
are on different file systems.
ENOSPC
]
EDQUOT
]
EIO
]
EROFS
]
EFAULT
]
)
function conforms to
ISO/IEC 9945-1:1990 (``POSIX.1'') .