Proposing tapset MAJOR(), MINOR(), and MKDEV() function
William Cohen
wcohen@redhat.com
Fri Jun 20 17:04:00 GMT 2008
Hi All,
I have been working on cleaning up the war stories and including them
in the regular testing. A number of the warstories(WSDeviceMonitor,
WSFileMonitor, and WSFileMonitor2) make use of the device number
information. The examples extract the device number out of a
dev_t. Right now the examples are a bit awkward. The examples use stat
to get determine the major and minor number, but the actual feeding to
the script requires some manual munging. From WSDeviceMonitor:
$ ls -laF /dev/sdc1
brw-r----- 1 root disk 8, 33 2007-06-12 20:25 /dev/sdc1
$ stap traceio2.stp 8 33
It seems like it would be nicer to allow the use the output of stat
directly. Something like:
stap traceio2.stp `stat -c "0x%t 0x%T" /dev/sdc1`
It might be useful to have wrappers functions in systemtap to make
handling major and minor device numbers a bit more portable:
MAJOR(kdev_t dev) extract major device number
MINOR(kdev_t dev) extract minor device number
MKDEV(int major, int minor)generate device number
rather than having hardcoded shifts and bit-wise or, could do something
like the following in the script:
probe kernel.function ("vfs_write"),
kernel.function ("vfs_read")
{
dev_nr = $file->f_path->dentry->d_inode->i_sb->s_dev
inode_nr = $file->f_path->dentry->d_inode->i_ino
if (dev_nr == MKDEV($1,$2))
printf ("%s(%d) %s 0x%x\n", execname(), pid(), probefunc(), dev_nr)
}
I have attached the dev.stp tapset to the mail. Any comments about
adding these tapset functions.
-Will
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dev.stp
URL: <http://sourceware.org/pipermail/systemtap/attachments/20080620/2c16129d/attachment.ksh>
More information about the Systemtap
mailing list