how to use the function copyout()
NKoch at demig.de
Mon Jul 25 15:01:39 GMT 2005
> > So if I get it right, it's impossible in FreeBSD to gain access to
> > 64KB of user's program memory with ioctl?
> > My situation is this - I have a device driver for Linux. My task is
> > port it as it is (1:1) into FreeBSD.
> > In the Linux driver Ioctl is realized with the macroses _put_user
> > _get_user all over it. As I understand in FreeBSD their analogues are
> > functions described in store(9), copy(9) and fetch(9).
> > So the problem is that in my user program an array short unsigned int
> > Data is defined. I need to gain access to the array(to each
> > element of it) from device driver with Ioctl handler.
> > Is it possible to do? If yes, then how it can be done?
> A better alternative that doesn't involve copying huge amounts of data
> from userlevel to kernel space and vice versa is probably to pass just
> the address of the area with an ioctl() and then map the appropriate
> pages from the address space of the user process to an area where the
> kernel can access the data directly?
I think that could work (only an idea, not tested):
void * p;
#define IOBIG _IOWR ('b', 123, struct Region)
struct Region r;
r.p = data;
r.s = sizeof data;
int error = ioctl (fd, IOBIG, &r);
int my_ioctl(..., caddr_t data, ...)
return copyout(data, ((struct Region *) data)->p, ((struct Region *)
Have a try and tell us if it works.
More information about the freebsd-hackers