OSDN Git Service

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