summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2021-01-28 04:10:42 +0100
committerWaldemar Brodkorb <wbx@openadk.org>2021-01-28 04:10:42 +0100
commitaca82e0ebadc48cc63fba4f71664b9b297733db2 (patch)
tree707a9d991cf5b9529638565b8ca4050e282f0fe8 /libc
parent008687f5f659118bd25136fd5a05bcb9a8f9ef5d (diff)
use renameat2 syscall, when renameat isn't available
Diffstat (limited to 'libc')
-rw-r--r--libc/sysdeps/linux/common/renameat.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/libc/sysdeps/linux/common/renameat.c b/libc/sysdeps/linux/common/renameat.c
index b0b91fa3e..0156981de 100644
--- a/libc/sysdeps/linux/common/renameat.c
+++ b/libc/sysdeps/linux/common/renameat.c
@@ -6,12 +6,18 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <sys/syscall.h>
#include <stdio.h>
+#include <fcntl.h>
+#include <sysdep.h>
+#include <errno.h>
+int
+renameat (int oldfd, const char *old, int newfd, const char *new)
+{
#ifdef __NR_renameat
-_syscall4(int, renameat, int, oldfd, const char *, old, int, newfd, const char *, new)
-libc_hidden_def(renameat)
+ return INLINE_SYSCALL (renameat, 4, oldfd, old, newfd, new);
#else
-/* should add emulation with rename() and /proc/self/fd/ ... */
+ return INLINE_SYSCALL (renameat2, 5, oldfd, old, newfd, new, 0);
#endif
+}
+libc_hidden_def (renameat)