Original implementation from Chen Gang; code moved around as per v2
Signed-off-by: Chen Gang <[email protected]>
Signed-off-by: Carlo Marcelo Arenas Belón <[email protected]>
---
linux-user/syscall.c | 16 ++++++++++++++++
linux-user/syscall_defs.h | 5 +++++
2 files changed, 21 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 9b6364a266..d3c500ca78 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2829,6 +2829,8 @@ static abi_long do_setsockopt(int sockfd, int level, int
optname,
int val;
struct ip_mreqn *ip_mreq;
struct ip_mreq_source *ip_mreq_source;
+ struct linger lg;
+ struct target_linger *tlg;
switch(level) {
case SOL_TCP:
@@ -3071,6 +3073,20 @@ set_timeout:
unlock_user (dev_ifname, optval_addr, 0);
return ret;
}
+ case TARGET_SO_LINGER:
+ optname = SO_LINGER;
+ if (optlen != sizeof(struct target_linger)) {
+ return -TARGET_EINVAL;
+ }
+ if (!lock_user_struct(VERIFY_READ, tlg, optval_addr, 1)) {
+ return -TARGET_EFAULT;
+ }
+ __get_user(lg.l_onoff, &tlg->l_onoff);
+ __get_user(lg.l_linger, &tlg->l_linger);
+ ret = get_errno(setsockopt(sockfd, SOL_SOCKET, optname,
+ &lg, sizeof(lg)));
+ unlock_user_struct(tlg, optval_addr, 0);
+ return ret;
/* Options with 'int' argument. */
case TARGET_SO_DEBUG:
optname = SO_DEBUG;
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 40c5027e93..a60d6bb163 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -202,6 +202,11 @@ struct target_ip_mreq_source {
uint32_t imr_sourceaddr;
};
+struct target_linger {
+ abi_int l_onoff; /* Linger active */
+ abi_int l_linger; /* How long to linger for */
+};
+
struct target_timeval {
abi_long tv_sec;
abi_long tv_usec;
--
2.11.0 (Apple Git-81)