* open sockets from task_struct
@ 2010-04-18 7:06 ratheesh k
2010-04-18 7:30 ` Jonathan Campbell
[not found] ` <4BCAB35A.6070806@nerdgrounds.com>
0 siblings, 2 replies; 3+ messages in thread
From: ratheesh k @ 2010-04-18 7:06 UTC (permalink / raw)
To: linux-kernel
I have task_struct structure , how to find all the opened files ? how
to find opened sockets ?
Thanks,
Ratheesh
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: open sockets from task_struct
2010-04-18 7:06 open sockets from task_struct ratheesh k
@ 2010-04-18 7:30 ` Jonathan Campbell
[not found] ` <4BCAB35A.6070806@nerdgrounds.com>
1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Campbell @ 2010-04-18 7:30 UTC (permalink / raw)
To: ratheesh k; +Cc: linux-kernel
(reposted because I remember kernel.org mentioning that HTML email is
verboten or something like that---Sorry!)
I know that on the user-space side any open handles can be seen in the
/proc/<pid>/fd directory (<pid> is whatever process you're interested in).
Assuming you're talking about reading this from kernel space, I'd look
at what the procfs filesystem is doing and learn from that.
Sockets and block/char devices are listed like any other file, the list
is based on file handles.
> I have task_struct structure , how to find all the opened files ? how
> to find opened sockets ?
>
> Thanks,
> Ratheesh
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: open sockets from task_struct
[not found] ` <s2jcfeab66d1004180056m927c83f6l5642dcf56ad05a5e@mail.gmail.com>
@ 2010-04-18 8:12 ` Jonathan Campbell
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Campbell @ 2010-04-18 8:12 UTC (permalink / raw)
To: ratheesh k; +Cc: linux-kernel
Get the Linux kernel source and look at what the procfs filesystem is
doing to get that information. Look under fs/proc.
fs/proc/base.c(2508) seems to contain the inode structures for
/proc/pid/fd and /proc/pid/fdinfo, locate the inode operations
structure and locate the functions. Drill down through the function
calls and you'll eventually find how to read what
file handles are open. A quick glance tells me that the calls go several
layers deep including a call through a function pointer passed in one of
the parameters, "instantiate", hopefully that won't be a problem for you.
> On Sun, Apr 18, 2010 at 12:53 PM, Jonathan Campbell<jon@nerdgrounds.com> wrote:
>
>> I know that on the user-space side any open handles can be seen in the
>> /proc/<pid>/fd directory (<pid> is whatever process you're interested in).
>> Assuming you're talking about reading this from kernel space, I'd look at
>> what the procfs filesystem is doing and learn from that.
>> Sockets and block/char devices are listed like any other file, the list is
>> based on file handles.
>>
>>> I have task_struct structure , how to find all the opened files ? how
>>> to find opened sockets ?
>>>
>>> Thanks,
>>> Ratheesh
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>> Please read the FAQ at http://www.tux.org/lkml/
>>>
>>>
>>>
>>>
>>
>>
> I need it in kernel space and i am using 2.6.29.4 kernel .. could you
> please guide a little ?
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-04-18 8:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-18 7:06 open sockets from task_struct ratheesh k
2010-04-18 7:30 ` Jonathan Campbell
[not found] ` <4BCAB35A.6070806@nerdgrounds.com>
[not found] ` <s2jcfeab66d1004180056m927c83f6l5642dcf56ad05a5e@mail.gmail.com>
2010-04-18 8:12 ` Jonathan Campbell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).