The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: linux-kernel@vger.kernel.org, Danish Khateeb <danishkhateeb03@gmail.com>
Subject: Re: [PATCH v2 4/4] tools/nolibc: remove the open-coded fcntl() in dup2()
Date: Sat, 5 Dec 2026 15:26:28 +0100	[thread overview]
Message-ID: <axQfFBxGoJI4zNI2@1wt.eu> (raw)
In-Reply-To: <20261202-nolibc-fcntl-v2-4-651ff5781baa@weissschuh.net>

On Wed, Dec 02, 2026 at 08:29:49AM +0100, Thomas Weißschuh wrote:
> 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@weissschuh.net>

Yeah much cleaner, thanks!

Reviewed-by: Willy Tarreau <w@1wt.eu>

Willy

> ---
>  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

      reply	other threads:[~2026-12-05 14:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  7:29 [PATCH v2 0/4] tools/nolibc: add support for fcntl() Thomas Weißschuh
2026-12-02  7:29 ` [PATCH v2 1/4] tools/nolibc: derive clang target flags from ARCH if CROSS_COMPILE is not set Thomas Weißschuh
2026-12-05 14:33   ` Willy Tarreau
2026-12-02  7:29 ` [PATCH v2 2/4] selftests/nolibc: split out the structure member compatibility checks Thomas Weißschuh
2026-12-02 11:29   ` David Laight
2026-12-05 14:31     ` Willy Tarreau
2026-12-02  7:29 ` [PATCH v2 3/4] tools/nolibc: add support for fcntl() Thomas Weißschuh
2026-12-05 14:25   ` Willy Tarreau
2026-12-05 14:56     ` Thomas Weißschuh
2026-12-05 16:08       ` Willy Tarreau
2026-12-02  7:29 ` [PATCH v2 4/4] tools/nolibc: remove the open-coded fcntl() in dup2() Thomas Weißschuh
2026-12-05 14:26   ` Willy Tarreau [this message]

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=axQfFBxGoJI4zNI2@1wt.eu \
    --to=w@1wt.eu \
    --cc=danishkhateeb03@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@weissschuh.net \
    /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