In task_struct, we can find there are:
struct mm_struct *mm, *active_mm;
struct files_struct *files;
files_struct contains pointers to up to 256 file data structures, each one describing a file being used by this process.
struct file * fd_array[NR_OPEN_DEFAULT];
mm_struct contains a vm_area_struct.
struct vm_area_struct * mmap; /* list of VMAs */
And in vm_area_struct, we can find:
struct file * vm_file; /* File we map to (can be NULL). */
So my question are:
-
what is the relationship between the files in
fd_arrayand thevm_file? -
Are all the files shown up in the
fd_arraywill also be mapped in thevm_area_structin a way similar as shown in the picture? Or, are all the files mapped in thevm_area_structwill show up in thefd_array?
Thanks,

(source: duartes.org)
The files in
fd_arrayare those that currently have a file descriptor associated with them (eg. opened withopen(),socket()or similar), and those linked by VMAs are those that are mapped into process memory (eg. withmmap()). Files can be in either category or in both, so those files infd_arrayare not necessarily linked by a VMA and vice-versa.