From 592f466b1be65f5fb7784dad52457a6d98b4450a Mon Sep 17 00:00:00 2001 From: pjd Date: Sat, 5 May 2007 17:52:22 +0000 Subject: Handle GEOM::ident attribute by attaching 'sX' string at the end of ident received from the underlying provider, where X is pp->index value. OK'ed by: phk --- sys/geom/geom_slice.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/sys/geom/geom_slice.c b/sys/geom/geom_slice.c index c85e4a0..9462fdc 100644 --- a/sys/geom/geom_slice.c +++ b/sys/geom/geom_slice.c @@ -172,6 +172,28 @@ g_slice_finish_hot(struct bio *bp) } static void +g_slice_done(struct bio *bp) +{ + + KASSERT(bp->bio_cmd == BIO_GETATTR && + strcmp(bp->bio_attribute, "GEOM::ident") == 0, + ("bio_cmd=0x%x bio_attribute=%s", bp->bio_cmd, bp->bio_attribute)); + + if (bp->bio_error == 0 && bp->bio_data[0] != '\0') { + char idx[8]; + + /* Add index to the ident received. */ + snprintf(idx, sizeof(idx), "s%d", + bp->bio_parent->bio_to->index); + if (strlcat(bp->bio_data, idx, bp->bio_length) >= + bp->bio_length) { + bp->bio_error = EFAULT; + } + } + g_std_done(bp); +} + +static void g_slice_start(struct bio *bp) { struct bio *bp2; @@ -251,6 +273,16 @@ g_slice_start(struct bio *bp) /* Give the real method a chance to override */ if (gsp->start != NULL && gsp->start(bp)) return; + if (!strcmp("GEOM::ident", bp->bio_attribute)) { + bp2 = g_clone_bio(bp); + if (bp2 == NULL) { + g_io_deliver(bp, ENOMEM); + return; + } + bp2->bio_done = g_slice_done; + g_io_request(bp2, cp); + return; + } if (!strcmp("GEOM::kerneldump", bp->bio_attribute)) { struct g_kerneldump *gkd; -- cgit v1.1