1LINKAT(2) Linux Programmer's Manual LINKAT(2)
2
3
4
6 linkat - create a file link relative to directory file descriptors
7
9 #define _ATFILE_SOURCE
10 #include <unistd.h>
11
12 int linkat(int olddirfd, const char *oldpath,
13 int newdirfd, const char *newpath, int flags);
14
16 The linkat() system call operates in exactly the same way as link(2),
17 except for the differences described in this manual page.
18
19 If the pathname given in oldpath is relative, then it is interpreted
20 relative to the directory referred to by the file descriptor olddirfd
21 (rather than relative to the current working directory of the calling
22 process, as is done by link(2) for a relative pathname).
23
24 If oldpath is relative and olddirfd is the special value AT_FDCWD, then
25 oldpath is interpreted relative to the current working directory of the
26 calling process (like link(2)).
27
28 If oldpath is absolute, then olddirfd is ignored.
29
30 The interpretation of newpath is as for oldpath, except that a relative
31 pathname is interpreted relative to the directory referred to by the
32 file descriptor newdirfd.
33
34 By default, linkat(2), does not dereference oldpath if it is a symbolic
35 link (like link(2)). Since Linux 2.6.18, the flag AT_SYMLINK_FOLLOW
36 can be specified flags to cause oldpath to be dereferenced if it is a
37 symbolic link. Before kernel 2.6.18, the flags argument was unused,
38 and had to be specified as 0.
39
41 On success, linkat() returns 0. On error, -1 is returned and errno is
42 set to indicate the error.
43
45 The same errors that occur for link(2) can also occur for linkat().
46 The following additional errors can occur for linkat():
47
48 EBADF olddirfd or newdirfd is not a valid file descriptor.
49
50 ENOTDIR
51 oldpath is relative and olddirfd is a file descriptor referring
52 to a file other than a directory; or similar for newpath and
53 newdirfd
54
56 See openat(2) for an explanation of the need for linkat().
57
59 This system call is non-standard but is proposed for inclusion in a
60 future revision of POSIX.1.
61
63 linkat() was added to Linux in kernel 2.6.16.
64
66 link(2), openat(2), path_resolution(2)
67
68
69
70Linux 2.6.16 2006-04-10 LINKAT(2)