[PATCHv2 1/4] Introduce a separate function to copy from msghdr32 to msghdr
Masatake YAMATO
yamato at redhat.com
Fri Nov 7 02:38:19 UTC 2014
This patch is an initial step for supporting "-e write=all" and
"-e read=all" option for sendmmsg and recvmmsg system calls.
Coverting a data of msghdr32 to msghdr is needed both
{send,recv}msg and {send,recv}mmsg to decode parameters.
To share the copying code in both decoders, a separate
function named `copy_from_msghdr32' is introduced.
* net.c (copy_from_msghdr32): New function.
(extractmsghdr): calls copy_from_msghdr32.
In v2 patch: Nothing is changed.
Signed-off-by: Masatake YAMATO <yamato at redhat.com>
---
net.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/net.c b/net.c
index a0e90a8..193705d 100644
--- a/net.c
+++ b/net.c
@@ -392,6 +392,20 @@ struct mmsghdr32 {
uint32_t /* unsigned */ msg_len;
};
+#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
+static void
+copy_from_msghdr32(struct msghdr *to_msg, struct msghdr32 *from_msg32)
+{
+ to_msg->msg_name = (void*)(long)from_msg32->msg_name;
+ to_msg->msg_namelen = from_msg32->msg_namelen;
+ to_msg->msg_iov = (void*)(long)from_msg32->msg_iov;
+ to_msg->msg_iovlen = from_msg32->msg_iovlen;
+ to_msg->msg_control = (void*)(long)from_msg32->msg_control;
+ to_msg->msg_controllen = from_msg32->msg_controllen;
+ to_msg->msg_flags = from_msg32->msg_flags;
+}
+#endif
+
static bool
extractmsghdr(struct tcb *tcp, long addr, struct msghdr *msg)
{
@@ -401,13 +415,7 @@ extractmsghdr(struct tcb *tcp, long addr, struct msghdr *msg)
if (umove(tcp, addr, &msg32) < 0)
return false;
- msg->msg_name = (void*)(long)msg32.msg_name;
- msg->msg_namelen = msg32.msg_namelen;
- msg->msg_iov = (void*)(long)msg32.msg_iov;
- msg->msg_iovlen = msg32.msg_iovlen;
- msg->msg_control = (void*)(long)msg32.msg_control;
- msg->msg_controllen = msg32.msg_controllen;
- msg->msg_flags = msg32.msg_flags;
+ copy_from_msghdr32(msg, &msg32);
} else
#endif
if (umove(tcp, addr, msg) < 0)
--
1.9.3
More information about the Strace-devel
mailing list