summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremie Koenig <jk@jk.fr.eu.org>2010-08-23 05:44:37 +0000
committerJeremie Koenig <jk@jk.fr.eu.org>2010-08-30 14:29:51 +0200
commite873ff83afba08ff61a5e98ab90d5ee05ab5c601 (patch)
treeddbb54a9647f2f17b33f6bb0f7eb26c66370a5a8
parente3707dc9deb28d5144836032a54dbc028247835d (diff)
Add statm to process directories
* process.c: Add the statm file.
-rw-r--r--process.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/process.c b/process.c
index f7a7a57..4404d08 100644
--- a/process.c
+++ b/process.c
@@ -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,
+ },
+ },
{}
};