From: Mike Mason <mmlnx@us.ibm.com>
To: SystemTAP <systemtap@sources.redhat.com>
Subject: ioblock.stp major/minor number patch
Date: Mon, 23 Oct 2006 15:37:00 -0000 [thread overview]
Message-ID: <453CE190.3060406@us.ibm.com> (raw)
The following patch adds major/minor number functions to the ioblock tapset. I found them useful in a block IO script I'm writing. It also fixes a few misleading comments.
- Mike Mason
--- src/tapset/ioblock.stp 2006-08-15 18:54:46.000000000 -0700
+++ src.save2/tapset/ioblock.stp 2006-10-23 08:30:08.000000000 -0700
@@ -10,9 +10,10 @@
%{
#include <linux/bio.h>
#include <linux/genhd.h>
+#include <linux/kdev_t.h>
%}
-/* get i-node number of mapped file */
+/* get i-node number of device file */
function __bio_ino:long(bio:long)
%{
struct bio *bio;
@@ -113,6 +114,52 @@
}
%}
+/* returns block device major number */
+function bio_major:long(bio:long)
+%{
+ struct bio *bio;
+ struct block_device *bi_bdev;
+
+ bio = (struct bio *)(long)THIS->bio;
+ bi_bdev = (struct block_device *)deref(sizeof(bio->bi_bdev),
+ &(bio->bi_bdev));
+ if (bi_bdev == NULL) {
+ THIS->__retvalue = -1;
+ goto end;
+ }
+
+ THIS->__retvalue = MAJOR(bi_bdev->bd_dev);
+
+ if (0) {
+deref_fault:
+ CONTEXT->last_error = "pointer dereference fault";
+ }
+end: ;
+%}
+
+/* returns block device minor number */
+function bio_minor:long(bio:long)
+%{
+ struct bio *bio;
+ struct block_device *bi_bdev;
+
+ bio = (struct bio *)(long)THIS->bio;
+ bi_bdev = (struct block_device *)deref(sizeof(bio->bi_bdev),
+ &(bio->bi_bdev));
+ if (bi_bdev == NULL) {
+ THIS->__retvalue = -1;
+ goto end;
+ }
+
+ THIS->__retvalue = MINOR(bi_bdev->bd_dev);
+
+ if (0) {
+deref_fault:
+ CONTEXT->last_error = "pointer dereference fault";
+ }
+end: ;
+%}
+
global BIO_READ, BIO_WRITE
probe begin
{
@@ -129,7 +176,7 @@
*
* Variables:
* devname - block device name
- * ino - i-node number of the mapped file
+ * ino - i-node number of the device file
* sector - beginning sector for the entire bio
* flags - see below
* BIO_UPTODATE 0 ok after I/O completion
@@ -184,8 +231,8 @@
*
* Variables:
* devname - block device name
- * ino - i-node number of the mapped file
- * byte_done - number of bytes transferred
+ * ino - i-node number of the device file
+ * bytes_done - number of bytes transferred
* sector - beginning sector for the entire bio
* flags - see below
* BIO_UPTODATE 0 ok after I/O completion
next reply other threads:[~2006-10-23 15:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-23 15:37 Mike Mason [this message]
2006-10-23 15:56 ` Frank Ch. Eigler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=453CE190.3060406@us.ibm.com \
--to=mmlnx@us.ibm.com \
--cc=systemtap@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).