[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/13] linux-user: implement getsockopt SO_RCVTIMEO and SO_SNDTIME
From: |
Laurent Vivier |
Subject: |
[PULL 02/13] linux-user: implement getsockopt SO_RCVTIMEO and SO_SNDTIMEO |
Date: |
Thu, 20 Feb 2020 10:20:42 +0100 |
From: Andreas Schwab <address@hidden>
Signed-off-by: Andreas Schwab <address@hidden>
Reviewed-by: Laurent Vivier <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Laurent Vivier <address@hidden>
---
linux-user/syscall.c | 36 ++++++++++++++++++++++++++++++++++--
1 file changed, 34 insertions(+), 2 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 7aaa9d96397c..9fa722f2388d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2310,10 +2310,42 @@ static abi_long do_getsockopt(int sockfd, int level,
int optname,
level = SOL_SOCKET;
switch (optname) {
/* These don't just return a single integer */
- case TARGET_SO_RCVTIMEO:
- case TARGET_SO_SNDTIMEO:
case TARGET_SO_PEERNAME:
goto unimplemented;
+ case TARGET_SO_RCVTIMEO: {
+ struct timeval tv;
+ socklen_t tvlen;
+
+ optname = SO_RCVTIMEO;
+
+get_timeout:
+ if (get_user_u32(len, optlen)) {
+ return -TARGET_EFAULT;
+ }
+ if (len < 0) {
+ return -TARGET_EINVAL;
+ }
+
+ tvlen = sizeof(tv);
+ ret = get_errno(getsockopt(sockfd, level, optname,
+ &tv, &tvlen));
+ if (ret < 0) {
+ return ret;
+ }
+ if (len > sizeof(struct target_timeval)) {
+ len = sizeof(struct target_timeval);
+ }
+ if (copy_to_user_timeval(optval_addr, &tv)) {
+ return -TARGET_EFAULT;
+ }
+ if (put_user_u32(len, optlen)) {
+ return -TARGET_EFAULT;
+ }
+ break;
+ }
+ case TARGET_SO_SNDTIMEO:
+ optname = SO_SNDTIMEO;
+ goto get_timeout;
case TARGET_SO_PEERCRED: {
struct ucred cr;
socklen_t crlen;
--
2.24.1
- [PULL 00/13] Linux user for 5.0 patches, Laurent Vivier, 2020/02/20
- [PULL 03/13] configure: linux-user doesn't need neither fdt nor slirp, Laurent Vivier, 2020/02/20
- [PULL 09/13] linux-user: Add support for getting alsa timer version and id, Laurent Vivier, 2020/02/20
- [PULL 05/13] configure: Avoid compiling system tools on user build by default, Laurent Vivier, 2020/02/20
- [PULL 02/13] linux-user: implement getsockopt SO_RCVTIMEO and SO_SNDTIMEO,
Laurent Vivier <=
- [PULL 01/13] linux-user: Implement membarrier syscall, Laurent Vivier, 2020/02/20
- [PULL 12/13] linux-user: Add support for getting/setting selected alsa timer parameters using ioctls, Laurent Vivier, 2020/02/20
- [PULL 08/13] linux-user: remove gemu_log from the linux-user tree, Laurent Vivier, 2020/02/20
- [PULL 04/13] linux-user/strace: Improve output of various syscalls, Laurent Vivier, 2020/02/20
- [PULL 10/13] linux-user: Add support for getting/setting specified alsa timer parameters using ioctls, Laurent Vivier, 2020/02/20
- [PULL 06/13] linux-user: Use `qemu_log' for non-strace logging, Laurent Vivier, 2020/02/20
- [PULL 11/13] linux-user: Add support for selecting alsa timer using ioctl, Laurent Vivier, 2020/02/20
- [PULL 13/13] linux-user: Add support for selected alsa timer instructions using ioctls, Laurent Vivier, 2020/02/20
- [PULL 07/13] linux-user: Use `qemu_log' for strace, Laurent Vivier, 2020/02/20
- Re: [PULL 00/13] Linux user for 5.0 patches, Peter Maydell, 2020/02/21