1LINKAT(2)                  Linux Programmer's Manual                 LINKAT(2)
2
3
4

NAME

6       linkat - create a file link relative to directory file descriptors
7

SYNOPSIS

9       #include <fcntl.h> /* Definition of AT_* constants */
10       #include <unistd.h>
11
12       int linkat(int olddirfd, const char *oldpath,
13                  int newdirfd, const char *newpath, int flags);
14
15   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
16
17       linkat():
18       Since glibc 2.10: _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
19       Before glibc 2.10: _ATFILE_SOURCE
20

DESCRIPTION

22       The  linkat()  system call operates in exactly the same way as link(2),
23       except for the differences described in this manual page.
24
25       If the pathname given in oldpath is relative, then  it  is  interpreted
26       relative  to  the directory referred to by the file descriptor olddirfd
27       (rather than relative to the current working directory of  the  calling
28       process, as is done by link(2) for a relative pathname).
29
30       If oldpath is relative and olddirfd is the special value AT_FDCWD, then
31       oldpath is interpreted relative to the current working directory of the
32       calling process (like link(2)).
33
34       If oldpath is absolute, then olddirfd is ignored.
35
36       The interpretation of newpath is as for oldpath, except that a relative
37       pathname is interpreted relative to the directory referred  to  by  the
38       file descriptor newdirfd.
39
40       By  default, linkat(), does not dereference oldpath if it is a symbolic
41       link (like link(2)).  Since Linux 2.6.18,  the  flag  AT_SYMLINK_FOLLOW
42       can  be specified in flags to cause oldpath to be dereferenced if it is
43       a symbolic link.  Before kernel 2.6.18, the flags argument was  unused,
44       and had to be specified as 0.
45

RETURN VALUE

47       On  success, linkat() returns 0.  On error, -1 is returned and errno is
48       set to indicate the error.
49

ERRORS

51       The same errors that occur for link(2) can  also  occur  for  linkat().
52       The following additional errors can occur for linkat():
53
54       EBADF  olddirfd or newdirfd is not a valid file descriptor.
55
56       ENOTDIR
57              oldpath  is relative and olddirfd is a file descriptor referring
58              to a file other than a directory; or  similar  for  newpath  and
59              newdirfd
60

VERSIONS

62       linkat() was added to Linux in kernel 2.6.16.
63

CONFORMING TO

65       POSIX.1-2008.
66

NOTES

68       See openat(2) for an explanation of the need for linkat().
69

SEE ALSO

71       link(2), openat(2), path_resolution(7), symlink(7)
72

COLOPHON

74       This  page  is  part of release 3.25 of the Linux man-pages project.  A
75       description of the project, and information about reporting  bugs,  can
76       be found at http://www.kernel.org/doc/man-pages/.
77
78
79
80Linux                             2009-12-13                         LINKAT(2)
Impressum