Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 21 Mar 2019 11:32:39 -0400
From: Drew DeVault <sir@...wn.com>
To: musl@...ts.openwall.com
Cc: Drew DeVault <sir@...wn.com>
Subject: [PATCH 2/3] stdio/rename: use renameat2 when appropriate

---
 src/stdio/rename.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

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
 }
-- 
2.21.0

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.