summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorWilliam Cohen <wcohen@redhat.com>2010-03-01 15:39:23 -0500
committerWilliam Cohen <wcohen@redhat.com>2010-03-02 11:52:20 -0500
commit1f95aa31dd8859031149678651916e2441a8d3c5 (patch)
tree8f83fcb48cbc98ba1834a9f91a39c818a6d28404 /doc
parentbfbbb76e5d0294cc1d44f42ab6c2d91149067b6c (diff)
downloadsystemtap-steved-1f95aa31dd8859031149678651916e2441a8d3c5.tar.gz
systemtap-steved-1f95aa31dd8859031149678651916e2441a8d3c5.tar.xz
systemtap-steved-1f95aa31dd8859031149678651916e2441a8d3c5.zip
Make the inode-watch.stp example work on newer kernels.
Diffstat (limited to 'doc')
-rw-r--r--doc/tutorial.tex25
-rw-r--r--doc/tutorial/inode-watch.stp7
2 files changed, 22 insertions, 10 deletions
diff --git a/doc/tutorial.tex b/doc/tutorial.tex
index 3a04900b..1200967b 100644
--- a/doc/tutorial.tex
+++ b/doc/tutorial.tex
@@ -427,13 +427,18 @@ Let's say that you are trying to trace filesystem reads/writes to a
particular device/inode. From your knowledge of the kernel, you know
that two functions of interest could be \verb+vfs_read+ and
\verb+vfs_write+. Each takes a \verb+struct file *+ argument, inside
-which there is a \verb+struct dentry *+, a \verb+struct inode *+, and
-so on. Systemtap allows limited dereferencing of such pointer chains.
+there is either a \verb+struct dentry *+ or \verb+struct path *+ which
+has a \verb+struct dentry *+.
+The \verb+struct dentry *+ contains a \verb+struct inode *+, and
+so on.
+Systemtap allows limited dereferencing of such pointer chains.
Two functions, \verb+user_string+ and \verb+kernel_string+, can copy
\verb+char *+ target variables into systemtap strings.
Figure~\ref{fig:inode-watch} demonstrates one way to monitor a
-particular file (identifed by device number and inode number). This
-example also demonstrates pasting numeric command-line arguments
+particular file (identifed by device number and inode number).
+The script selects the appropriate variants of \verb+dev_nr+
+and\verb+inode_nr+ based on the kernel version.
+This example also demonstrates pasting numeric command-line arguments
(\verb+$1+ etc.) into scripts.
%$
@@ -444,8 +449,13 @@ example also demonstrates pasting numeric command-line arguments
probe kernel.function ("vfs_write"),
kernel.function ("vfs_read")
{
+%( kernel_v >= "2.6.20" %?
+ dev_nr = $file->f_path->dentry->d_inode->i_sb->s_dev
+ inode_nr = $file->f_path->dentry->d_inode->i_ino
+%:
dev_nr = $file->f_dentry->d_inode->i_sb->s_dev
inode_nr = $file->f_dentry->d_inode->i_ino
+%)
if (dev_nr == ($1 << 20 | $2) # major/minor device
&& inode_nr == $3)
@@ -453,11 +463,10 @@ probe kernel.function ("vfs_write"),
execname(), pid(), probefunc(), dev_nr, inode_nr)
}
# stat -c '%D %i' /etc/crontab
-803 988136
+fd03 133099
# stap inode-watch.stp 8 3 988136
-crond(2419) vfs_read 0x800003/988136
-crond(2419) vfs_read 0x800003/988136
-crond(2419) vfs_read 0x800003/988136
+more(30789) vfs_read 0xfd00003/133099
+more(30789) vfs_read 0xfd00003/133099
\end{verbatim}
% $
\end{boxedminipage}
diff --git a/doc/tutorial/inode-watch.stp b/doc/tutorial/inode-watch.stp
index caf04b9a..2209f309 100644
--- a/doc/tutorial/inode-watch.stp
+++ b/doc/tutorial/inode-watch.stp
@@ -1,13 +1,16 @@
probe kernel.function ("vfs_write"),
kernel.function ("vfs_read")
{
+%( kernel_v >= "2.6.20" %?
+ dev_nr = $file->f_path->dentry->d_inode->i_sb->s_dev
+ inode_nr = $file->f_path->dentry->d_inode->i_ino
+%:
dev_nr = $file->f_dentry->d_inode->i_sb->s_dev
inode_nr = $file->f_dentry->d_inode->i_ino
+%)
if (dev_nr == ($1 << 20 | $2) # major/minor device
&& inode_nr == $3)
printf ("%s(%d) %s 0x%x/%u\n",
execname(), pid(), probefunc(), dev_nr, inode_nr)
}
-
-# dev_name = kernel_string ($file->f_dentry->d_inode->i_sb->s_id)