This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ioblock.stp major/minor number patch


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]