[2/3] stdio/rename: use renameat2 when appropriate

Submitted by Drew DeVault on March 21, 2019, 3:32 p.m.

Details

Message ID 20190321153240.29328-3-sir@cmpwn.com
State New
Series "Use v2 syscalls when appropriate"
Headers show

Commit Message

Drew DeVault March 21, 2019, 3:32 p.m.
---
 src/stdio/rename.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/stdio/rename.c b/src/stdio/rename.c
index 04c90c01..f540adb6 100644
--- a/src/stdio/rename.c
+++ b/src/stdio/rename.c
@@ -4,9 +4,11 @@ 
 
 int rename(const char *old, const char *new)
 {
-#ifdef SYS_rename
+#if defined(SYS_rename)
 	return syscall(SYS_rename, old, new);
-#else
+#elif defined(SYS_renameat)
 	return syscall(SYS_renameat, AT_FDCWD, old, AT_FDCWD, new);
+#else
+	return syscall(SYS_renameat2, AT_FDCWD, old, AT_FDCWD, new, 0);
 #endif
 }