diff options
author | srikar <srikar> | 2007-09-04 10:36:59 +0000 |
---|---|---|
committer | srikar <srikar> | 2007-09-04 10:36:59 +0000 |
commit | 86963113d4e3b10cd08389873c0eff62ba79f516 (patch) | |
tree | 1a7dd6fc33e2475dc26a2c298a6b8f599ce1d640 /tapset | |
parent | c4830239d5dc029bd935e0903a417815b894c96a (diff) | |
download | systemtap-steved-86963113d4e3b10cd08389873c0eff62ba79f516.tar.gz systemtap-steved-86963113d4e3b10cd08389873c0eff62ba79f516.tar.xz systemtap-steved-86963113d4e3b10cd08389873c0eff62ba79f516.zip |
Added open_file_handles tapset function and man page for task tapsets.
Diffstat (limited to 'tapset')
-rw-r--r-- | tapset/task.stp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tapset/task.stp b/tapset/task.stp index 97ae5c7e..947351c6 100644 --- a/tapset/task.stp +++ b/tapset/task.stp @@ -6,6 +6,10 @@ // Public License (GPL); either version 2, or (at your option) any // later version. +%{ +#include <linux/version.h> +#include <linux/file.h> +%} // Return the task_struct representing the current process function task_current:long () %{ /* pure */ @@ -125,3 +129,33 @@ function task_cpu:long (task:long) CATCH_DEREF_FAULT(); %} %) + + +// Return the number of open file handlers for the given task +function task_open_file_handles:long (task:long) %{ /* pure */ + struct task_struct *t = (struct task_struct *)(long)THIS->task; + struct files_struct *f = kread(&(t->files)); + struct fdtable *fdt = kread(&(f->fdt)); + unsigned int count=0, fd, max; + rcu_read_lock(); + max = kread(&(fdt->max_fds)); + for (fd = 0; fd < max; fd++) { + if ( kread(&(fdt->fd[fd])) != NULL) + count ++; + } + rcu_read_unlock(); + THIS->__retvalue = count; + CATCH_DEREF_FAULT(); +%} + + +// Return the maximum number of file handlers for the given task +function task_max_file_handles:long (task:long) %{ /* pure */ + struct task_struct *t = (struct task_struct *)(long)THIS->task; + struct files_struct *f = kread (&(t->files)); + struct fdtable *fdt = kread(&(f->fdt)); + rcu_read_lock(); + THIS->__retvalue = kread(&(fdt->max_fds)); + rcu_read_unlock(); + CATCH_DEREF_FAULT(); +%} |