summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2004-07-26 17:14:47 +0000
committerpjd <pjd@FreeBSD.org>2004-07-26 17:14:47 +0000
commit73a684d5877f06cfed5b965bce4980dc1d1f3e5e (patch)
tree376311136ec2ae90ae2a302bbc4edad2094096dd /sys
parent3a2f13d5f5f45530d066bd48f5c672989bc023c1 (diff)
downloadFreeBSD-src-73a684d5877f06cfed5b965bce4980dc1d1f3e5e.zip
FreeBSD-src-73a684d5877f06cfed5b965bce4980dc1d1f3e5e.tar.gz
Improve geom(8)'s 'list' command to show geoms and their providers and
consumers. Teach STRIPE, CONCAT and NOP classes about this improvement.
Diffstat (limited to 'sys')
-rw-r--r--sys/geom/concat/g_concat.c63
-rw-r--r--sys/geom/nop/g_nop.c6
-rw-r--r--sys/geom/stripe/g_stripe.c59
3 files changed, 69 insertions, 59 deletions
diff --git a/sys/geom/concat/g_concat.c b/sys/geom/concat/g_concat.c
index 20a54c5..c87839d 100644
--- a/sys/geom/concat/g_concat.c
+++ b/sys/geom/concat/g_concat.c
@@ -798,35 +798,44 @@ g_concat_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
g_topology_assert();
sc = gp->softc;
- if (sc == NULL || pp == NULL)
+ if (sc == NULL)
return;
- sbuf_printf(sb, "%s<id>%u</id>\n", indent, (u_int)sc->sc_id);
- switch (sc->sc_type) {
- case G_CONCAT_TYPE_AUTOMATIC:
- sbuf_printf(sb, "%s<type>%s</type>\n", indent, "automatic");
- break;
- case G_CONCAT_TYPE_MANUAL:
- sbuf_printf(sb, "%s<type>%s</type>\n", indent, "manual");
- break;
- default:
- sbuf_printf(sb, "%s<type>%s</type>\n", indent, "unknown");
- break;
+ if (pp != NULL) {
+ /* Nothing here. */
+ } else if (cp != NULL) {
+ struct g_concat_disk *disk;
+
+ disk = cp->private;
+ if (disk == NULL)
+ return;
+ sbuf_printf(sb, "%s<End>%jd</End>\n", indent,
+ (intmax_t)disk->d_end);
+ sbuf_printf(sb, "%s<Start>%jd</Start>\n", indent,
+ (intmax_t)disk->d_start);
+ } else {
+ sbuf_printf(sb, "%s<ID>%u</ID>\n", indent, (u_int)sc->sc_id);
+ sbuf_printf(sb, "%s<Type>", indent);
+ switch (sc->sc_type) {
+ case G_CONCAT_TYPE_AUTOMATIC:
+ sbuf_printf(sb, "AUTOMATIC");
+ break;
+ case G_CONCAT_TYPE_MANUAL:
+ sbuf_printf(sb, "MANUAL");
+ break;
+ default:
+ sbuf_printf(sb, "UNKNOWN");
+ break;
+ }
+ sbuf_printf(sb, "</Type>\n");
+ sbuf_printf(sb, "%s<Status>Total=%u, Online=%u</Status>\n",
+ indent, sc->sc_ndisks, g_concat_nvalid(sc));
+ sbuf_printf(sb, "%s<State>", indent);
+ if (sc->sc_provider != NULL && sc->sc_provider->error == 0)
+ sbuf_printf(sb, "UP");
+ else
+ sbuf_printf(sb, "DOWN");
+ sbuf_printf(sb, "</State>\n");
}
- sbuf_printf(sb, "%s<providers>", indent);
- LIST_FOREACH(cp, &gp->consumer, consumer) {
- if (cp->provider == NULL)
- continue;
- sbuf_printf(sb, "%s", cp->provider->name);
- if (LIST_NEXT(cp, consumer) != NULL)
- sbuf_printf(sb, " ");
- }
- sbuf_printf(sb, "</providers>\n");
- sbuf_printf(sb, "%s<status>total=%u, online=%u</status>\n", indent,
- sc->sc_ndisks, g_concat_nvalid(sc));
- if (pp->error == 0)
- sbuf_printf(sb, "%s<state>UP</state>\n", indent);
- else
- sbuf_printf(sb, "%s<state>DOWN</state>\n", indent);
}
DECLARE_GEOM_CLASS(g_concat_class, g_concat);
diff --git a/sys/geom/nop/g_nop.c b/sys/geom/nop/g_nop.c
index 00860f1..88283ee 100644
--- a/sys/geom/nop/g_nop.c
+++ b/sys/geom/nop/g_nop.c
@@ -468,12 +468,12 @@ g_nop_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
{
struct g_nop_softc *sc;
- if (pp == NULL)
+ if (pp != NULL || cp != NULL)
return;
sc = gp->softc;
- sbuf_printf(sb, "%s<offset>%jd</offset>\n", indent,
+ sbuf_printf(sb, "%s<Offset>%jd</Offset>\n", indent,
(intmax_t)sc->sc_offset);
- sbuf_printf(sb, "%s<failprob>%u</failprob>\n", indent, sc->sc_failprob);
+ sbuf_printf(sb, "%s<Failprob>%u</Failprob>\n", indent, sc->sc_failprob);
}
DECLARE_GEOM_CLASS(g_nop_class, g_nop);
diff --git a/sys/geom/stripe/g_stripe.c b/sys/geom/stripe/g_stripe.c
index 9e642c0..705a860 100644
--- a/sys/geom/stripe/g_stripe.c
+++ b/sys/geom/stripe/g_stripe.c
@@ -1128,37 +1128,38 @@ g_stripe_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
struct g_stripe_softc *sc;
sc = gp->softc;
- if (sc == NULL || pp == NULL)
+ if (sc == NULL)
return;
- sbuf_printf(sb, "%s<id>%u</id>\n", indent, (u_int)sc->sc_id);
- sbuf_printf(sb, "%s<stripesize>%u</stripesize>\n", indent,
- (u_int)sc->sc_stripesize);
- switch (sc->sc_type) {
- case G_STRIPE_TYPE_AUTOMATIC:
- sbuf_printf(sb, "%s<type>%s</type>\n", indent, "automatic");
- break;
- case G_STRIPE_TYPE_MANUAL:
- sbuf_printf(sb, "%s<type>%s</type>\n", indent, "manual");
- break;
- default:
- sbuf_printf(sb, "%s<type>%s</type>\n", indent, "unknown");
- break;
- }
- sbuf_printf(sb, "%s<providers>", indent);
- LIST_FOREACH(cp, &gp->consumer, consumer) {
- if (cp->provider == NULL)
- continue;
- sbuf_printf(sb, "%s", cp->provider->name);
- if (LIST_NEXT(cp, consumer) != NULL)
- sbuf_printf(sb, " ");
+ if (pp != NULL) {
+ /* Nothing here. */
+ } else if (cp != NULL) {
+ /* Nothing here. */
+ } else {
+ sbuf_printf(sb, "%s<ID>%u</ID>\n", indent, (u_int)sc->sc_id);
+ sbuf_printf(sb, "%s<Stripesize>%u</Stripesize>\n", indent,
+ (u_int)sc->sc_stripesize);
+ sbuf_printf(sb, "%s<Type>", indent);
+ switch (sc->sc_type) {
+ case G_STRIPE_TYPE_AUTOMATIC:
+ sbuf_printf(sb, "AUTOMATIC");
+ break;
+ case G_STRIPE_TYPE_MANUAL:
+ sbuf_printf(sb, "MANUAL");
+ break;
+ default:
+ sbuf_printf(sb, "UNKNOWN");
+ break;
+ }
+ sbuf_printf(sb, "</Type>\n");
+ sbuf_printf(sb, "%s<Status>Total=%u, Online=%u</Status>\n",
+ indent, sc->sc_ndisks, g_stripe_nvalid(sc));
+ sbuf_printf(sb, "%s<State>", indent);
+ if (sc->sc_provider != NULL && sc->sc_provider->error == 0)
+ sbuf_printf(sb, "UP");
+ else
+ sbuf_printf(sb, "DOWN");
+ sbuf_printf(sb, "</State>\n");
}
- sbuf_printf(sb, "</providers>\n");
- sbuf_printf(sb, "%s<status>total=%u, online=%u</status>\n", indent,
- sc->sc_ndisks, g_stripe_nvalid(sc));
- if (pp->error == 0)
- sbuf_printf(sb, "%s<state>UP</state>\n", indent);
- else
- sbuf_printf(sb, "%s<state>DOWN</state>\n", indent);
}
DECLARE_GEOM_CLASS(g_stripe_class, g_stripe);
OpenPOWER on IntegriCloud