[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: getting fd from pointer to sock
On Wed, Aug 14, 2002 at 04:41:50PM +0530, Amit Shah wrote:
> hello,
> i wanted to know if there is any function which can from the pointer to
> the sock structure or the pointer to the socket structure give me the
> corressponding socket descriptor value.
> Or even if it can give me the descriptor value from the pointer to the file
> structure...that would be helpful too.
> thanks,
Hi.
This is how the different data structures are related to each other:
struct task_struct --> struct files_struct * --> struct file ** -->
(current) (files) (fd)
--> struct dentry --> struct inode --> struct socket --> struct sock
(f_dentry) (d_inode) (u.socket_i) (sk)
Mmmh, not too clear? It means: you can get a pointer to a struct
files_struct through the 'files' field in the struct task_struct. From
that and its field 'fd', you can a pointer to a struct file, and so on.
HTH,
Marco
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/