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>
11
12       int unlinkat(int dirfd, const char *pathname, int flags);
13
14   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
15
16       unlinkat():
17       Since glibc 2.10: _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
18       Before glibc 2.10: _ATFILE_SOURCE
19

DESCRIPTION

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

RETURN VALUE

47       On success, unlinkat() returns 0.  On error, -1 is returned  and  errno
48       is set to indicate the error.
49

ERRORS

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

VERSIONS

64       unlinkat() was added to Linux in kernel 2.6.16.
65

CONFORMING TO

67       POSIX.1-2008.  A similar system call exists on Solaris.
68

NOTES

70       See openat(2) for an explanation of the need for unlinkat().
71

SEE ALSO

73       openat(2), rmdir(2), unlink(2), path_resolution(7)
74

COLOPHON

76       This page is part of release 3.25 of the Linux  man-pages  project.   A
77       description  of  the project, and information about reporting bugs, can
78       be found at http://www.kernel.org/doc/man-pages/.
79
80
81
82Linux                             2009-12-13                       UNLINKAT(2)
Impressum