qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Subject: Re: [PATCH v3 11/12] linux-user: Add close_range() syscall
Date: Sun, 25 Sep 2022 17:42:50 +0200	[thread overview]
Message-ID: <730a6c07-883f-b1f6-600b-fd1645fc5f0d@vivier.eu> (raw)
In-Reply-To: <20220918194555.83535-12-deller@gmx.de>

Le 18/09/2022 à 21:45, Helge Deller a écrit :
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>   linux-user/strace.list |  3 +++
>   linux-user/syscall.c   | 16 ++++++++++++++++
>   2 files changed, 19 insertions(+)
> 
> diff --git a/linux-user/strace.list b/linux-user/strace.list
> index 215d971b2a..ad9ef94689 100644
> --- a/linux-user/strace.list
> +++ b/linux-user/strace.list
> @@ -103,6 +103,9 @@
>   #ifdef TARGET_NR_close
>   { TARGET_NR_close, "close" , "%s(%d)", NULL, NULL },
>   #endif
> +#ifdef TARGET_NR_close_range
> +{ TARGET_NR_close_range, "close_range" , "%s(%d,%d,%d)", NULL, NULL },
> +#endif
>   #ifdef TARGET_NR_connect
>   { TARGET_NR_connect, "connect" , "%s(%d,%#x,%d)", NULL, NULL },
>   #endif
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index ca39acfceb..2e0e974562 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -338,6 +338,10 @@ _syscall3(int,sys_syslog,int,type,char*,bufp,int,len)
>   #ifdef __NR_exit_group
>   _syscall1(int,exit_group,int,error_code)
>   #endif
> +#if defined(__NR_close_range) && defined(TARGET_NR_close_range)
> +#define __NR_sys_close_range __NR_close_range
> +_syscall3(int,sys_close_range,int,first,int,last,int,flags)
> +#endif
>   #if defined(__NR_futex)
>   _syscall6(int,sys_futex,int *,uaddr,int,op,int,val,
>             const struct timespec *,timeout,int *,uaddr2,int,val3)
> @@ -8721,6 +8725,18 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
>       case TARGET_NR_close:
>           fd_trans_unregister(arg1);
>           return get_errno(close(arg1));
> +#if defined(__NR_close_range) && defined(TARGET_NR_close_range)
> +    case TARGET_NR_close_range:
> +        {
> +            abi_long fd;
> +            abi_long maxfd = (arg2 == (abi_long)-1) ? target_fd_max : arg2;
> +
> +            for (fd = arg1; fd <= maxfd; fd++) {
> +                fd_trans_unregister(fd);
> +            }
> +        }
> +        return get_errno(sys_close_range(arg1, arg2, arg3));

if flags is CLOSE_RANGE_CLOEXEC, the fd is not closed so you don't want to call 
fd_trans_unregister() in this case.

It would be better to call fd_trans_unregister() loop only if sys_close_range() doesn't fail.

Thanks,
Laurent

> +#endif
> 
>       case TARGET_NR_brk:
>           return do_brk(arg1);
> --
> 2.37.3
> 
> 



  reply	other threads:[~2022-09-25 15:43 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-18 19:45 [PATCH v3 00/12] linux-user: Add more syscalls, enhance tracing & logging enhancements Helge Deller
2022-09-18 19:45 ` [PATCH v3 01/12] linux-user: Add missing signals in strace output Helge Deller
2022-09-25 15:00   ` Laurent Vivier
2022-09-18 19:45 ` [PATCH v3 02/12] linux-user: Add missing clock_gettime64() syscall strace Helge Deller
2022-09-25 15:09   ` Laurent Vivier
2022-09-25 15:27     ` Helge Deller
2022-09-25 15:47       ` Laurent Vivier
2022-09-25 15:53         ` Helge Deller
2022-09-25 15:58           ` Laurent Vivier
2022-09-25 16:09             ` Helge Deller
2022-09-18 19:45 ` [PATCH v3 03/12] linux-user: Add pidfd_open(), pidfd_send_signal() and pidfd_getfd() syscalls Helge Deller
2022-09-25 15:25   ` Laurent Vivier
2022-09-18 19:45 ` [PATCH v3 04/12] linux-user: Log failing executable in EXCP_DUMP() Helge Deller
2022-09-18 20:37   ` Philippe Mathieu-Daudé via
2022-09-25 15:26   ` Laurent Vivier
2022-09-18 19:45 ` [PATCH v3 05/12] linux-user/hppa: Use EXCP_DUMP() to show enhanced debug info Helge Deller
2022-09-25 15:26   ` Laurent Vivier
2022-09-18 19:45 ` [PATCH v3 06/12] linux-user/hppa: Dump IIR on register dump Helge Deller
2022-09-18 20:38   ` Philippe Mathieu-Daudé via
2022-09-25 15:27   ` Laurent Vivier
2022-09-18 19:45 ` [PATCH v3 07/12] linux-user: Fix strace of chmod() if mode == 0 Helge Deller
2022-09-18 20:46   ` Philippe Mathieu-Daudé via
2022-09-25 15:29   ` Laurent Vivier
2022-09-18 19:45 ` [PATCH v3 08/12] linux-user/hppa: Set TASK_UNMAPPED_BASE to 0xfa000000 for hppa arch Helge Deller
2022-09-18 19:45 ` [PATCH v3 09/12] linux-user: Add strace for clock_nanosleep() Helge Deller
2022-09-25 15:36   ` Laurent Vivier
2022-09-18 19:45 ` [PATCH v3 10/12] linux-user: Show timespec on strace for futex() Helge Deller
2022-09-25 15:38   ` Laurent Vivier
2022-09-18 19:45 ` [PATCH v3 11/12] linux-user: Add close_range() syscall Helge Deller
2022-09-25 15:42   ` Laurent Vivier [this message]
2022-09-18 19:45 ` [PATCH v3 12/12] linux-user: Add parameters of getrandom() syscall for strace Helge Deller
2022-09-18 20:49   ` Philippe Mathieu-Daudé via
2022-09-27  7:32 ` [PATCH v3 00/12] linux-user: Add more syscalls, enhance tracing & logging enhancements Laurent Vivier
2022-09-27  8:56   ` Helge Deller
2022-09-27  9:12     ` Laurent Vivier

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=730a6c07-883f-b1f6-600b-fd1645fc5f0d@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    /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).