aboutsummaryrefslogtreecommitdiff
path: root/libio
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2018-07-05 18:59:02 +0200
committerFlorian Weimer <fweimer@redhat.com>2018-07-05 19:00:10 +0200
commitd6da5cb6a8e0e8a9ce92b7d951a254cf325248d7 (patch)
tree4c8f50e0ec6b6780eb1eb4dd2b496f0a1b1411d3 /libio
parent1002d708232dda9ebff65f6c1409fa067a01b6e0 (diff)
downloadglibc-d6da5cb6a8e0e8a9ce92b7d951a254cf325248d7.zip
glibc-d6da5cb6a8e0e8a9ce92b7d951a254cf325248d7.tar.gz
glibc-d6da5cb6a8e0e8a9ce92b7d951a254cf325248d7.tar.bz2
Add renameat2 function [BZ #17662]
The implementation falls back to renameat if renameat2 is not available in the kernel (or in the kernel headers) and the flags argument is zero. Without kernel support, a non-zero argument returns EINVAL, not ENOSYS. This mirrors what the kernel does for invalid renameat2 flags.
Diffstat (limited to 'libio')
-rw-r--r--libio/stdio.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/libio/stdio.h b/libio/stdio.h
index 731f8e5..739e086 100644
--- a/libio/stdio.h
+++ b/libio/stdio.h
@@ -153,6 +153,18 @@ extern int renameat (int __oldfd, const char *__old, int __newfd,
const char *__new) __THROW;
#endif
+#ifdef __USE_GNU
+/* Flags for renameat2. */
+# define RENAME_NOREPLACE (1 << 0)
+# define RENAME_EXCHANGE (1 << 1)
+# define RENAME_WHITEOUT (1 << 2)
+
+/* Rename file OLD relative to OLDFD to NEW relative to NEWFD, with
+ additional flags. */
+extern int renameat2 (int __oldfd, const char *__old, int __newfd,
+ const char *__new, unsigned int __flags) __THROW;
+#endif
+
/* Create a temporary file and open it read/write.
This function is a possible cancellation point and therefore not