From 36b357552e8bf68a082895a618ce8fc14d7b21a8 Mon Sep 17 00:00:00 2001 From: phk Date: Mon, 28 Oct 2002 22:43:54 +0000 Subject: [PATCH] Add the remaning part of the new libdisk interaction. WARNING: This is not a published interface, it is a stopgap measure for WARNING: libdisk so we can get 5.0-R out of the door. Sponsored by: DARPA & NAI Labs --- sys/geom/geom_disk.c | 5 +++++ sys/geom/geom_dump.c | 44 +++++++++++++++++++++++++++++++++++++++++++ sys/geom/geom_int.h | 1 + sys/geom/geom_kern.c | 25 ++++++++++++++++++++++-- sys/geom/geom_slice.c | 6 ++++++ 5 files changed, 79 insertions(+), 2 deletions(-) diff --git a/sys/geom/geom_disk.c b/sys/geom/geom_disk.c index b919cd4741b5..0379fabd73e5 100644 --- a/sys/geom/geom_disk.c +++ b/sys/geom/geom_disk.c @@ -208,6 +208,11 @@ g_disk_dumpconf(struct sbuf *sb, char *indent, struct g_geom *gp, struct g_consu struct disk *dp; dp = gp->softc; + if (indent == NULL) { + sbuf_printf(sb, " hd %u", dp->d_fwheads); + sbuf_printf(sb, " sc %u", dp->d_fwsectors); + return; + } if (pp != NULL) { sbuf_printf(sb, "%s%u\n", indent, dp->d_fwheads); diff --git a/sys/geom/geom_dump.c b/sys/geom/geom_dump.c index 3827229548a0..756e8cacbd6f 100644 --- a/sys/geom/geom_dump.c +++ b/sys/geom/geom_dump.c @@ -116,6 +116,50 @@ g_confdot(void *p) wakeup(p); } +static void +g_conftxt_geom(struct sbuf *sb, struct g_geom *gp, int level) +{ + struct g_provider *pp; + struct g_consumer *cp; + + LIST_FOREACH(pp, &gp->provider, provider) { + sbuf_printf(sb, "%d %s %s %ju %u", level, gp->class->name, + pp->name, (uintmax_t)pp->mediasize, pp->sectorsize); + gp->dumpconf(sb, NULL, gp, NULL, pp); + sbuf_printf(sb, "\n"); + LIST_FOREACH(cp, &pp->consumers, consumers) + g_conftxt_geom(sb, cp->geom, level + 1); + } +} + +static void +g_conftxt_class(struct sbuf *sb, struct g_class *mp) +{ + struct g_geom *gp; + + LIST_FOREACH(gp, &mp->geom, geom) + g_conftxt_geom(sb, gp, 0); +} + +void +g_conftxt(void *p) +{ + struct g_class *mp; + struct sbuf *sb; + + sb = p; + g_topology_assert(); + LIST_FOREACH(mp, &g_classes, class) + if (!strcmp(mp->name, "DISK")) + break; + if (mp != NULL) + g_conftxt_class(sb, mp); + else + printf("no DISK\n"); + sbuf_finish(sb); + wakeup(p); +} + static void g_conf_consumer(struct sbuf *sb, struct g_consumer *cp) diff --git a/sys/geom/geom_int.h b/sys/geom/geom_int.h index 8f3009828f42..3224a2db2353 100644 --- a/sys/geom/geom_int.h +++ b/sys/geom/geom_int.h @@ -73,6 +73,7 @@ struct g_event { void g_confxml(void *); void g_conf_specific(struct sbuf *sb, struct g_class *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp); void g_confdot(void *); +void g_conftxt(void *); /* geom_event.c */ diff --git a/sys/geom/geom_kern.c b/sys/geom/geom_kern.c index 5901316c8679..1031fd46fae3 100644 --- a/sys/geom/geom_kern.c +++ b/sys/geom/geom_kern.c @@ -159,6 +159,23 @@ g_init(void) mtx_unlock(&Giant); } +static int +sysctl_kern_geom_conftxt(SYSCTL_HANDLER_ARGS) +{ + int error; + struct sbuf *sb; + + sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND); + sbuf_clear(sb); + g_call_me(g_conftxt, sb); + do { + tsleep(sb, PZERO, "g_dot", hz); + } while(!sbuf_done(sb)); + error = SYSCTL_OUT(req, sbuf_data(sb), sbuf_len(sb) + 1); + sbuf_delete(sb); + return error; +} + static int sysctl_kern_geom_confdot(SYSCTL_HANDLER_ARGS) { @@ -197,11 +214,15 @@ SYSCTL_NODE(_kern, OID_AUTO, geom, CTLFLAG_RW, 0, "GEOMetry management"); SYSCTL_PROC(_kern_geom, OID_AUTO, confxml, CTLTYPE_STRING|CTLFLAG_RD, 0, 0, sysctl_kern_geom_confxml, "A", - "Dump the GEOM config"); + "Dump the GEOM config in XML"); SYSCTL_PROC(_kern_geom, OID_AUTO, confdot, CTLTYPE_STRING|CTLFLAG_RD, 0, 0, sysctl_kern_geom_confdot, "A", - "Dump the GEOM config"); + "Dump the GEOM config in dot"); + +SYSCTL_PROC(_kern_geom, OID_AUTO, conftxt, CTLTYPE_STRING|CTLFLAG_RD, + 0, 0, sysctl_kern_geom_conftxt, "A", + "Dump the GEOM config in txt"); SYSCTL_INT(_kern_geom, OID_AUTO, debugflags, CTLFLAG_RW, &g_debugflags, 0, ""); diff --git a/sys/geom/geom_slice.c b/sys/geom/geom_slice.c index cc67cb908f44..033713adf927 100644 --- a/sys/geom/geom_slice.c +++ b/sys/geom/geom_slice.c @@ -206,6 +206,12 @@ g_slice_dumpconf(struct sbuf *sb, char *indent, struct g_geom *gp, struct g_cons struct g_slicer *gsp; gsp = gp->softc; + if (indent == NULL) { + sbuf_printf(sb, " i %u", pp->index); + sbuf_printf(sb, " o %ju", + (uintmax_t)gsp->slices[pp->index].offset); + return; + } if (gp != NULL && (pp == NULL && cp == NULL)) { sbuf_printf(sb, "%s%ju\n", indent, (intmax_t)gsp->frontstuff);