xref: /dragonfly/lib/libc/sys/unlinkat.2 (revision 279dd846)
1.\" Copyright (c) 2009 The DragonFly Project.  All rights reserved.
2.\"
3.\" This code is derived from software contributed to The DragonFly Project
4.\" by Nicolas Thery <nthery@gmail.com>
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\"
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in
14.\"    the documentation and/or other materials provided with the
15.\"    distribution.
16.\" 3. Neither the name of The DragonFly Project nor the names of its
17.\"    contributors may be used to endorse or promote products derived
18.\"    from this software without specific, prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
24.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
26.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31.\" SUCH DAMAGE.
32.\"
33.Dd August 18, 2009
34.Dt UNLINKAT 2
35.Os
36.Sh NAME
37.Nm unlinkat
38.Nd remove directory entry or directory file
39.Sh LIBRARY
40.Lb libc
41.Sh SYNOPSIS
42.In fcntl.h
43.In unistd.h
44.Ft int
45.Fn unlinkat "int fd" "const char *path" "int flags"
46.Sh DESCRIPTION
47The
48.Fn unlinkat
49function
50operates as the
51.Fn unlink
52or
53.Fn rmdir
54functions depending on the value of
55.Fa flags .
56.Pp
57The values for the
58.Fa flags
59are constructed by a bitwise-inclusive OR of flags from the following list,
60defined in
61.In fcntl.h :
62.Bl -tag -width indent
63.It Dv AT_REMOVEDIR
64Remove a directory file instead of a directory entry.
65.El
66.Pp
67If
68.Fa path
69specifies a relative path the directory entry or directory file to delete is
70determined relative to the directory associated with the file descriptor
71.Fa fd
72instead of the current working directory.
73If
74.Fa fd
75is the special value
76.Dv AT_FDCWD
77the current working directory is used and the behavior is identical to a call to
78.Fn rmdir
79or
80.Fn unlink .
81.Sh RETURN VALUES
82.Rv -std unlinkat
83.Sh ERRORS
84The
85.Fn unlinkat
86function can fail with the same error codes as
87.Fn unlink
88and
89.Fn rmdir .
90In addition,
91.Fn unlinkat
92can fail with:
93.Bl -tag -width Er
94.It Bq Er EBADF
95.Fa fd
96is not a valid file descriptor.
97.It Bq Er ENOTDIR
98.Fa path
99is relative and
100.Fa fd
101does not point to a directory.
102.It Bq Er EINVAL
103.Fa flags
104contains unsupported flags.
105.El
106.Sh SEE ALSO
107.Xr rmdir 2 ,
108.Xr unlink 2
109.Sh HISTORY
110The
111.Fn unlinkat
112system call appeared in
113.Dx 2.3 .
114