diff options
author | Nick Desaulniers <nickdesaulniers@users.noreply.github.com> | 2024-03-21 09:35:18 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-21 09:35:18 -0700 |
commit | 6eff53b4f07c1d8f6ae271254499ec087f40cc83 (patch) | |
tree | c60372abb58c2fad00be6b6842b74678985fbd8f /libc/src/stdio | |
parent | c1c2551a2876f536b5a06f48fa809aeedbc3d7ba (diff) | |
download | llvm-6eff53b4f07c1d8f6ae271254499ec087f40cc83.zip llvm-6eff53b4f07c1d8f6ae271254499ec087f40cc83.tar.gz llvm-6eff53b4f07c1d8f6ae271254499ec087f40cc83.tar.bz2 |
[libc][stdio] implement rename via SYS_renameat2 (#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: #84980
Link: #85068
Diffstat (limited to 'libc/src/stdio')
-rw-r--r-- | libc/src/stdio/linux/rename.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libc/src/stdio/linux/rename.cpp b/libc/src/stdio/linux/rename.cpp index f3d68424..379a6ef 100644 --- a/libc/src/stdio/linux/rename.cpp +++ b/libc/src/stdio/linux/rename.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "src/stdio/rename.h" +#include "include/llvm-libc-macros/linux/fcntl-macros.h" #include "src/__support/OSUtil/syscall.h" // For internal syscall function. #include "src/__support/common.h" #include "src/errno/libc_errno.h" @@ -15,7 +16,8 @@ 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; |