1UNLINKAT(2)                Linux Programmer's Manual               UNLINKAT(2)
2
3
4

NAME

6       unlinkat  -  remove  a  directory  entry  relative  to a directory file
7       descriptor
8

SYNOPSIS

10       #include <fcntl.h> /* Definition of AT_* constants */
11       #include <unistd.h>
12
13       int unlinkat(int dirfd, const char *pathname, int flags);
14
15   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
16
17       unlinkat():
18           Since glibc 2.10:
19               _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
20           Before glibc 2.10:
21               _ATFILE_SOURCE
22

DESCRIPTION

24       The unlinkat() system call operates in exactly the same way  as  either
25       unlink(2)  or  rmdir(2) (depending on whether or not flags includes the
26       AT_REMOVEDIR flag) except for the differences described in this  manual
27       page.
28
29       If  the  pathname given in pathname is relative, then it is interpreted
30       relative to the directory referred to  by  the  file  descriptor  dirfd
31       (rather  than  relative to the current working directory of the calling
32       process, as is done by unlink(2) and rmdir(2) for a relative pathname).
33
34       If the pathname given in pathname is relative and dirfd is the  special
35       value  AT_FDCWD,  then  pathname is interpreted relative to the current
36       working directory of the calling process (like unlink(2) and rmdir(2)).
37
38       If the pathname given in pathname is absolute, then dirfd is ignored.
39
40       flags is a bit mask that can either be specified  as  0,  or  by  ORing
41       together  flag  values  that control the operation of unlinkat().  Cur‐
42       rently only one such flag is defined:
43
44       AT_REMOVEDIR
45              By default, unlinkat() performs the equivalent of  unlink(2)  on
46              pathname.   If the AT_REMOVEDIR flag is specified, then performs
47              the equivalent of rmdir(2) on pathname.
48

RETURN VALUE

50       On success, unlinkat() returns 0.  On error, -1 is returned  and  errno
51       is set to indicate the error.
52

ERRORS

54       The  same  errors  that occur for unlink(2) and rmdir(2) can also occur
55       for  unlinkat().   The  following  additional  errors  can  occur   for
56       unlinkat():
57
58       EBADF  dirfd is not a valid file descriptor.
59
60       EINVAL An invalid flag value was specified in flags.
61
62       ENOTDIR
63              pathname is relative and dirfd is a file descriptor referring to
64              a file other than a directory.
65

VERSIONS

67       unlinkat() was added to Linux in kernel  2.6.16;  library  support  was
68       added to glibc in version 2.4.
69

CONFORMING TO

71       POSIX.1-2008.  A similar system call exists on Solaris.
72

NOTES

74       See openat(2) for an explanation of the need for unlinkat().
75

SEE ALSO

77       openat(2), rmdir(2), unlink(2), path_resolution(7)
78

COLOPHON

80       This  page  is  part of release 3.53 of the Linux man-pages project.  A
81       description of the project, and information about reporting  bugs,  can
82       be found at http://www.kernel.org/doc/man-pages/.
83
84
85
86Linux                             2012-05-04                       UNLINKAT(2)
Impressum