linux-user/syscall.c: Add SO_RCVTIMEO and SO_SNDTIMEO for getsockopt
PATCH v2 1/1 linux-user/syscall.c: Add SO_RCVTIMEO and SO_SNDTIMEO for getsockopt
From: Chen Gang <[email protected]>
Implement them according to the other features implementations.
--- linux-user/syscall.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)
linux-user/syscall.c +25 -2
@@ -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;
Signature · 1 line
1.9.1
Quoted 31 lines · Le 11/01/2016 09:54, [email protected] a écrit :
From: Chen Gang <[email protected]>
Implement them according to the other features implementations.
Signed-off-by Chen Gang <[email protected]>--- linux-user/syscall.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)linux-user/syscall.c +3
-2@@ -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 ;
linux-user/syscall.c static abi_long do_getsockopt(int sockfd, int level, int optname, · line 1711
Quoted 10 lines
linux-user/syscall.c +10
-0+ 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 ; + }
Check len >= 0.
linux-user/syscall.c static abi_long do_getsockopt(int sockfd, int level, int optname, · line 1720
Quoted 9 lines
linux-user/syscall.c +9
-0+ 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)) {
Put in optlen the result of getsockopt(), i.e. "lv", or check lv == sizeof(struct target_timeval).
Quoted 7 lines
linux-user/syscall.c +3
-0+return -TARGET_EFAULT ; + } +break ;case TARGET_SO_PEERCRED : {struct ucred cr;socklen_t crlen;
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): CAFEAcA-QQDbXd+YEdxqRyOzZO2fYxyR+AK8zfqb6UgWy7Fq94g@mail.gmail.com
Quoted 5 lines · Peter Maydell
On 11 January 2016 at 10:31, Chen Gang <[email protected]> wrote:
[various things about a patch]Why have we dropped qemu-devel from this email thread?
Oh, sorry, I did not notice about it.
Thanks.
Signature · 3 lines
Chen Gang (陈刚) Open, share, and attitude like air, water, and life which God blessed