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       #define _ATFILE_SOURCE
11       #include <fcntl.h>
12
13       int unlinkat(int dirfd, const char *pathname, int flags);
14

DESCRIPTION

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

RETURN VALUE

42       On success, unlinkat() returns 0.  On error, -1 is returned  and  errno
43       is set to indicate the error.
44

ERRORS

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

VERSIONS

59       unlinkat() was added to Linux in kernel 2.6.16.
60

CONFORMING TO

62       POSIX.1-2008.  A similar system call exists on Solaris.
63

NOTES

65       See openat(2) for an explanation of the need for unlinkat().
66

SEE ALSO

68       openat(2), rmdir(2), unlink(2), path_resolution(7)
69

COLOPHON

71       This page is part of release 3.22 of the Linux  man-pages  project.   A
72       description  of  the project, and information about reporting bugs, can
73       be found at http://www.kernel.org/doc/man-pages/.
74
75
76
77Linux                             2008-08-21                       UNLINKAT(2)
Impressum