Browse Source

use renameat2 syscall, when renameat isn't available

Waldemar Brodkorb 3 years ago
parent
commit
aca82e0eba
1 changed files with 10 additions and 4 deletions
  1. 10 4
      libc/sysdeps/linux/common/renameat.c

+ 10 - 4
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)