[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to find the list and number of files opened by a process?



Thanks Avishay.

On 3/5/07, Avishay Traeger <atraeger@xxxxxxxxxxxxx> wrote:
On Mon, 2007-03-05 at 13:47 +0100, Martin Mancuska wrote:
> Hi,
>
> maybe struct task_struct is that what you  are looking for.
>
> martin

More specifically, in "struct task_struct", there is a field "struct
files_struct *files", which should have all of the information that
you're looking for.

Actually,  I am able to find the pid, ppid, state of the process.

But, I am not able to find the count of the files opened by the process. I am aware of the fact that  files_struct *files pointer gives information about the open files. But, not sure how to get them.

Because, of RCU files_struct is changed and it makes use of struct fdtable (this is the only thing I grasped from Documentation/fs/files.txt) (i m using 2.6.20 kernel)

struct files_struct {
  /*
   * read mostly part
   */
    atomic_t count;
    struct fdtable *fdt;
    struct fdtable fdtab;
  /*
   * written part on a separate cache line in SMP
   */
    spinlock_t file_lock ____cacheline_aligned_in_smp;
    int next_fd;
    struct embedded_fd_set close_on_exec_init;
    struct embedded_fd_set open_fds_init;
    struct file * fd_array[NR_OPEN_DEFAULT];
};

There are two fdtables not sure which one will give me the number of files opened and names of the files opened by the process.

Avishay



--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ