package/uclibc: add renameat2 syscall wrapper
PATCH 1/1 package/uclibc: add renameat2 syscall wrapper
--- ...02-renameat2-add-new-syscall-wrapper.patch | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 package/uclibc/0002-renameat2-add-new-syscall-wrapper.patch
package/uclibc/0002-renameat2-add-new-syscall-wrapper.patch new file +70 -0
@@ -0,0 +1,70 @@ +From 8201708234efe3ce182beaac42cee84166bea78b Mon Sep 17 00:00:00 2001 +From: Waldemar Brodkorb <[email protected]> +Date: Fri, 20 Nov 2026 05:37:52 +0100 +Subject: [PATCH] renameat2: add new syscall wrapper + +Upstream: https://github.com/wbx-github/uclibc-ng/commit/8201708234efe3ce182beaac42cee84166bea78b +Signed-off-by: Waldemar Brodkorb <[email protected]> +--- + include/stdio.h | 16 ++++++++++++++++ + libc/sysdeps/linux/common/renameat2.c | 21 +++++++++++++++++++++ + 2 files changed, 37 insertions(+) + create mode 100644 libc/sysdeps/linux/common/renameat2.c + +diff --git a/include/stdio.h b/include/stdio.h +index a48fa9b78..5069bc65e 100644 +--- a/include/stdio.h ++++ b/include/stdio.h +@@ -157,6 +157,22 @@ extern int renameat (int __oldfd, const char *__old, int __newfd, + libc_hidden_proto(renameat) + #endif + ++#ifdef __USE_GNU ++/* Flags for renameat2. */ ++# define RENAME_NOREPLACE (1 << 0) ++# define AT_RENAME_NOREPLACE 0x0001 ++# define RENAME_EXCHANGE (1 << 1) ++# define AT_RENAME_EXCHANGE 0x0002 ++# define RENAME_WHITEOUT (1 << 2) ++# define AT_RENAME_WHITEOUT 0x0004 ++ ++/* Rename file OLD relative to OLDFD to NEW relative to NEWFD, with ++ additional flags. */ ++extern int renameat2 (int __oldfd, const char *__old, int __newfd, ++ const char *__new, unsigned int __flags) __THROW; ++libc_hidden_proto(renameat2) ++#endif ++ + __BEGIN_NAMESPACE_STD + /* Create a temporary file and open it read/write. + +diff --git a/libc/sysdeps/linux/common/renameat2.c b/libc/sysdeps/linux/common/renameat2.c +new file mode 100644 +index 000000000..efab4e019 +--- /dev/null ++++ b/libc/sysdeps/linux/common/renameat2.c +@@ -0,0 +1,21 @@ ++/* ++ * renameat2() for uClibc-ng ++ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. ++ */ ++ ++#include <stdio.h> ++#include <fcntl.h> ++#include <sysdep.h> ++#include <errno.h> ++ ++int ++renameat2 (int oldfd, const char *old, int newfd, const char *new, unsigned int flags) ++{ ++#ifdef __NR_renameat2 ++ return INLINE_SYSCALL (renameat2, 5, oldfd, old, newfd, new, flags); ++#else ++ __set_errno(ENOSYS); ++ return -1; ++#endif ++} ++libc_hidden_def (renameat2) +-- +2.47.3 +
Signature · 6 lines
2.47.3 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hi Waldemar,
Quoted 6 lines · Waldemar Brodkorb
Signed-off-by Waldemar Brodkorb <[email protected]>--- ...02-renameat2-add-new-syscall-wrapper.patch | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 package/uclibc/0002-renameat2-add-new-syscall-wrapper.patch
Thanks for the quick fix. I tested it with the configuration of the optee-client autobuilder failure (arm926t, soft-float, headers 6.6):
optee-client 4.9.0 builds now and tee-supplicant links renameat2() from libc. I also built riscv64, which has neither rename nor renameat, so rename.c's local renameat2 stub is used there; it compiles without warnings next to the new declaration in stdio.h.
At runtime (qemu-user, arm and riscv64), RENAME_NOREPLACE onto an existing file fails with EEXIST, RENAME_EXCHANGE swaps the files and RENAME_NOREPLACE to a new name succeeds.
I think this is meant for next (uClibc-ng 1.0.60, where 0002 is the next free number; on master it clashes with 0002-ppc-fix-e500-fenv-support.patch). If so, could you mark it [PATCH next] and add a short commit message, e.g. that optee-client needs renameat2() since 4.8.0, with:
Master and 2026.11 would keep failing until next is merged. My optee-client patch [1] could cover them in the meantime and be reverted on next once your patch is in.
[1] https://patchwork.buildroot.org/project/buildroot/patch/[email protected]/
Best regards,
Yegor
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot