summaryrefslogtreecommitdiffstats
path: root/sys/geom/geom_io.c
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2004-02-11 18:21:32 +0000
committerpjd <pjd@FreeBSD.org>2004-02-11 18:21:32 +0000
commitc681583fbc8e0ff0d3f54a2ce41b3a5a14917315 (patch)
treeae4981c67b129f44f81748d7104bcfdf9166b968 /sys/geom/geom_io.c
parent920753994a7214f33c6eb260960a56e05a24885e (diff)
downloadFreeBSD-src-c681583fbc8e0ff0d3f54a2ce41b3a5a14917315.zip
FreeBSD-src-c681583fbc8e0ff0d3f54a2ce41b3a5a14917315.tar.gz
Added g_print_bio() function to print informations about given bio.
Approved by: phk, scottl (mentor)
Diffstat (limited to 'sys/geom/geom_io.c')
-rw-r--r--sys/geom/geom_io.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/sys/geom/geom_io.c b/sys/geom/geom_io.c
index 28c3b32..507069b 100644
--- a/sys/geom/geom_io.c
+++ b/sys/geom/geom_io.c
@@ -457,3 +457,37 @@ g_write_data(struct g_consumer *cp, off_t offset, void *ptr, off_t length)
g_destroy_bio(bp);
return (error);
}
+
+void
+g_print_bio(struct bio *bp)
+{
+ const char *pname, *cmd = NULL;
+
+ if (bp->bio_to != NULL)
+ pname = bp->bio_to->name;
+ else
+ pname = "[unknown]";
+
+ switch (bp->bio_cmd) {
+ case BIO_GETATTR:
+ cmd = "GETATTR";
+ printf("%s[%s(attr=%s)]", pname, cmd, bp->bio_attribute);
+ return;
+ case BIO_READ:
+ cmd = "READ";
+ case BIO_WRITE:
+ if (cmd == NULL)
+ cmd = "WRITE";
+ case BIO_DELETE:
+ if (cmd == NULL)
+ cmd = "DELETE";
+ printf("%s[%s(offset=%jd, length=%jd)]", pname, cmd,
+ (intmax_t)bp->bio_offset, (intmax_t)bp->bio_length);
+ return;
+ default:
+ cmd = "UNKNOWN";
+ printf("%s[%s()]", pname, cmd);
+ return;
+ }
+ /* NOTREACHED */
+}
OpenPOWER on IntegriCloud