[PATCH 4/5] manual: Document unlinkat

Arjun Shankar arjun@redhat.com
Thu Dec 19 16:12:21 GMT 2024


---
 manual/filesys.texi | 39 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/manual/filesys.texi b/manual/filesys.texi
index 53718830e7..f2b2cea872 100644
--- a/manual/filesys.texi
+++ b/manual/filesys.texi
@@ -339,6 +339,10 @@ applies to the file or directory in the mounted file system, not the
 underlying file system that was mounted over.  This flag is a GNU
 extension.
 
+@item AT_REMOVEDIR
+This flag when passed to @code{unlinkat} causes it to perform an
+@code{rmdir} operation instead of the equivalent of @code{unlink}.
+
 @item AT_SYMLINK_FOLLOW
 If the effective final path component is a symbolic link, the
 operation follows the symbolic link and operates on its target.  (For
@@ -1695,6 +1699,40 @@ file system and can't be modified.
 @end table
 @end deftypefun
 
+@deftypefun int unlinkat (int @var{filedes}, const char *@var{filename}, int @var{flags})
+@standards{POSIX.1-2008, unistd.h}
+@comment Unaudited and therefore marked AC-Unsafe and AS-Unsafe by default
+@safety{@mtsafe{}@asunsafe{@asucorrupt{}}@acunsafe{@acucorrupt{}}}
+This function is a descriptor-relative version of the @code{unlink}
+function above.  @xref{Descriptor-Relative Access}.  The @var{flags}
+argument may either be @code{0} or contain the flag @code{AT_REMOVEDIR}:
+
+@table @code
+@item AT_REMOVEDIR
+This flag causes @code{unlinkat} to perform an @code{rmdir} operation on
+@code{filename} instead of performing the equivalent of @code{unlink}.
+@end table
+
+Compared to @code{unlink}, the following additional error conditions can
+occur:
+
+@table @code
+@item EBADF
+The @var{filedes} argument is not a valid file descriptor.
+
+@item EINVAL
+The @var{flags} argument is not valid for this function.
+
+@item EISDIR
+@var{filename} is a directory but the @var{AT_REMOVEDIR} was not passed in
+@code{flags}.
+
+@item ENOTDIR
+The descriptor @var{filedes} is not associated with a directory, and
+@var{filename} is a relative file name.
+@end table
+@end deftypefun
+
 @deftypefun int rmdir (const char *@var{filename})
 @standards{POSIX.1, unistd.h}
 @safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
@@ -3845,6 +3883,5 @@ The @code{mkdtemp} function comes from OpenBSD.
 @c renameat2
 @c scandirat
 @c symlinkat
-@c unlinkat
 @c utimensat
 @c mknodat
-- 
2.47.1



More information about the Libc-alpha mailing list