Re: how to use the function copyout()

2005-07-26 Thread Scott Long
Felix-KM wrote: I think that could work (only an idea, not tested): struct Region { void * p; size_t s; }; #define IOBIG _IOWR ('b', 123, struct Region) userland: char data[1000]; struct Region r; r.p = data; r.s = sizeof data; int error = ioctl (fd, IOBIG, &r); kernel: int my_i

RE: how to use the function copyout()

2005-07-26 Thread Felix-KM
> I think that could work (only an idea, not tested): > > > struct Region > { > void * p; > size_t s; > }; > > > #define IOBIG _IOWR ('b', 123, struct Region) > > > userland: > > char data[1000]; > struct Region r; > > r.p = data; > r.s = sizeof data; > int error = ioctl (fd,

Re: how to use the function copyout()

2005-07-25 Thread Scott Long
Scott Long wrote: Felix-KM wrote: I can't understand how to use the function copyout(). It is necessary to write the data from a device driver to the array defined in user program. I do it this way: #define IOCTL_GET_B_IOWR("F", 127, 0x4) What you've declared here i

Re: how to use the function copyout()

2005-07-25 Thread Scott Long
Felix-KM wrote: I can't understand how to use the function copyout(). It is necessary to write the data from a device driver to the array defined in user program. I do it this way: #define IOCTL_GET_B_IOWR("F", 127, 0x4) What you've declared here is an ioctl that wil

Re: how to use the function copyout()

2005-07-25 Thread Scott Long
Giorgos Keramidas wrote: On 2005-07-25 18:14, Felix-KM <[EMAIL PROTECTED]> wrote: I have no idea if it is possible for ioctls to have mapped more than a few 100 bytes for data exchange. You should use read and uiomove() instead. So if I get it right, it's impossible in FreeBSD to gain acces

Re: how to use the function copyout()

2005-07-25 Thread Scott Long
Kamal R. Prasad wrote: Im not sure of the bug in your code, but you have got to assume that copyout() would fail if the user/kernel addr passed to it is not accessible. regards -kamal The whole point of copyin and copyout is to deal with copying to and from user virtual memory that might not

Re: how to use the function copyout()

2005-07-25 Thread Julian Elischer
Felix-KM wrote: #define IOCTL_GET_B_IOWR("F", 127, 0x4) I think the third parameter to _IOWR should directly specify a type, e.g. _IOWR("F", 127, int) or _IOWR("F", 127, struct MyStruct). driver struct my_softc { ... short unsigned int B; }; ... static int my_io

RE: how to use the function copyout()

2005-07-25 Thread Matthew N. Dodd
On Mon, 25 Jul 2005, Felix-KM wrote: 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). Linux doesn't provide any help for driver IOCTL routines, FreeBSD

RE: how to use the function copyout()

2005-07-25 Thread Norbert Koch
> > > 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

Re: how to use the function copyout()

2005-07-25 Thread Giorgos Keramidas
On 2005-07-25 18:14, Felix-KM <[EMAIL PROTECTED]> wrote: > >I have no idea if it is possible for ioctls to have mapped more than > >a few 100 bytes for data exchange. You should use read and uiomove() > >instead. > > So if I get it right, it's impossible in FreeBSD to gain access to > 64KB of use

RE: how to use the function copyout()

2005-07-25 Thread Felix-KM
>> #define IOCTL_GET_B_IOWR("F", 127, 0x4) > >I think the third parameter to _IOWR should directly specify a type, >e.g. _IOWR("F", 127, int) or _IOWR("F", 127, struct MyStruct). > >> >> driver >> >> struct my_softc { >> ... >> short unsigned int B; >> }; >> >> ... >> >> static

RE: how to use the function copyout()

2005-07-25 Thread Norbert Koch
> #define IOCTL_GET_B_IOWR("F", 127, 0x4) I think the third parameter to _IOWR should directly specify a type, e.g. _IOWR("F", 127, int) or _IOWR("F", 127, struct MyStruct). > > driver > > struct my_softc { > ... > short unsigned int B; > }; > > ... > > static int > my_ioctl(s

Re: how to use the function copyout()

2005-07-25 Thread Kamal R. Prasad
Im not sure of the bug in your code, but you have got to assume that copyout() would fail if the user/kernel addr passed to it is not accessible. regards -kamal --- Felix-KM <[EMAIL PROTECTED]> wrote: > I can't understand how to use the function > copyout(). > It is necessa

Re: how to use the function copyout()

2005-07-25 Thread Stefan Sperling
On Mon, Jul 25, 2005 at 04:35:20PM +0400, Felix-KM wrote: > I can't understand how to use the function copyout(). > It is necessary to write the data from a device driver to the > array defined in user program. > I do it this way: > > #define IOCTL_GET_B_IOWR("F

how to use the function copyout()

2005-07-25 Thread Felix-KM
I can't understand how to use the function copyout(). It is necessary to write the data from a device driver to the array defined in user program. I do it this way: #define IOCTL_GET_B_IOWR("F", 127, 0x4) driver struct my_softc { ... short unsigned int B; };