diff options
author | Helge Deller | 2022-10-25 04:34:14 +0200 |
---|---|---|
committer | Laurent Vivier | 2022-11-02 17:17:07 +0100 |
commit | af804f39cc7d3e0bed1c20c414cb43c1662c4465 (patch) | |
tree | 0b531b39ee01bc216ef2b60239784f3bb01fd55d /linux-user | |
parent | linux-user/hppa: Detect glibc ABORT_INSTRUCTION and EXCP_BREAK handler (diff) | |
download | qemu-af804f39cc7d3e0bed1c20c414cb43c1662c4465.tar.gz qemu-af804f39cc7d3e0bed1c20c414cb43c1662c4465.tar.xz qemu-af804f39cc7d3e0bed1c20c414cb43c1662c4465.zip |
linux-user: Add close_range() syscall
Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <Y1dLJoEDhJ2AAYDn@p100>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Diffstat (limited to 'linux-user')
-rw-r--r-- | linux-user/strace.list | 3 | ||||
-rw-r--r-- | linux-user/syscall.c | 19 |
2 files changed, 22 insertions, 0 deletions
diff --git a/linux-user/strace.list b/linux-user/strace.list index 3df2184580..cd995e5d56 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(%u,%u,%u)", 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 8402c1399d..8b18adfba8 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -364,6 +364,13 @@ _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) +#ifndef CLOSE_RANGE_CLOEXEC +#define CLOSE_RANGE_CLOEXEC (1U << 2) +#endif +#endif #if defined(__NR_futex) _syscall6(int,sys_futex,int *,uaddr,int,op,int,val, const struct timespec *,timeout,int *,uaddr2,int,val3) @@ -8756,6 +8763,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: + ret = get_errno(sys_close_range(arg1, arg2, arg3)); + if (ret == 0 && !(arg3 & CLOSE_RANGE_CLOEXEC)) { + abi_long fd, maxfd; + maxfd = MIN(arg2, target_fd_max); + for (fd = arg1; fd < maxfd; fd++) { + fd_trans_unregister(fd); + } + } + return ret; +#endif case TARGET_NR_brk: return do_brk(arg1); |