-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc][stdio] implement rename via SYS_renameat2 #86140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
SYS_rename may be unavailable on architectures such as aarch64 and riscv. rename can be implemented in terms of SYS_rename, SYS_renameat, or SYS_renameat2. I don't have a full picture of the history here, but it seems that SYS_renameat might also be unavailable on some platforms. `man 2 rename` mentions that SYS_renameat2 was added in Linux 3.15. We don't need to support such ancient kernel versions. Link: llvm#84980 Link: llvm#85068
cc @aniplcc |
@llvm/pr-subscribers-libc Author: Nick Desaulniers (nickdesaulniers) ChangesSYS_rename may be unavailable on architectures such as aarch64 and riscv.
Link: #84980 Full diff: https://github.com/llvm/llvm-project/pull/86140.diff 1 Files Affected:
diff --git a/libc/src/stdio/linux/rename.cpp b/libc/src/stdio/linux/rename.cpp
index f3d684249ad28e..afa025864fb1c5 100644
--- a/libc/src/stdio/linux/rename.cpp
+++ b/libc/src/stdio/linux/rename.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "include/llvm-libc-macros/linux/fcntl-macros.h"
#include "src/stdio/rename.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
@@ -15,7 +16,7 @@
namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(int, rename, (const char *oldpath, const char *newpath)) {
- int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_rename, oldpath, newpath);
+ int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_renameat2, AT_FDCWD, oldpath, AT_FDCWD, newpath, 0);
if (ret >= 0)
return 0;
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
(emphasis added) |
Merging this to unbreak the build. @michaelrj-google when you're online let's chat about what to do for cases like this in the future. I'm happy to write up public docs for whatever policy we decide on. |
Follow up on llvm#86140
SYS_rename may be unavailable on architectures such as aarch64 and riscv. rename can be implemented in terms of SYS_rename, SYS_renameat, or SYS_renameat2. I don't have a full picture of the history here, but it seems that SYS_renameat might also be unavailable on some platforms. `man 2 rename` mentions that SYS_renameat2 was added in Linux 3.15. We don't need to support such ancient kernel versions prior. Link: llvm#84980 Link: llvm#85068
Follow up on llvm#86140
SYS_rename may be unavailable on architectures such as aarch64 and riscv.
rename can be implemented in terms of SYS_rename, SYS_renameat, or
SYS_renameat2. I don't have a full picture of the history here, but it seems
that SYS_renameat might also be unavailable on some platforms.
man 2 rename
mentions that SYS_renameat2 was added in Linux 3.15. We don'tneed to support such ancient kernel versions prior.
Link: #84980
Link: #85068