summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2007-05-05 17:52:22 +0000
committerpjd <pjd@FreeBSD.org>2007-05-05 17:52:22 +0000
commit592f466b1be65f5fb7784dad52457a6d98b4450a (patch)
treef71a0dbcc0facedc4cc6c221f5e9dcf0e65bd49d
parent9409284b5b281b8a9a8732b5edcd7e12680a173b (diff)
downloadFreeBSD-src-592f466b1be65f5fb7784dad52457a6d98b4450a.zip
FreeBSD-src-592f466b1be65f5fb7784dad52457a6d98b4450a.tar.gz
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
-rw-r--r--sys/geom/geom_slice.c32
1 files changed, 32 insertions, 0 deletions
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;
OpenPOWER on IntegriCloud