[PATCH 3/3] tools/nolibc: remove the open-coded fcntl() in dup2()
From: Thomas Weißschuh
Date: Wed Nov 25 2026 - 04:44:34 EST
Now that nolibc has a proper fctnl() wrapper use that in the dup2()
implementation instead of the open-coded logic.
Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
---
tools/include/nolibc/sys.h | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
index b63fa6c618c5..5cd1c3ea9013 100644
--- a/tools/include/nolibc/sys.h
+++ b/tools/include/nolibc/sys.h
@@ -29,6 +29,7 @@
#include "stdarg.h"
#include "types.h"
+static int _sys_fcntl(int fd, int cmd, unsigned long arg);
/* Syscall return helper: takes the syscall value in argument and checks for an
* error in it. This may only be used with signed returns (int or long), but
@@ -262,16 +263,10 @@ static __attribute__((unused))
int _sys_dup2(int old, int new)
{
#if defined(__NR_dup3)
- int ret, nr_fcntl;
-
-#ifdef __NR_fcntl64
- nr_fcntl = __NR_fcntl64;
-#else
- nr_fcntl = __NR_fcntl;
-#endif
+ int ret;
if (old == new) {
- ret = __nolibc_syscall2(nr_fcntl, old, F_GETFD);
+ ret = _sys_fcntl(old, F_GETFD, 0);
return ret < 0 ? ret : old;
}
--
2.56.1