Subject: copyout() - can it be used in ioctl method?
To: None <email@example.com>
From: Gary Thorpe <firstname.lastname@example.org>
Date: 06/26/2003 23:27:42
I wrote an ioctl command for a device which takes a pointer to an
struct as as the argument (the ioctl command is to get the device's
status and put it into the struct).
My original approach was to directly manipulate the struct by
dereferencing the argument (with appropriate casting) without need for
copies, but this did not work (the struct would not get updated). Then
I tried to use copyout(9) to copy from a struct in the device ioctl
method (kernel address) to the dereferenced argument (user address).
This always returned EFAULT. When I tried memcpy(9), it successfully
copied the data and stores the device's status in the dereferenced
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. Why does
memcpy(9) work instead (should it fail and not copyout)? Am I misusing
copyout(9) for something it was not originally intended?
Post your free ad now! http://personals.yahoo.ca