Hi!

Sorry for the delay, I tried to build a patch for RTAI as well... I have written a
request to the RTAI Mailing List...

I'll wait for the RTAI guys to answer the request, and then send the patch to the Xenomai mailing list (or is it sufficient to just send you a short mail?). I believe it's important
that both projects use RTDM the same.

I think I will rebase the actual modification in RTnet (timestamping) once again to match the style of previous changes in RTnet. Is it a problem that I first add a new
source file (commit 1) and then recreate autotools configuration and change
GNUmakefile.am in a second commit (commit 2)? Commit 1 will not build...

Thanks for all your help!

Manuel

>From 2a202f0b1222c79396b7f9c91b1d2b318b16de19 Mon Sep 17 00:00:00 2001
From: Manuel Huber <[email protected]>
Date: Fri, 14 Jun 2013 11:37:20 +0200
Subject: [PATCH] rtdm: Fix msghdr struct (cmsg) in sys_rtdm_recvmsg

Whenever a new control message is put into msg_control buffer
the actual address and the space left is saved to msg_control
and msg_controllen. This allows adding messages as long as
there is enough space left in the user-supplied buffer. Both
fields have to be fixed again before passing them to the user
by copying the original starting address of the buffer to
msg_control and saving the actual amount of bytes written to
the buffer to msg_controllen.
---
 addons/rtdm/module.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/addons/rtdm/module.c b/addons/rtdm/module.c
index 771ccef..4eeb144 100644
--- a/addons/rtdm/module.c
+++ b/addons/rtdm/module.c
@@ -100,13 +100,18 @@ static RTAI_SYSCALL_MODE int sys_rtdm_recvmsg(long fd, struct msghdr *msg, long
 {
 	struct msghdr krnl_msg;
 	struct task_struct *curr = current;
+	void *cmsg_control;
 	int ret;
 
 	if (unlikely(!__xn_access_ok(curr, VERIFY_WRITE, msg, sizeof(krnl_msg)))) {
 		return -EFAULT;
 	}
 	__xn_copy_from_user(curr, &krnl_msg, msg, sizeof(krnl_msg));
+	cmsg_control = krnl_msg.msg_control;
 	if ((ret = __rt_dev_recvmsg(curr, fd, &krnl_msg, flags)) >= 0) {
+		krnl_msg.msg_controllen = (__kernel_size_t)(krnl_msg.msg_control -
+							    cmsg_control);
+		krnl_msg.msg_control = cmsg_control;
 		__xn_copy_to_user(curr, msg, &krnl_msg, sizeof(krnl_msg));
 	}
 	return ret;
-- 
1.7.0.4

>From 79872fff7bf6536007e1a09c353c4194b0def57c Mon Sep 17 00:00:00 2001
From: Manuel Huber <[email protected]>
Date: Fri, 14 Jun 2013 10:39:50 +0200
Subject: [PATCH] rtdm: Fix msghdr struct (cmsg) in sys_rtdm_recvmsg

Whenever a new control message is put into msg_control buffer
the actual address and the space left is saved to msg_control
and msg_controllen. This allows adding messages as long as
there is enough space left in the user-supplied buffer. Both
fields have to be fixed again before passing them to the user
by copying the original starting address of the buffer to
msg_control and saving the actual amount of bytes written to
the buffer to msg_controllen.
---
 ksrc/skins/rtdm/syscall.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/ksrc/skins/rtdm/syscall.c b/ksrc/skins/rtdm/syscall.c
index 0ff5d40..e5d9ae0 100644
--- a/ksrc/skins/rtdm/syscall.c
+++ b/ksrc/skins/rtdm/syscall.c
@@ -79,6 +79,7 @@ static int sys_rtdm_recvmsg(struct pt_regs *regs)
 {
 	struct task_struct *p = current;
 	struct msghdr krnl_msg;
+	void *cmsg_control;
 	int ret;
 
 	if (unlikely(!access_wok(__xn_reg_arg2(regs),
@@ -88,11 +89,17 @@ static int sys_rtdm_recvmsg(struct pt_regs *regs)
 					 sizeof(krnl_msg))))
 		return -EFAULT;
 
+	cmsg_control = krnl_msg.msg_control;
+
 	ret = __rt_dev_recvmsg(p, __xn_reg_arg1(regs), &krnl_msg,
 			       __xn_reg_arg3(regs));
 	if (unlikely(ret < 0))
 		return ret;
 
+	krnl_msg.msg_controllen = (__kernel_size_t)(krnl_msg.msg_control -
+						    cmsg_control);
+	krnl_msg.msg_control = cmsg_control;
+
 	if (unlikely(__xn_copy_to_user((void __user *)__xn_reg_arg2(regs),
 				       &krnl_msg, sizeof(krnl_msg))))
 		return -EFAULT;
-- 
1.7.0.4

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
RTnet-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rtnet-developers

Reply via email to