qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: chengang@emindsoft.com.cn
To: riku.voipio@iki.fi, laurent@vivier.eu
Cc: peter.maydell@linaro.org, Chen Gang <gang.chen.5i5j@gmail.com>,
	Chen Gang <chengang@emindsoft.com.cn>,
	qemu-devel@nongnu.org, rth@twiddle.net
Subject: [Qemu-devel] [PATCH] linux-user: syscall: Add SO_LINGER for setsockopt
Date: Fri,  8 Jan 2016 10:03:06 +0800	[thread overview]
Message-ID: <1452218586-4009-1-git-send-email-chengang@emindsoft.com.cn> (raw)

From: Chen Gang <chengang@emindsoft.com.cn>

Just implement it according to the other features implementations.

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
 linux-user/syscall.c      | 16 +++++++++++++++-
 linux-user/syscall_defs.h |  5 +++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index f27148a..9f2c871 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1409,6 +1409,9 @@ 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:
@@ -1659,7 +1662,19 @@ set_timeout:
         case TARGET_SO_RCVLOWAT:
 		optname = SO_RCVLOWAT;
 		break;
-            break;
+        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);
+            unlock_user_struct(tlg, optval_addr, 0);
+            return get_errno(setsockopt(sockfd, SOL_SOCKET, optname,
+                             &lg, sizeof(lg)));
         default:
             goto unimplemented;
         }
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 9d3c537..5a4d565 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -165,6 +165,11 @@ struct target_ip_mreq_source {
     uint32_t imr_sourceaddr;
 };
 
+struct target_linger {
+    int l_onoff;        /* Linger active                */
+    int l_linger;       /* How long to linger for       */
+};
+
 struct target_timeval {
     abi_long tv_sec;
     abi_long tv_usec;
-- 
1.9.1

             reply	other threads:[~2016-01-08  2:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-08  2:03 chengang [this message]
2016-01-08  8:38 ` [Qemu-devel] [PATCH] linux-user: syscall: Add SO_LINGER for setsockopt Laurent Vivier
2016-01-08  9:45   ` Chen Gang
2016-01-08  9:57     ` Laurent Vivier
2016-01-08 10:13       ` Chen Gang

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=1452218586-4009-1-git-send-email-chengang@emindsoft.com.cn \
    --to=chengang@emindsoft.com.cn \
    --cc=gang.chen.5i5j@gmail.com \
    --cc=laurent@vivier.eu \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    --cc=rth@twiddle.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;
as well as URLs for NNTP newsgroup(s).