|LINK(2)||System Calls Manual||LINK(2)|
— make hard link to a file
char *name1, const char
fd1, const char
*name1, int fd2,
const char *name2,
function 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. As mandated by POSIX.1 name1 may not be a directory.
function is equivalent to
link() except that where
name1 or name2 specifies a
relative path, the directory entries linked are resolved relative to the
directories associated with file descriptors fd1 or
fd2 (respectively) instead of the current working
The flag argument is the bitwise OR of zero or more of the following values:
AT_SYMLINK_FOLLOW flag is clear and
name1 names a symbolic link, a new link is created for
the symbolic link name1 and not its target.
Upon successful completion, the value 0 is returned; otherwise the value -1 is returned and the global variable errno is set to indicate the error.
linkat() will fail and no link will be created
NAME_MAXcharacters, or an entire pathname (including the terminating NUL) exceeded
link() on a directory.
linkat() will fail if:
AT_FDCWDnor a valid file descriptor.
linkat() functions are expected to conform to
IEEE Std 1003.1-2008 (“POSIX.1”).
link() system call first appeared in
Version 1 AT&T UNIX. The
linkat() function appeared in
|September 10, 2015||OpenBSD-current|