From mboxrd@z Thu Jan 1 00:00:00 1970 From: greg@kroah.com (Greg KH) Date: Tue, 19 Aug 2014 11:10:51 -0500 Subject: fd type from number In-Reply-To: <53F36F70.3020001@draios.com> References: <53F36F70.3020001@draios.com> Message-ID: <20140819161051.GA31971@kroah.com> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org 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? > 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? thanks, greg k-h