fd type from number

Loris Degioanni loris at draios.com
Tue Aug 19 12:36:25 EDT 2014


On 8/19/2014 9:10 AM, Greg KH wrote:
> On Tue, Aug 19, 2014 at 08:38:24AM -0700, Loris Degioanni wrote:
>> (resending making sure this is not part of another thread)
>>
>> I'm looking for an efficient way to determine the type of an fd (file,
>> socket...) given its number, from a kernel module.
> You don't have a "number" from within the kernel, you have a pointer to
> the full file descriptor structure, right?  If so, what is missing from
> that structure that you can not find?

I do have the FD number, because it's coming from intercepting a system 
call.

>
>> The closest thing I found by looking at the kernel sources is
>> sockfd_lookup(), which works but is limited to telling me if the fd is a
>> socket or not.
>>
>> Is there something else I can look at?
> What exactly are you trying to do with this?  And what does it matter
> what "type" of thing a file descriptor is?  What can you do with that
> information?

I just sent another email with some explanation.

Loris

>
> thanks,
>
> greg k-h




More information about the Kernelnewbies mailing list