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>,
	qemu-devel@nongnu.org, rth@twiddle.net
Subject: [Qemu-devel] [PATCH] linux-user/syscall.c: Add SO_RCVTIMEO and SO_SNDTIMEO for getsockopt
Date: Fri,  8 Jan 2016 09:59:09 +0800	[thread overview]
Message-ID: <1452218349-3793-1-git-send-email-chengang@emindsoft.com.cn> (raw)

From: Chen Gang <gang.chen.5i5j@gmail.com>

Just implement them according to the other features implementations.

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
 linux-user/syscall.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 12a6cd2..f27148a 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1685,6 +1685,7 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
     abi_long ret;
     int len, val;
     socklen_t lv;
+    struct timeval tv;
 
     switch(level) {
     case TARGET_SOL_SOCKET:
@@ -1692,10 +1693,30 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
         switch (optname) {
         /* These don't just return a single integer */
         case TARGET_SO_LINGER:
-        case TARGET_SO_RCVTIMEO:
-        case TARGET_SO_SNDTIMEO:
         case TARGET_SO_PEERNAME:
             goto unimplemented;
+
+        case TARGET_SO_RCVTIMEO:
+            optname = SO_RCVTIMEO;
+            goto time_case;
+        case TARGET_SO_SNDTIMEO:
+            optname = SO_SNDTIMEO;
+        time_case:
+            if (optlen < sizeof(struct target_timeval)) {
+                return -TARGET_EINVAL;
+            }
+            lv = sizeof(tv);
+            ret = get_errno(getsockopt(sockfd, level, optname, &tv, &lv));
+            if (ret < 0) {
+                return ret;
+            }
+            if (copy_to_user_timeval(optval_addr, &tv)) {
+                return -TARGET_EFAULT;
+            }
+            if (put_user_u32(sizeof(struct target_timeval), optlen)) {
+                return -TARGET_EFAULT;
+            }
+            break;
         case TARGET_SO_PEERCRED: {
             struct ucred cr;
             socklen_t crlen;
-- 
1.9.1

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

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-08  1:59 chengang [this message]
2016-01-08  8:25 ` [Qemu-devel] [PATCH] linux-user/syscall.c: Add SO_RCVTIMEO and SO_SNDTIMEO for getsockopt Laurent Vivier
2016-01-08  9:40   ` Chen Gang
2016-01-11  6:31     ` 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=1452218349-3793-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).