Subject: Re: copyout() - can it be used in ioctl method?
To: None <email@example.com>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
Date: 06/26/2003 23:33:45
> My question: when is copyout(9) supposed to be used? I would have
> thought that the code in the device's ioctl methods would have its
> variables in kernel land and that since the argument is an address
> from a user program that copyout(9) would be a natural fit.
What you're missing here is that the kernel deals with copying the
struct in and out for you (assuming of course you used _IOR/_IOW/etc
correctly when defining it). Thus, by the time it hits your driver's
ioctl routine, you're already dealing with kernel space.
But this copying goes only one level deep. If your struct contains
pointers to other userland memory, those you will need to use
/~\ The ASCII der Mouse
\ / Ribbon Campaign
X Against HTML firstname.lastname@example.org
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B