linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
	valentin.schneider@arm.com, linux-kernel@vger.kernel.org,
	Willy Tarreau <w@1wt.eu>
Subject: [PATCH 2/9] tools/nolibc: make dup2() rely on dup3() when available
Date: Thu, 21 Jan 2021 08:20:24 +0100	[thread overview]
Message-ID: <20210121072031.23777-3-w@1wt.eu> (raw)
In-Reply-To: <20210121072031.23777-1-w@1wt.eu>

A recent boot failure on 5.4-rc3 on arm64 revealed that sys_dup2()
is not available and that only sys_dup3() is implemented, thus let's
detect this and fall back to sys_dup3() when available.
[This is nolibc's upstream commit fd5272ec2c66]

Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 tools/include/nolibc/nolibc.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h
index 3115c6467d10..5fda4d844054 100644
--- a/tools/include/nolibc/nolibc.h
+++ b/tools/include/nolibc/nolibc.h
@@ -1502,10 +1502,22 @@ int sys_dup(int fd)
 	return my_syscall1(__NR_dup, fd);
 }
 
+#ifdef __NR_dup3
+static __attribute__((unused))
+int sys_dup3(int old, int new, int flags)
+{
+	return my_syscall3(__NR_dup3, old, new, flags);
+}
+#endif
+
 static __attribute__((unused))
 int sys_dup2(int old, int new)
 {
+#ifdef __NR_dup3
+	return my_syscall3(__NR_dup3, old, new, 0);
+#else
 	return my_syscall2(__NR_dup2, old, new);
+#endif
 }
 
 static __attribute__((unused))
@@ -1876,6 +1888,20 @@ int dup2(int old, int new)
 	return ret;
 }
 
+#ifdef __NR_dup3
+static __attribute__((unused))
+int dup3(int old, int new, int flags)
+{
+	int ret = sys_dup3(old, new, flags);
+
+	if (ret < 0) {
+		SET_ERRNO(-ret);
+		ret = -1;
+	}
+	return ret;
+}
+#endif
+
 static __attribute__((unused))
 int execve(const char *filename, char *const argv[], char *const envp[])
 {
-- 
2.28.0


  parent reply	other threads:[~2021-01-21  7:29 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-21  7:20 [PATCH 0/9] tools/nolibc: fix build issues on aarch64 after unistd cleanup Willy Tarreau
2021-01-21  7:20 ` [PATCH 1/9] tools/nolibc: the definition dup() was missing Willy Tarreau
2021-01-21  7:20 ` Willy Tarreau [this message]
2021-01-21  7:20 ` [PATCH 3/9] tools/nolibc: make getpgrp() fall back to getpgid(0) Willy Tarreau
2021-01-21  7:20 ` [PATCH 4/9] tools/nolibc: implement fork() based on clone() Willy Tarreau
2021-01-21  7:20 ` [PATCH 5/9] tools/nolibc: implement poll() based on ppoll() Willy Tarreau
2021-01-21  7:20 ` [PATCH 6/9] tools/nolibc: get timeval, timespec and timezone from linux/time.h Willy Tarreau
2021-01-21  7:20 ` [PATCH 7/9] tools/nolibc: remove incorrect definitions of __ARCH_WANT_* Willy Tarreau
2021-01-21  7:20 ` [PATCH 8/9] tools/nolibc: emit a detailed error when missing alternate syscall number definitions Willy Tarreau
2021-01-21  7:20 ` [PATCH 9/9] tools/nolibc: fix position of -lgcc in the documented example Willy Tarreau
2021-01-21  7:48 ` [PATCH 10/9] tools/rcutorture: fix position of -lgcc in mkinitrd.sh Willy Tarreau
2021-01-21 11:05 ` [PATCH 0/9] tools/nolibc: fix build issues on aarch64 after unistd cleanup Valentin Schneider
2021-01-21 11:07   ` Willy Tarreau
2021-01-21 11:13   ` Mark Rutland
2021-01-21 11:11 ` Mark Rutland
2021-01-21 14:18   ` Willy Tarreau
2021-01-21 19:54     ` Paul E. McKenney
2021-01-21 20:17       ` Willy Tarreau
2021-01-21 21:36         ` Paul E. McKenney
2021-01-22 12:03   ` Paul E. McKenney
2021-01-22 12:25     ` Mark Rutland
2021-01-22 15:42       ` Paul E. McKenney

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=20210121072031.23777-3-w@1wt.eu \
    --to=w@1wt.eu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=paulmck@kernel.org \
    --cc=valentin.schneider@arm.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.
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).