diff options
author | Jeremie Koenig <jk@jk.fr.eu.org> | 2010-08-23 05:44:37 +0000 |
---|---|---|
committer | Jeremie Koenig <jk@jk.fr.eu.org> | 2010-08-30 14:29:51 +0200 |
commit | 166becc7157e51c54a51a7cb78602704256969d0 (patch) | |
tree | 6d80b049ff9699f955865e5453036ddffab282a3 | |
parent | d87eae321df3f434ea9b6cf96c2437c8b9a7b23d (diff) |
Add statm to process directories
* process.c: Add the statm file.
-rw-r--r-- | process.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -105,6 +105,20 @@ process_file_gc_stat (struct proc_stat *ps, size_t *len) return len >= 0 ? contents : NULL; } +static char * +process_file_gc_statm (struct proc_stat *ps, size_t *len) +{ + task_basic_info_t tbi = proc_stat_task_basic_info (ps); + char *contents; + + *len = asprintf (&contents, + "%lu %lu 0 0 0 0 0\n", + tbi->virtual_size / sysconf(_SC_PAGE_SIZE), + tbi->resident_size / sysconf(_SC_PAGE_SIZE)); + + return len >= 0 ? contents : NULL; +} + /* Describes a file in a process directory. This is used as an "entry hook" * for our procfs_dir entry table, passed to process_file_make_node. */ @@ -217,6 +231,15 @@ static struct procfs_dir_entry entries[] = { .mode = 0400, }, }, + { + .name = "statm", + .make_node = process_file_make_node, + .hook = & (struct process_file_desc) { + .get_contents = process_file_gc_statm, + .needs = PSTAT_TASK_BASIC, + .mode = 0444, + }, + }, {} }; |