Subject: Re: IOCTL implementation and kernel/userland addresses
To: None <tech-kern@netbsd.org>
From: Frank van der Linden <fvdl@netbsd.org>
List: tech-kern
Date: 02/04/2005 21:44:17
On Fri, Feb 04, 2005 at 06:36:08PM +0100, Reinoud Zandijk wrote:
> I.e. the CDIOREADTOCENTRYS ioctl can only be called from userland. Isn't an
> ioctl implementation to allow both userland and kernel-space calls?
> Shouldn't the implementation of CDIOREADTOCENTRYS examine the `struc proc *'
> argument to the ioctl handler? And when equal to NULL use a `memcpy'
> instead? Or use the `copyout_proc' or variant that has the proc* as
> argument too wich can then decide to use copyout or memcpy?
I see where your confusion comes from.. ioctl is wrapped in a piece of
code which copies in/out data depending on _IOR/_IOW/_IOWR. So, the
ioctl backend implementations (devices) don't deal with the copyin/copyout.
However, ioctl is and always has been a userspace interface.
If you want something usable from kernel space, implement a seperate
function which can be called by both the ioctl code and your code.
Btw, copyout_proc is only to be used when data is to be copied to
an address space that is not the current process.
- Frank