link.2: Use .Fn and add .Nm linkat
[dragonfly.git] / lib / libc / sys / unlinkat.2
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
47 The
48 .Fn unlinkat
49 function
50 operates as the
51 .Fn unlink
52 or
53 .Fn rmdir
54 functions depending on the value of
55 .Fa flags .
56 .Pp
57 The values for the
58 .Fa flags
59 are constructed by a bitwise-inclusive OR of flags from the following list,
60 defined in
61 .In fcntl.h :
62 .Bl -tag -width indent
63 .It Dv AT_REMOVEDIR
64 Remove a directory file instead of a directory entry.
65 .El
66 .Pp
67 If
68 .Fa path
69 specifies a relative path the directory entry or directory file to delete is
70 determined relative to the directory associated with the file descriptor
71 .Fa fd
72 instead of the current working directory.
73 If
74 .Fa fd
75 is the special value
76 .Dv AT_FDCWD
77 the current working directory is used and the behavior is identical to a call to
78 .Fn rmdir
79 or
80 .Fn unlink .
81 .Sh RETURN VALUES
82 .Rv -std unlinkat
83 .Sh ERRORS
84 The
85 .Fn unlinkat
86 function can fail with the same error codes as
87 .Fn unlink
88 and
89 .Fn rmdir .
90 In addition,
91 .Fn unlinkat
92 can fail with:
93 .Bl -tag -width Er
94 .It Bq Er EBADF
95 .Fa fd
96 is not a valid file descriptor.
97 .It Bq Er ENOTDIR
98 .Fa path
99 is relative and
100 .Fa fd
101 does not point to a directory.
102 .It Bq Er EINVAL
103 .Fa flags
104 contains unsupported flags.
105 .El
106 .Sh SEE ALSO
107 .Xr rmdir 2 ,
108 .Xr unlink 2
109 .Sh HISTORY
110 The
111 .Fn unlinkat
112 system call appeared in
113 .Dx 2.3 .