Section: Linux Programmer's Manual (2)
Return to Main Contents
linkat - create a file link relative to directory file descriptors
#include <fcntl.h> /* Definition of AT_* constants */
int linkat(int olddirfd, const char *oldpath,
int newdirfd, const char *newpath, int flags);
Feature Test Macro Requirements for glibc (see
- Since glibc 2.10:
_XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
- Before glibc 2.10:
system call operates in exactly the same way as
except for the differences described in this manual page.
If the pathname given in
is relative, then it is interpreted relative to the directory
referred to by the file descriptor
(rather than relative to the current working directory of
the calling process, as is done by
for a relative pathname).
is relative and
is the special value
is interpreted relative to the current working
directory of the calling process (like
is absolute, then
The interpretation of
is as for
except that a relative pathname is interpreted relative
to the directory referred to by the file descriptor
The following values can be bitwise ORed in
- AT_EMPTY_PATH (since Linux 2.6.39)
is an empty string, create a link to the file referenced by
(which may have been obtained using the
In this case,
can refer to any type of file, not just a directory.
The caller must have the
capability in order to use this flag;
this prevents arbitrary users from creating hard links
using file descriptors received via a UNIX domain socket
(see the discussion of
- AT_SYMLINK_FOLLOW (since Linux 2.6.18)
does not dereference
if it is a symbolic link (like
can be specified in
to be dereferenced if it is a symbolic link.
Before kernel 2.6.18, the
argument was unused, and had to be specified as 0.
On error, -1 is returned and
is set to indicate the error.
The same errors that occur for
can also occur for
The following additional errors can occur for
is not a valid file descriptor.
was specified in
but the caller did not have the
is relative and
is a file descriptor referring to a file other than a directory;
or similar for
was added to Linux in kernel 2.6.16;
library support was added to glibc in version 2.4.
for an explanation of the need for
This page is part of release 3.54 of the Linux
A description of the project,
and information about reporting bugs,
can be found at
- RETURN VALUE
- CONFORMING TO
- SEE ALSO
This document was created by
using the manual pages.
Time: 23:32:32 GMT, January 16, 2018