[prev in list] [next in list] [prev in thread] [next in thread]
List: freebsd-hackers
Subject: Re: how to use the function copyout()
From: Scott Long <scottl () samsco ! org>
Date: 2005-07-26 15:39:13
Message-ID: 42E65921.8060400 () samsco ! org
[Download RAW message or body]
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
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic