COPYIN/COPYOUT macro problems Re: IOCTL implementation and kernel/userland addresses

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Reinoud Zandijk
Date: Thursday, August 25, 2005 - 9:35 am

Dear folks,

picking up an old thread on the added FKIOCTL flag :

On Thu, Feb 17, 2005 at 12:26:36AM +0100, Reinoud Zandijk wrote:



I've defined COPYIN and COPYOUT macros wich allways DTRT for ioctls in the 
following proposed patch :

------------------
diff -u -r1.179 systm.h
--- sys/systm.h 23 Jun 2005 00:30:28 -0000      1.179
+++ sys/systm.h 25 Aug 2005 16:22:28 -0000
@@ -240,6 +240,21 @@
 int    copyin(const void *, void *, size_t);
 int    copyout(const void *, void *, size_t);
 
+#ifdef _KERNEL
+#define COPYIN(ioctlflags, uaddr, kaddr, len)\
+               if ((ioctlflags) & FKIOCTL) {\
+                       memcpy((kaddr), (uaddr), (len));\
+               } else {\
+                       copyin((uaddr), (kaddr), (len));\
+               };
+#define COPYOUT(ioctlflags, kaddr, uaddr, len)\
+               if ((ioctlflags) & FKIOCTL) {\
+                       memcpy((uaddr), (kaddr), (len));\
+               } else {\
+                       copyout((kaddr), (uaddr), (len));\
+               };
+#endif /* KERNEL */
+
 int    copyin_proc(struct proc *, const void *, void *, size_t);
 int    copyout_proc(struct proc *, const void *, void *, size_t);
----------------------

*BUT* a grep in src/sys pointed to the following problems:

arch/pc532/fpu/ieee_handler.c
dist/pf/net/pf_table.c
dist/ipf/netinet/ip_compat.h

all define their own COPYIN() and COPYOUT() macro's.... now what to do?
   a) don't use COPYIN/COPYOUT but use IOCTL_COPYIN and IOCTL_COPYOUT ?
   b) patch somehow pc532/pf/ipf to not use such generic names?
   c) ...

(a) would do justice to the fact that they are only usable for IOCTL flags 
(b) might cause problems with importing newer pf/ipf or are those imports 
mainly scripted?
(c) other suggestions?

Reinoud
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: IOCTL implementation and kernel/userland addresses, Manuel Bouyer, (Mon Feb 7, 11:40 am)
Re: IOCTL implementation and kernel/userland addresses, Bill Studenmund, (Mon Feb 7, 11:59 am)
Re: IOCTL implementation and kernel/userland addresses, Reinoud Zandijk, (Sat Feb 12, 6:25 am)
Re: IOCTL implementation and kernel/userland addresses, Reinoud Zandijk, (Sat Feb 12, 8:10 am)
Re: IOCTL implementation and kernel/userland addresses, Bill Studenmund, (Sun Feb 13, 8:35 pm)
Re: IOCTL implementation and kernel/userland addresses, YAMAMOTO Takashi, (Sun Feb 13, 8:51 pm)
Re: IOCTL implementation and kernel/userland addresses, Chuck Silvers, (Sun Feb 13, 8:52 pm)
Re: IOCTL implementation and kernel/userland addresses, Bill Studenmund, (Mon Feb 14, 11:43 am)
Re: IOCTL implementation and kernel/userland addresses, Bill Studenmund, (Mon Feb 14, 11:45 am)
Re: IOCTL implementation and kernel/userland addresses, Manuel Bouyer, (Mon Feb 14, 11:50 am)
Re: IOCTL implementation and kernel/userland addresses, Bill Studenmund, (Mon Feb 14, 12:56 pm)
Re: IOCTL implementation and kernel/userland addresses, Manuel Bouyer, (Mon Feb 14, 1:00 pm)
Re: IOCTL implementation and kernel/userland addresses, Bill Studenmund, (Wed Feb 16, 11:55 am)
Re: IOCTL implementation and kernel/userland addresses, Reinoud Zandijk, (Wed Feb 16, 3:25 pm)
Re: IOCTL implementation and kernel/userland addresses, Frank van der Linden, (Wed Feb 16, 3:37 pm)
Re: IOCTL implementation and kernel/userland addresses, Bill Studenmund, (Wed Feb 16, 4:02 pm)
Re: IOCTL implementation and kernel/userland addresses, Reinoud Zandijk, (Wed Feb 16, 4:26 pm)
Re: IOCTL implementation and kernel/userland addresses, Chuck Silvers, (Wed Feb 16, 7:14 pm)
COPYIN/COPYOUT macro problems Re: IOCTL implementation and ..., Reinoud Zandijk, (Thu Aug 25, 9:35 am)
Re: COPYIN/COPYOUT macro problems Re: IOCTL implementation ..., YAMAMOTO Takashi, (Thu Aug 25, 11:01 am)
Re: COPYIN/COPYOUT macro problems Re: IOCTL implementation ..., Julio M. Merino Vidal, (Thu Aug 25, 2:47 pm)
ioctl_copy{in,out} proposal, Reinoud Zandijk, (Sun Aug 28, 6:48 am)
Re: ioctl_copy{in,out} proposal, Julio M. Merino Vidal, (Sun Aug 28, 6:54 am)
Re: ioctl_copy{in,out} proposal, Reinoud Zandijk, (Sun Aug 28, 7:03 am)
Re: ioctl_copy{in,out} proposal, Reinoud Zandijk, (Sun Aug 28, 7:18 am)