OSDN Git Service

(split) LDP: Update original to LDP v3.38.
[linuxjm/LDP_man-pages.git] / original / man2 / unlinkat.2
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.
13 .\"
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.
21 .\"
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 UNLINKAT 2 2012-03-25 "Linux" "Linux Programmer's Manual"
27 .SH NAME
28 unlinkat \- remove a directory entry relative to a directory file descriptor
29 .SH SYNOPSIS
30 .nf
31 .B #include <fcntl.h>           /* Definition of AT_* constants */
32 .B #include <unistd.h>
33 .sp
34 .BI "int unlinkat(int " dirfd ", const char *" pathname ", int " flags );
35 .fi
36 .sp
37 .in -4n
38 Feature Test Macro Requirements for glibc (see
39 .BR feature_test_macros (7)):
40 .in
41 .sp
42 .BR unlinkat ():
43 .PD 0
44 .ad l
45 .RS 4
46 .TP 4
47 Since glibc 2.10:
48 _XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L
49 .TP
50 Before glibc 2.10:
51 _ATFILE_SOURCE
52 .RE
53 .ad
54 .PD
55 .SH DESCRIPTION
56 The
57 .BR unlinkat ()
58 system call operates in exactly the same way as either
59 .BR unlink (2)
60 or
61 .BR rmdir (2)
62 (depending on whether or not
63 .I flags
64 includes the
65 .B AT_REMOVEDIR
66 flag)
67 except for the differences described in this manual page.
68
69 If the pathname given in
70 .I pathname
71 is relative, then it is interpreted relative to the directory
72 referred to by the file descriptor
73 .I dirfd
74 (rather than relative to the current working directory of
75 the calling process, as is done by
76 .BR unlink (2)
77 and
78 .BR rmdir (2)
79 for a relative pathname).
80
81 If the pathname given in
82 .I pathname
83 is relative and
84 .I dirfd
85 is the special value
86 .BR AT_FDCWD ,
87 then
88 .I pathname
89 is interpreted relative to the current working
90 directory of the calling process (like
91 .BR unlink (2)
92 and
93 .BR rmdir (2)).
94
95 If the pathname given in
96 .I pathname
97 is absolute, then
98 .I dirfd
99 is ignored.
100
101 .I flags
102 is a bit mask that can either be specified as 0, or by ORing
103 together flag values that control the operation of
104 .BR unlinkat ().
105 Currently only one such flags is defined:
106 .TP
107 .B AT_REMOVEDIR
108 By default,
109 .BR unlinkat ()
110 performs the equivalent of
111 .BR unlink (2)
112 on
113 .IR pathname .
114 If the
115 .B AT_REMOVEDIR
116 flag is specified, then
117 performs the equivalent of
118 .BR rmdir (2)
119 on
120 .IR pathname .
121 .SH "RETURN VALUE"
122 On success,
123 .BR unlinkat ()
124 returns 0.
125 On error, \-1 is returned and
126 .I errno
127 is set to indicate the error.
128 .SH ERRORS
129 The same errors that occur for
130 .BR unlink (2)
131 and
132 .BR rmdir (2)
133 can also occur for
134 .BR unlinkat ().
135 The following additional errors can occur for
136 .BR unlinkat ():
137 .TP
138 .B EBADF
139 .I dirfd
140 is not a valid file descriptor.
141 .TP
142 .B EINVAL
143 An invalid flag value was specified in
144 .IR flags .
145 .TP
146 .B ENOTDIR
147 .I pathname
148 is relative and
149 .I dirfd
150 is a file descriptor referring to a file other than a directory.
151 .SH VERSIONS
152 .BR unlinkat ()
153 was added to Linux in kernel 2.6.16.
154 .SH "CONFORMING TO"
155 POSIX.1-2008.
156 A similar system call exists on Solaris.
157 .SH NOTES
158 See
159 .BR openat (2)
160 for an explanation of the need for
161 .BR unlinkat ().
162 .SH "SEE ALSO"
163 .BR openat (2),
164 .BR rmdir (2),
165 .BR unlink (2),
166 .BR path_resolution (7)