public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* Improvement to disktop.stp: how to find the full file name?
@ 2010-09-05 15:23 laurent
  2010-09-06 13:19 ` Mark Wielaard
  0 siblings, 1 reply; 3+ messages in thread
From: laurent @ 2010-09-05 15:23 UTC (permalink / raw)
  To: systemtap; +Cc: laurent

Hi,

I'd like to add disltop.stp the capability to print which file are 
being read/written by each process. It's quite easy to get the filename 
by using the provided __file_pathname function (eg: "kern.log"), but 
I'm unable to figure out how to find the full pathname (eg: 
"/var/log/kern.log"). Any idea on how to do that?

Thanks in advance,

Laurent

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Improvement to disktop.stp: how to find the full file name?
  2010-09-05 15:23 Improvement to disktop.stp: how to find the full file name? laurent
@ 2010-09-06 13:19 ` Mark Wielaard
  2010-09-06 13:37   ` Mark Wielaard
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Wielaard @ 2010-09-06 13:19 UTC (permalink / raw)
  To: laurent; +Cc: systemtap

On Sun, 2010-09-05 at 17:23 +0200, laurent@guerby.net wrote:
> I'd like to add disltop.stp the capability to print which file are 
> being read/written by each process. It's quite easy to get the filename 
> by using the provided __file_pathname function (eg: "kern.log"), but 
> I'm unable to figure out how to find the full pathname (eg: 
> "/var/log/kern.log"). Any idea on how to do that?

dentry.stp provides a function reverse_path_walk() that mostly seems to
do what you want. It takes a dentry, which you could get as follows:

$ stap -e 'probe vfs.read { if (file != 0 && devname != "N/A")
  { dentry = @cast(file, "file")->f_path->dentry;
    log(execname() . " " . devname . ":"
        . reverse_path_walk(dentry)); } }'

Don't know if there is an easy way to map the dev/devname to the mount
point to complete the full path name.

Cheers,

Mark

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Improvement to disktop.stp: how to find the full file name?
  2010-09-06 13:19 ` Mark Wielaard
@ 2010-09-06 13:37   ` Mark Wielaard
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Wielaard @ 2010-09-06 13:37 UTC (permalink / raw)
  To: laurent; +Cc: systemtap

On Mon, 2010-09-06 at 15:19 +0200, Mark Wielaard wrote:
> On Sun, 2010-09-05 at 17:23 +0200, laurent@guerby.net wrote:
> > I'd like to add disltop.stp the capability to print which file are 
> > being read/written by each process. It's quite easy to get the filename 
> > by using the provided __file_pathname function (eg: "kern.log"), but 
> > I'm unable to figure out how to find the full pathname (eg: 
> > "/var/log/kern.log"). Any idea on how to do that?
> 
> dentry.stp provides a function reverse_path_walk() that mostly seems to
> do what you want. It takes a dentry, which you could get as follows:
> 
> $ stap -e 'probe vfs.read { if (file != 0 && devname != "N/A")
>   { dentry = @cast(file, "file")->f_path->dentry;
>     log(execname() . " " . devname . ":"
>         . reverse_path_walk(dentry)); } }'
> 
> Don't know if there is an easy way to map the dev/devname to the mount
> point to complete the full path name.

Actually, it wasn't to hard to come up with something that is pretty
close:
$ stap -e 'probe vfs.read
  { if (file != 0 && devname != "N/A")
    { mountpoint = @cast(file, "file")->f_path->mnt->mnt_mountpoint;
      parent = @cast(file, "file")->f_path->dentry->d_parent;
      name = @cast(file, "file")->f_path->dentry;
      log(execname() . " " . reverse_path_walk(mountpoint)
          . reverse_path_walk(parent) . d_name(name)); } }'

You need to tweak this a little to get the slashes right at the start,
but it seems to mostly do what you want.

Cheers,

Mark

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-09-06 13:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-05 15:23 Improvement to disktop.stp: how to find the full file name? laurent
2010-09-06 13:19 ` Mark Wielaard
2010-09-06 13:37   ` Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).