mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Drew DeVault <sir@cmpwn.com>
To: musl@lists.openwall.com
Cc: Drew DeVault <sir@cmpwn.com>
Subject: [PATCH 2/3] stdio/rename: use renameat2 when appropriate
Date: Thu, 21 Mar 2019 11:32:39 -0400	[thread overview]
Message-ID: <20190321153240.29328-3-sir@cmpwn.com> (raw)
In-Reply-To: <20190321153240.29328-1-sir@cmpwn.com>

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



  parent reply	other threads:[~2019-03-21 15:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-21 15:32 [PATCH 0/3] Use v2 syscalls " Drew DeVault
2019-03-21 15:32 ` [PATCH 1/3] mman/mlock: use mlock2 " Drew DeVault
2019-03-21 15:32 ` Drew DeVault [this message]
2019-03-21 15:32 ` [PATCH 3/3] unistd/renameat: use renameat2 " Drew DeVault
2019-03-22  1:20 ` [PATCH 0/3] Use v2 syscalls " Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190321153240.29328-3-sir@cmpwn.com \
    --to=sir@cmpwn.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).