How to figure out the file descriptor inside a driver?
Carl-Johan Hansson
cjhansson at hotmail.com
Mon Dec 15 16:33:13 UTC 2003
>Carl-Johan Hansson wrote:
>
>>>>I'm writing a couple of new drivers and in one of them I want to map the
>>>>file descriptor that I receive when I open the driver with another
>>>>parameter when I call ioctl(). Is there some way to figure out the file
>>>>descriptor when I'm inside the driver routine?
>>>>
>>>>Hope you understand the question!
>>>
>>>
>>>Do you mean file description in the integer sense (e.g. read()) or
>>>in the FILE * sense (e.g. fread())?
>>
>>
>>I mean in the integer number you receive when calling open() and not
>>fopen(). I want to find that number in the arguments when calling (e.g
>>read()) if possible.
>
>OK. Each device driver entry point is called with an argument which
>ends up pointing to an rtems_libio* which includes an iop pointer.
>
>This "iop" pointer can be converted to an integer pointer using this
>code from cpukit/libcsupport/src/open.c
>
> return iop - rtems_libio_iops;
>
>Honestly, there should be a macro in
>cpukit/libcsupport/include/rtems/libio_.h
>which is the opposite of rtems_libio_iop() around line 48. Something
>like this:
>
>#define rtems_libio_iop_to_descriptor(_iop) \
> ((!(_iop)) ? -1 : (iop - rtems_libio_iops))
>
>If this works for you, file a PR in GNATS and it can be added.
>
>--
>Joel Sherrill, Ph.D. Director of Research & Development
>joel at OARcorp.com On-Line Applications Research
>Ask me about RTEMS: a free RTOS Huntsville AL 35805
>Support Available (256) 722-9985
>
Thanks!
Works perfect!
_________________________________________________________________
Bli förälskad på MSN Dejting http://www.msn.se/dejting/default.asp
More information about the users
mailing list