summaryrefslogtreecommitdiffstats
path: root/tapset/dev.stp
diff options
context:
space:
mode:
authorDavid Smith <dsmith@redhat.com>2010-03-30 15:53:51 -0500
committerDavid Smith <dsmith@redhat.com>2010-03-30 15:53:51 -0500
commit1713a05f2afa6df663a7fd3552849759a7d3ff48 (patch)
treebd182e9ce4c075cf4cde34a273966761fa3edbff /tapset/dev.stp
parenteda8b449152cf0f864d2cd250fb2b7a2945bc996 (diff)
downloadsystemtap-steved-1713a05f2afa6df663a7fd3552849759a7d3ff48.tar.gz
systemtap-steved-1713a05f2afa6df663a7fd3552849759a7d3ff48.tar.xz
systemtap-steved-1713a05f2afa6df663a7fd3552849759a7d3ff48.zip
PR 9871 (partial) fix. Removed some embedded-C in ioblock.stp/vfs.stp.
* tapset/dev.stp: Added a bdevname() script function. * tapset/ioblock.stp: Rewrote the embedded-C devname function to just use bdevname() script function. * tapset/vfs.stp: Removed embedded-C __bdevname() C function. Calls bdevname() script function instead. * tapset/string.stp: Added isdigit() function.
Diffstat (limited to 'tapset/dev.stp')
-rw-r--r--tapset/dev.stp26
1 files changed, 24 insertions, 2 deletions
diff --git a/tapset/dev.stp b/tapset/dev.stp
index 80449324..2c22031a 100644
--- a/tapset/dev.stp
+++ b/tapset/dev.stp
@@ -1,5 +1,5 @@
-// Device numbering tapset
-// Copyright (C) 2008 Red Hat Corp.
+// Device tapset
+// Copyright (C) 2008, 2010 Red Hat Corp.
//
// This file is part of systemtap, and is free software. You can
// redistribute it and/or modify it under the terms of the GNU General
@@ -31,3 +31,25 @@ function usrdev2kerndev:long(dev:long)
%{ /* pure */
THIS->__retvalue = new_decode_dev(THIS->dev);
%}
+
+function bdevname:string(bdev:long)
+{
+ if (bdev == 0)
+ return "N/A"
+
+ hd = @cast(bdev, "block_device")->bd_disk
+
+ if (@cast(bdev, "block_device")->bd_part)
+ partno = @cast(bdev, "block_device")->bd_part->partno
+ else
+ partno = MINOR(@cast(bdev, "block_device")->bd_dev)
+ - @cast(bdev, "block_device")->bd_disk->first_minor;
+
+ if (!partno)
+ return kernel_string(@cast(hd, "gendisk")->disk_name)
+ disk_name = kernel_string(@cast(hd, "gendisk")->disk_name)
+ if (isdigit(substr(disk_name, strlen(disk_name) - 1, 1)))
+ return sprintf("%sp%d", disk_name, partno)
+ else
+ return sprintf("%s%d", disk_name, partno)
+}