Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit af804f3

Browse files
hdellervivier
authored andcommitted
linux-user: Add close_range() syscall
Signed-off-by: Helge Deller <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Message-Id: <Y1dLJoEDhJ2AAYDn@p100> Signed-off-by: Laurent Vivier <[email protected]>
1 parent dcd8614 commit af804f3

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

linux-user/strace.list

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@
103103
#ifdef TARGET_NR_close
104104
{ TARGET_NR_close, "close" , "%s(%d)", NULL, NULL },
105105
#endif
106+
#ifdef TARGET_NR_close_range
107+
{ TARGET_NR_close_range, "close_range" , "%s(%u,%u,%u)", NULL, NULL },
108+
#endif
106109
#ifdef TARGET_NR_connect
107110
{ TARGET_NR_connect, "connect" , "%s(%d,%#x,%d)", NULL, NULL },
108111
#endif

linux-user/syscall.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,13 @@ _syscall3(int,sys_syslog,int,type,char*,bufp,int,len)
364364
#ifdef __NR_exit_group
365365
_syscall1(int,exit_group,int,error_code)
366366
#endif
367+
#if defined(__NR_close_range) && defined(TARGET_NR_close_range)
368+
#define __NR_sys_close_range __NR_close_range
369+
_syscall3(int,sys_close_range,int,first,int,last,int,flags)
370+
#ifndef CLOSE_RANGE_CLOEXEC
371+
#define CLOSE_RANGE_CLOEXEC (1U << 2)
372+
#endif
373+
#endif
367374
#if defined(__NR_futex)
368375
_syscall6(int,sys_futex,int *,uaddr,int,op,int,val,
369376
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,
87568763
case TARGET_NR_close:
87578764
fd_trans_unregister(arg1);
87588765
return get_errno(close(arg1));
8766+
#if defined(__NR_close_range) && defined(TARGET_NR_close_range)
8767+
case TARGET_NR_close_range:
8768+
ret = get_errno(sys_close_range(arg1, arg2, arg3));
8769+
if (ret == 0 && !(arg3 & CLOSE_RANGE_CLOEXEC)) {
8770+
abi_long fd, maxfd;
8771+
maxfd = MIN(arg2, target_fd_max);
8772+
for (fd = arg1; fd < maxfd; fd++) {
8773+
fd_trans_unregister(fd);
8774+
}
8775+
}
8776+
return ret;
8777+
#endif
87598778

87608779
case TARGET_NR_brk:
87618780
return do_brk(arg1);

0 commit comments

Comments
 (0)