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       #define _ATFILE_SOURCE
10       #include <fcntl.h> /* Definition of AT_* constants */
11       #include <unistd.h>
12
13       int linkat(int olddirfd, const char *oldpath,
14                  int newdirfd, const char *newpath, int flags);
15

DESCRIPTION

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

RETURN VALUE

42       On  success, linkat() returns 0.  On error, -1 is returned and errno is
43       set to indicate the error.
44

ERRORS

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

VERSIONS

57       linkat() was added to Linux in kernel 2.6.16.
58

CONFORMING TO

60       POSIX.1-2008.
61

NOTES

63       See openat(2) for an explanation of the need for linkat().
64

SEE ALSO

66       link(2), openat(2), path_resolution(7), symlink(7)
67

COLOPHON

69       This  page  is  part of release 3.22 of the Linux man-pages project.  A
70       description of the project, and information about reporting  bugs,  can
71       be found at http://www.kernel.org/doc/man-pages/.
72
73
74
75Linux                             2008-08-21                         LINKAT(2)
Impressum