Obtaining a list of open sockets from "struct task_struct"

Vimal j.vimal at gmail.com
Fri Nov 11 11:03:47 EST 2011


Hi all,

I am trying to understand more about kernel data structures and I
would like to know how to obtain a list of TCP/UDP sockets, starting
from a "struct task_struct" variable "task".

So far, I have understood the following:  Please correct me if I am wrong! :)

- An open file descriptor is represented by a "struct file *" in the
tasks's file table: task->files.fdt.fd
- The file tables are organised as a linked list
- The file table contains a structure fd_array, that is an array of
"struct file *", each representing an open file

But, almost all operations in the TCP code start from a "struct sock".
  Are the "struct file" and "struct sock" somehow connected?

Thanks,
-- 
Vimal



More information about the Kernelnewbies mailing list