qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] linux-user/syscall.c: Add SO_RCVTIMEO and SO_SNDTIMEO for getsockopt
@ 2016-01-11  8:54 chengang
  2016-01-11  9:07 ` Laurent Vivier
  0 siblings, 1 reply; 3+ messages in thread
From: chengang @ 2016-01-11  8:54 UTC (permalink / raw)
  To: riku.voipio, laurent; +Cc: peter.maydell, Chen Gang, Chen Gang, qemu-devel, rth

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

Implement them according to the other features implementations.

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

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 44485f2..4c68800 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1687,6 +1687,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:
@@ -1694,10 +1695,32 @@ 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 (get_user_u32(len, optlen)) {
+                return -TARGET_EFAULT;
+            }
+            if (len < 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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-01-11 14:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-11  8:54 [Qemu-devel] [PATCH v2] linux-user/syscall.c: Add SO_RCVTIMEO and SO_SNDTIMEO for getsockopt chengang
2016-01-11  9:07 ` Laurent Vivier
     [not found]   ` <569375FE.9000008@emindsoft.com.cn>
     [not found]     ` <56937BD0.2020900@vivier.eu>
     [not found]       ` <56938470.40109@emindsoft.com.cn>
     [not found]         ` <CAFEAcA-QQDbXd+YEdxqRyOzZO2fYxyR+AK8zfqb6UgWy7Fq94g@mail.gmail.com>
2016-01-11 14:39           ` Chen Gang

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).