Date: Tue, 26 Jul 2005 09:39:13 -0600 From: Scott Long <scottl@samsco.org> To: Felix-KM@yandex.ru Cc: NKoch@demig.de, freebsd-hackers@freebsd.org Subject: Re: how to use the function copyout() Message-ID: <42E65921.8060400@samsco.org> In-Reply-To: <42E5EA4F.00000A.07557@colgate.yandex.ru> References: <000001c59129$6099b560$4801a8c0@ws-ew-3.W2KDEMIG> <42E5EA4F.00000A.07557@colgate.yandex.ru>
next in thread | previous in thread | raw e-mail | index | archive | help
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_ioctl(..., caddr_t data, ...)
>> {
>> ...
>> char data[1000];
>> ...
>> return copyout(data, ((struct Region *) data)->p, ((struct Region *)
>>data)->s);
>> }
>>
>>
>>Have a try and tell us if it works.
>>
>>
>>Norbert
>>
>
>
> Yes! Now the program works!
> I have changed the code in this way:
>
> struct Region
> {
> void * p;
> size_t s;
> };
>
> #define IOBIG _IOWR ('b', 123, struct Region)
>
Unless your ioctl handler is going to modify values in the Region struct
and pass them back out to userland, you should just use _IOR instead of
_IORW.
Scott
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?42E65921.8060400>
