

The following example shows how to create a link to a file named /home/cnd/mod1 by creating a new directory entry namedĬreating a Link to a File Within a Program The linkat() function may fail if: The value of the flag argument is not valid. The number of links to the file named by path1 would exceed, or pathname resolution of a symbolic link produced an intermediate result with a

A loop exists in symbolic links encountered during resolution of the path1 or path2 argument. The path2 argument resolves to an existing directory entry or refers to a symbolic link. Write permission, or the calling process does not have permission to access the existing file and this is required by the These functions shall fail if: A component of either path prefix denies search permission, or the requested link requires writing in a directory that denies Otherwise, these functions shall return -1 and set errno to Upon successful completion, these functions shall return 0. Link is created for the symbolic link path1 and not its target. If the AT_SYMLINK_FOLLOW flag is clear in the flag argument and the path1 argument names a symbolic link, a new Identical to a call to link(), except that symbolic links shall be handled as specified by the value of flag. If both fd1 and fd2 have value AT_FDCWD, the behavior shall be Shall be used for the respective path argument. If linkat() is passed the special value AT_FDCWD in the fd1 or fd2 parameter, the current working directory If path1 names a symbolic link, a new link for the target of the symbolic link is created. Values for flag are constructed by a bitwise-inclusive OR of flags from the following list, defined in : AT_SYMLINK_FOLLOW If theĪccess mode is O_SEARCH, the function shall not perform the check. Whether directory searches are permitted using the current permissions of the directory underlying the file descriptor. If the access mode of the open file description associated with the file descriptor is not O_SEARCH, the function shall check In this case a relative path path1 is interpreted relative to the directory associated with the fileĭescriptor fd1 instead of the current working directory and similarly for path2 and the file descriptor fd2. Specified by the value of flag (see below) and except in the case where either path1 or path2 or both are The linkat() function shall be equivalent to the link() function except that symbolic links shall be handled as The implementation may require that the calling process has permission to access the existing file. If link() fails, no link shall be created and the link count of the file shall remain unchanged. Last data modification and last file status change timestamps of the directory that contains the new entry shall be marked for
#Symbolic linker update#
Upon successful completion, link() shall mark for update the last file status change timestamp of the file. If path1 names a symbolic link, it is implementation-defined whether link() follows the symbolic link, or creates If path1 names a directory, link() shall fail unless the process has appropriate privileges and the implementation Link count of the file shall be incremented by one. The link() function shall atomically create a new link for the existing file and the The path2 argument points to a pathname naming

The path1 argument points to a pathname naming an existing file. The link() function shall create a new link (directory entry) for the existing file, path1. Int linkat(int fd1, const char * path1, int fd2 , Int link(const char * path1, const char * path2 ) NAME link, linkat - link one file to another file SYNOPSIS The Open Group Base Specifications Isedition
