linux kernel - Where is code refers to /proc/PID/maps? -


i observe kernel code print /proc/pid/maps can't find this. tell me code located

the procfs code can found in fs/proc/ subdirectory. if open fs/proc/base.c, can find 2 similar arrays - tgid_base_stuff , tid_base_stuff. both register file operations functions files inside of /proc/pid/ , /proc/pid/tid/ respectivly. you're more interested in first one. find 1 registers "maps" file, looks this:

reg("maps",       s_irugo, proc_pid_maps_operations), 

so structure describing file operations on file called proc_pid_maps_operations. function defined in 2 places - fs/proc/task_mmu.c , fs/proc/task_nommu.c. 1 used depends on kernel configuration it's first one.

inside of task_mmu.c, can find structure definition:

const struct file_operations proc_pid_maps_operations = {     .open       = pid_maps_open,     .read       = seq_read,     .llseek     = seq_lseek,     .release    = proc_map_release, }; 

so when /proc/pid/maps opened, kernel use pid_maps_open function, registers set of operations:

static const struct seq_operations proc_pid_maps_op = {     .start  = m_start,     .next   = m_next,     .stop   = m_stop,     .show   = show_pid_map }; 

so you're interested in show_pid_map function, calls show_map function in turn calls show_map_vma (all in same file).


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -