]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/linkat.2
Wrapped long lines, wrapped at sentence boundaries; stripped trailing
[thirdparty/man-pages.git] / man2 / linkat.2
CommitLineData
db01a903
MK
1.\" Hey Emacs! This file is -*- nroff -*- source.
2.\"
3.\" This manpage is Copyright (C) 2006, Michael Kerrisk
4.\"
5.\" Permission is granted to make and distribute verbatim copies of this
6.\" manual provided the copyright notice and this permission notice are
7.\" preserved on all copies.
8.\"
9.\" Permission is granted to copy and distribute modified versions of this
10.\" manual under the conditions for verbatim copying, provided that the
11.\" entire resulting derived work is distributed under the terms of a
12.\" permission notice identical to this one.
c13182ef 13.\"
db01a903
MK
14.\" Since the Linux kernel and libraries are constantly changing, this
15.\" manual page may be incorrect or out-of-date. The author(s) assume no
16.\" responsibility for errors or omissions, or for damages resulting from
17.\" the use of the information contained herein. The author(s) may not
18.\" have taken the same level of care in the production of this manual,
19.\" which is licensed free of charge, as they might when working
20.\" professionally.
c13182ef 21.\"
db01a903
MK
22.\" Formatted or processed versions of this manual, if unaccompanied by
23.\" the source, must acknowledge the copyright and authors of this work.
24.\"
25.\"
26.TH LINKAT 2 2006-04-10 "Linux 2.6.16" "Linux Programmer's Manual"
27.SH NAME
28linkat \- create a file link relative to directory file descriptors
29.SH SYNOPSIS
30.nf
d44417fb 31.B #define _ATFILE_SOURCE
db01a903
MK
32.B #include <unistd.h>
33.sp
c13182ef 34.BI "int linkat(int " olddirfd ", const char *" oldpath ,
db01a903
MK
35.BI " int " newdirfd ", const char *" newpath ", int " flags );
36.fi
37.SH DESCRIPTION
38The
39.BR linkat ()
40system call operates in exactly the same way as
41.BR link (2),
42except for the differences described in this manual page.
43
c13182ef 44If the pathname given in
db01a903
MK
45.I oldpath
46is relative, then it is interpreted relative to the directory
47referred to by the file descriptor
c13182ef
MK
48.IR olddirfd
49(rather than relative to the current working directory of
db01a903
MK
50the calling process, as is done by
51.BR link (2)
52for a relative pathname).
53
1343b604 54If
db01a903 55.I oldpath
c13182ef 56is relative and
db01a903
MK
57.I olddirfd
58is the special value
59.BR AT_FDCWD ,
60then
61.I oldpath
c13182ef 62is interpreted relative to the current working
db01a903
MK
63directory of the calling process (like
64.BR link (2)).
65
1343b604 66If
db01a903 67.IR oldpath
c13182ef
MK
68is absolute, then
69.I olddirfd
db01a903
MK
70is ignored.
71
72The interpretation of
73.I newpath
c13182ef
MK
74is as for
75.IR oldpath ,
db01a903
MK
76except that a relative pathname is interpreted relative
77to the directory referred to by the file descriptor
78.IR newdirfd .
79
ab926035
MK
80By default,
81.BR linkat (2),
c13182ef 82does not dereference
ab926035 83.I oldpath
c13182ef 84if it is a symbolic link (like
ab926035
MK
85.BR link (2)).
86Since Linux 2.6.18, the flag
87.B AT_SYMLINK_FOLLOW
c13182ef 88can be specified
ab926035
MK
89.I flags
90to cause
91.I oldpath
92to be dereferenced if it is a symbolic link.
93Before kernel 2.6.18, the
db01a903 94.I flags
ab926035 95argument was unused, and had to be specified as 0.
db01a903
MK
96.SH "RETURN VALUE"
97On success,
c13182ef
MK
98.BR linkat ()
99returns 0.
db01a903
MK
100On error, \-1 is returned and
101.I errno
102is set to indicate the error.
103.SH ERRORS
104The same errors that occur for
105.BR link (2)
106can also occur for
107.BR linkat ().
c13182ef 108The following additional errors can occur for
db01a903
MK
109.BR linkat ():
110.TP
111.B EBADF
112.I olddirfd
113or
114.I newdirfd
115is not a valid file descriptor.
116.TP
117.B ENOTDIR
118.I oldpath
b328773d 119is relative and
db01a903
MK
120.I olddirfd
121is a file descriptor referring to a file other than a directory;
122or similar for
123.I newpath
124and
125.IR newdirfd
126.SH NOTES
127See
128.BR openat (2)
129for an explanation of the need for
130.BR linkat ().
131.SH "CONFORMING TO"
132This system call is non-standard but is proposed
133for inclusion in a future revision of POSIX.1.
134.SH VERSIONS
135.BR linkat ()
136was added to Linux in kernel 2.6.16.
137.SH "SEE ALSO"
db01a903
MK
138.BR link (2),
139.BR openat (2),
140.BR path_resolution (2)