|LINK(2)||System Calls Manual||LINK(2)|
char *name1, const char
fd1, const char
*name1, int fd2,
const char *name2,
link() 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.
linkat() 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 directory.
linkat() is passed the special value
AT_FDCWD (defined in
<fcntl.h>) in the
fd1 or fd2 parameter, the
current working directory is used for resolving the respective
name1 or name2 argument.
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.
linkat() will fail and no link will be created if:
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 OpenBSD 5.0.
|January 19, 2015||OpenBSD-5.8|