g_concat.c (ba385d0091e181a420bae1c7361e7e8907f0a631) g_concat.c (1d723f1d518b79fdea655f82e5419ae4888ad78c)
1/*-
2 * Copyright (c) 2004 Pawel Jakub Dawidek <pjd@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 784 unchanged lines hidden (view full) ---

793static void
794g_concat_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
795 struct g_consumer *cp, struct g_provider *pp)
796{
797 struct g_concat_softc *sc;
798
799 g_topology_assert();
800 sc = gp->softc;
1/*-
2 * Copyright (c) 2004 Pawel Jakub Dawidek <pjd@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 784 unchanged lines hidden (view full) ---

793static void
794g_concat_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
795 struct g_consumer *cp, struct g_provider *pp)
796{
797 struct g_concat_softc *sc;
798
799 g_topology_assert();
800 sc = gp->softc;
801 if (sc == NULL || pp == NULL)
801 if (sc == NULL)
802 return;
802 return;
803 sbuf_printf(sb, "%s<id>%u</id>\n", indent, (u_int)sc->sc_id);
804 switch (sc->sc_type) {
805 case G_CONCAT_TYPE_AUTOMATIC:
806 sbuf_printf(sb, "%s<type>%s</type>\n", indent, "automatic");
807 break;
808 case G_CONCAT_TYPE_MANUAL:
809 sbuf_printf(sb, "%s<type>%s</type>\n", indent, "manual");
810 break;
811 default:
812 sbuf_printf(sb, "%s<type>%s</type>\n", indent, "unknown");
813 break;
803 if (pp != NULL) {
804 /* Nothing here. */
805 } else if (cp != NULL) {
806 struct g_concat_disk *disk;
807
808 disk = cp->private;
809 if (disk == NULL)
810 return;
811 sbuf_printf(sb, "%s<End>%jd</End>\n", indent,
812 (intmax_t)disk->d_end);
813 sbuf_printf(sb, "%s<Start>%jd</Start>\n", indent,
814 (intmax_t)disk->d_start);
815 } else {
816 sbuf_printf(sb, "%s<ID>%u</ID>\n", indent, (u_int)sc->sc_id);
817 sbuf_printf(sb, "%s<Type>", indent);
818 switch (sc->sc_type) {
819 case G_CONCAT_TYPE_AUTOMATIC:
820 sbuf_printf(sb, "AUTOMATIC");
821 break;
822 case G_CONCAT_TYPE_MANUAL:
823 sbuf_printf(sb, "MANUAL");
824 break;
825 default:
826 sbuf_printf(sb, "UNKNOWN");
827 break;
828 }
829 sbuf_printf(sb, "</Type>\n");
830 sbuf_printf(sb, "%s<Status>Total=%u, Online=%u</Status>\n",
831 indent, sc->sc_ndisks, g_concat_nvalid(sc));
832 sbuf_printf(sb, "%s<State>", indent);
833 if (sc->sc_provider != NULL && sc->sc_provider->error == 0)
834 sbuf_printf(sb, "UP");
835 else
836 sbuf_printf(sb, "DOWN");
837 sbuf_printf(sb, "</State>\n");
814 }
838 }
815 sbuf_printf(sb, "%s<providers>", indent);
816 LIST_FOREACH(cp, &gp->consumer, consumer) {
817 if (cp->provider == NULL)
818 continue;
819 sbuf_printf(sb, "%s", cp->provider->name);
820 if (LIST_NEXT(cp, consumer) != NULL)
821 sbuf_printf(sb, " ");
822 }
823 sbuf_printf(sb, "</providers>\n");
824 sbuf_printf(sb, "%s<status>total=%u, online=%u</status>\n", indent,
825 sc->sc_ndisks, g_concat_nvalid(sc));
826 if (pp->error == 0)
827 sbuf_printf(sb, "%s<state>UP</state>\n", indent);
828 else
829 sbuf_printf(sb, "%s<state>DOWN</state>\n", indent);
830}
831
832DECLARE_GEOM_CLASS(g_concat_class, g_concat);
839}
840
841DECLARE_GEOM_CLASS(g_concat_class, g_concat);