Skip to content

Instantly share code, notes, and snippets.

@siddontang
Last active November 8, 2017 03:14
Show Gist options
  • Save siddontang/15021aeccb19210567dc09a7f1d185af to your computer and use it in GitHub Desktop.
Save siddontang/15021aeccb19210567dc09a7f1d185af to your computer and use it in GitHub Desktop.
#! /usr/bin/evn stap
#
probe begin
{
printf("begin to trace thread IO");
}
probe vfs.read
{
if (target() == pid()) {
printf("%s[%ld] - read %d from %s\n", execname(), tid(), bytes_to_read, reverse_path_walk($file->f_path->dentry))
}
}
probe vfs.write
{
if (target() == pid())
{
printf("%s[%ld] - write %d to %s\n", execname(), tid(), bytes_to_write, reverse_path_walk($file->f_path->dentry))
}
}
probe vfs.open
{
if (target() == pid())
{
printf("%s[%ld] - open %s\n", execname(), tid(), pathname)
}
}
probe syscall.close
{
if (target() == pid())
{
file = task_fd_lookup(task_current(), fd)
printf("%s[%ld] - close %s\n", execname(), tid(), fullpath_struct_path(&@cast(file, "file")->f_path))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment