Message ID | 1343087527-13582-1-git-send-email-jing.huang.pku@gmail.com |
---|---|
State | New |
Headers | show |
On 24 July 2012 00:52, Jing Huang <jing.huang.pku@gmail.com> wrote: > > Signed-off-by: Jing Huang <jing.huang.pku@gmail.com> > --- > linux-user/syscall.c | 20 ++++++++++++++++---- > 1 files changed, 16 insertions(+), 4 deletions(-) > > diff --git a/linux-user/syscall.c b/linux-user/syscall.c > index 9b498d0..ce70459 100644 > --- a/linux-user/syscall.c > +++ b/linux-user/syscall.c > @@ -1348,16 +1348,28 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh, > target_cmsg->cmsg_type = tswap32(cmsg->cmsg_type); > target_cmsg->cmsg_len = tswapal(TARGET_CMSG_LEN(len)); > > - if (cmsg->cmsg_level != TARGET_SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS) { > - gemu_log("Unsupported ancillary data: %d/%d\n", cmsg->cmsg_level, cmsg->cmsg_type); > - memcpy(target_data, data, len); > - } else { > + if ((cmsg->cmsg_level == TARGET_SOL_SOCKET) && > + (cmsg->cmsg_type == SCM_RIGHTS)) { > int *fd = (int *)data; > int *target_fd = (int *)target_data; > int i, numfds = len / sizeof(int); > > for (i = 0; i < numfds; i++) > target_fd[i] = tswap32(fd[i]); > + } else if ((cmsg->cmsg_level == TARGET_SOL_SOCKET) && > + (cmsg->cmsg_type == SO_TIMESTAMP) && > + (len == sizeof(struct timeval))) { > + /* copy struct timeval to target */ > + struct timeval *tv = (struct timeval *)data; > + struct target_timeval *target_tv = > + (struct target_timeval *)target_data; > + > + tv->tv_sec = tswapl(target_tv->tv_sec); > + tv->tv_usec = tswapl(target_tv->tv_usec); This is the wrong way round -- the source is in tv and you need to fill in target_tv. (This bug means that the Ubuntu x86-64 ping binary complains: "Warning: time of day goes back (-1336371523147153us), taking countermeasures." because the first time round it gets garbage rather than a valid timestamp.) Looks OK otherwise. -- PMM
diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9b498d0..ce70459 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1348,16 +1348,28 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh, target_cmsg->cmsg_type = tswap32(cmsg->cmsg_type); target_cmsg->cmsg_len = tswapal(TARGET_CMSG_LEN(len)); - if (cmsg->cmsg_level != TARGET_SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS) { - gemu_log("Unsupported ancillary data: %d/%d\n", cmsg->cmsg_level, cmsg->cmsg_type); - memcpy(target_data, data, len); - } else { + if ((cmsg->cmsg_level == TARGET_SOL_SOCKET) && + (cmsg->cmsg_type == SCM_RIGHTS)) { int *fd = (int *)data; int *target_fd = (int *)target_data; int i, numfds = len / sizeof(int); for (i = 0; i < numfds; i++) target_fd[i] = tswap32(fd[i]); + } else if ((cmsg->cmsg_level == TARGET_SOL_SOCKET) && + (cmsg->cmsg_type == SO_TIMESTAMP) && + (len == sizeof(struct timeval))) { + /* copy struct timeval to target */ + struct timeval *tv = (struct timeval *)data; + struct target_timeval *target_tv = + (struct target_timeval *)target_data; + + tv->tv_sec = tswapl(target_tv->tv_sec); + tv->tv_usec = tswapl(target_tv->tv_usec); + } else { + gemu_log("Unsupported ancillary data: %d/%d\n", + cmsg->cmsg_level, cmsg->cmsg_type); + memcpy(target_data, data, len); } cmsg = CMSG_NXTHDR(msgh, cmsg);
Signed-off-by: Jing Huang <jing.huang.pku@gmail.com> --- linux-user/syscall.c | 20 ++++++++++++++++---- 1 files changed, 16 insertions(+), 4 deletions(-)