NAME
unlinkat
—
remove directory entry or directory
file
LIBRARY
library “libc”
SYNOPSIS
#include <fcntl.h>
#include <unistd.h>
int
unlinkat
(int
fd, const char
*path, int
flags);
DESCRIPTION
Theunlinkat
()
function operates as the
unlink
()
or rmdir
() functions depending on the value of
flags.
The values for the flags are constructed by
a bitwise-inclusive OR of flags from the following list, defined in
<fcntl.h>
:
AT_REMOVEDIR
- Remove a directory file instead of a directory entry.
If path specifies a relative path
the directory entry or directory file to delete is determined relative to
the directory associated with the file descriptor fd
instead of the current working directory. If fd is the
special value AT_FDCWD
the current working directory
is used and the behavior is identical to a call to
rmdir
() or
unlink
().
RETURN VALUES
The unlinkat
() function returns the
value 0 if successful; otherwise the value -1 is returned and
the global variable errno is set to indicate the
error.
ERRORS
The unlinkat
() function can fail with the
same error codes as unlink
() and
rmdir
(). In addition,
unlinkat
() can fail with:
- [
EBADF
] - fd is not a valid file descriptor.
- [
ENOTDIR
] - path is relative and fd does not point to a directory.
- [
EINVAL
] - flags contains unsupported flags.
SEE ALSO
HISTORY
The unlinkat
() system call appeared in
DragonFly 2.3.