[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/geom/geom_dump.c

Version: -  FREEBSD  -  FREEBSD10  -  FREEBSD9  -  FREEBSD92  -  FREEBSD91  -  FREEBSD90  -  FREEBSD8  -  FREEBSD82  -  FREEBSD81  -  FREEBSD80  -  FREEBSD7  -  FREEBSD74  -  FREEBSD73  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  cheribsd  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1  -  FREEBSD-LIBC  -  FREEBSD8-LIBC  -  FREEBSD7-LIBC  -  FREEBSD6-LIBC  -  GLIBC27 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2002 Poul-Henning Kamp
    3  * Copyright (c) 2002 Networks Associates Technology, Inc.
    4  * All rights reserved.
    5  *
    6  * This software was developed for the FreeBSD Project by Poul-Henning Kamp
    7  * and NAI Labs, the Security Research Division of Network Associates, Inc.
    8  * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
    9  * DARPA CHATS research program.
   10  *
   11  * Redistribution and use in source and binary forms, with or without
   12  * modification, are permitted provided that the following conditions
   13  * are met:
   14  * 1. Redistributions of source code must retain the above copyright
   15  *    notice, this list of conditions and the following disclaimer.
   16  * 2. Redistributions in binary form must reproduce the above copyright
   17  *    notice, this list of conditions and the following disclaimer in the
   18  *    documentation and/or other materials provided with the distribution.
   19  * 3. The names of the authors may not be used to endorse or promote
   20  *    products derived from this software without specific prior written
   21  *    permission.
   22  *
   23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   33  * SUCH DAMAGE.
   34  */
   35 
   36 #include <sys/cdefs.h>
   37 __FBSDID("$FreeBSD$");
   38 
   39 #include <sys/param.h>
   40 #include <sys/sbuf.h>
   41 #include <sys/systm.h>
   42 #include <sys/malloc.h>
   43 #include <machine/stdarg.h>
   44 
   45 #include <geom/geom.h>
   46 #include <geom/geom_int.h>
   47 
   48 
   49 static void
   50 g_confdot_consumer(struct sbuf *sb, struct g_consumer *cp)
   51 {
   52 
   53         sbuf_printf(sb, "z%p [label=\"r%dw%de%d\"];\n",
   54             cp, cp->acr, cp->acw, cp->ace);
   55         if (cp->provider)
   56                 sbuf_printf(sb, "z%p -> z%p;\n", cp, cp->provider);
   57 }
   58 
   59 static void
   60 g_confdot_provider(struct sbuf *sb, struct g_provider *pp)
   61 {
   62 
   63         sbuf_printf(sb, "z%p [shape=hexagon,label=\"%s\\nr%dw%de%d\\nerr#%d\"];\n",
   64             pp, pp->name, pp->acr, pp->acw, pp->ace, pp->error);
   65 }
   66 
   67 static void
   68 g_confdot_geom(struct sbuf *sb, struct g_geom *gp)
   69 {
   70         struct g_consumer *cp;
   71         struct g_provider *pp;
   72 
   73         sbuf_printf(sb, "z%p [shape=box,label=\"%s\\n%s\\nr#%d\"];\n",
   74             gp, gp->class->name, gp->name, gp->rank);
   75         LIST_FOREACH(cp, &gp->consumer, consumer) {
   76                 g_confdot_consumer(sb, cp);
   77                 sbuf_printf(sb, "z%p -> z%p;\n", gp, cp);
   78         }
   79 
   80         LIST_FOREACH(pp, &gp->provider, provider) {
   81                 g_confdot_provider(sb, pp);
   82                 sbuf_printf(sb, "z%p -> z%p;\n", pp, gp);
   83         }
   84 }
   85 
   86 static void
   87 g_confdot_class(struct sbuf *sb, struct g_class *mp)
   88 {
   89         struct g_geom *gp;
   90 
   91         LIST_FOREACH(gp, &mp->geom, geom)
   92                 g_confdot_geom(sb, gp);
   93 }
   94 
   95 void
   96 g_confdot(void *p, int flag )
   97 {
   98         struct g_class *mp;
   99         struct sbuf *sb;
  100 
  101         KASSERT(flag != EV_CANCEL, ("g_confdot was cancelled"));
  102         sb = p;
  103         g_topology_assert();
  104         sbuf_printf(sb, "digraph geom {\n");
  105         LIST_FOREACH(mp, &g_classes, class)
  106                 g_confdot_class(sb, mp);
  107         sbuf_printf(sb, "};\n");
  108         sbuf_finish(sb);
  109 }
  110 
  111 static void
  112 g_conftxt_geom(struct sbuf *sb, struct g_geom *gp, int level)
  113 {
  114         struct g_provider *pp;
  115         struct g_consumer *cp;
  116 
  117         if (gp->flags & G_GEOM_WITHER)
  118                 return;
  119         LIST_FOREACH(pp, &gp->provider, provider) {
  120                 sbuf_printf(sb, "%d %s %s %ju %u", level, gp->class->name,
  121                     pp->name, (uintmax_t)pp->mediasize, pp->sectorsize);
  122                 if (gp->dumpconf != NULL)
  123                         gp->dumpconf(sb, NULL, gp, NULL, pp);
  124                 sbuf_printf(sb, "\n");
  125                 LIST_FOREACH(cp, &pp->consumers, consumers)
  126                         g_conftxt_geom(sb, cp->geom, level + 1);
  127         }
  128 }
  129 
  130 static void
  131 g_conftxt_class(struct sbuf *sb, struct g_class *mp)
  132 {
  133         struct g_geom *gp;
  134 
  135         LIST_FOREACH(gp, &mp->geom, geom)
  136                 g_conftxt_geom(sb, gp, 0);
  137 }
  138 
  139 void
  140 g_conftxt(void *p, int flag)
  141 {
  142         struct g_class *mp;
  143         struct sbuf *sb;
  144 
  145         KASSERT(flag != EV_CANCEL, ("g_conftxt was cancelled"));
  146         sb = p;
  147         g_topology_assert();
  148         LIST_FOREACH(mp, &g_classes, class)
  149                 if (!strcmp(mp->name, "DISK"))
  150                         break;
  151         if (mp != NULL)
  152                 g_conftxt_class(sb, mp);
  153         sbuf_finish(sb);
  154 }
  155 
  156 
  157 static void
  158 g_conf_consumer(struct sbuf *sb, struct g_consumer *cp)
  159 {
  160 
  161         sbuf_printf(sb, "\t<consumer id=\"%p\">\n", cp);
  162         sbuf_printf(sb, "\t  <geom ref=\"%p\"/>\n", cp->geom);
  163         if (cp->provider != NULL)
  164                 sbuf_printf(sb, "\t  <provider ref=\"%p\"/>\n", cp->provider);
  165         sbuf_printf(sb, "\t  <mode>r%dw%de%d</mode>\n",
  166             cp->acr, cp->acw, cp->ace);
  167         if (cp->geom->flags & G_GEOM_WITHER)
  168                 ;
  169         else if (cp->geom->dumpconf != NULL) {
  170                 sbuf_printf(sb, "\t  <config>\n");
  171                 cp->geom->dumpconf(sb, "\t    ", cp->geom, cp, NULL);
  172                 sbuf_printf(sb, "\t  </config>\n");
  173         }
  174         sbuf_printf(sb, "\t</consumer>\n");
  175 }
  176 
  177 static void
  178 g_conf_provider(struct sbuf *sb, struct g_provider *pp)
  179 {
  180 
  181         sbuf_printf(sb, "\t<provider id=\"%p\">\n", pp);
  182         sbuf_printf(sb, "\t  <geom ref=\"%p\"/>\n", pp->geom);
  183         sbuf_printf(sb, "\t  <mode>r%dw%de%d</mode>\n",
  184             pp->acr, pp->acw, pp->ace);
  185         sbuf_printf(sb, "\t  <name>%s</name>\n", pp->name);
  186         sbuf_printf(sb, "\t  <mediasize>%jd</mediasize>\n",
  187             (intmax_t)pp->mediasize);
  188         sbuf_printf(sb, "\t  <sectorsize>%u</sectorsize>\n", pp->sectorsize);
  189         if (pp->geom->flags & G_GEOM_WITHER)
  190                 ;
  191         else if (pp->geom->dumpconf != NULL) {
  192                 sbuf_printf(sb, "\t  <config>\n");
  193                 pp->geom->dumpconf(sb, "\t    ", pp->geom, NULL, pp);
  194                 sbuf_printf(sb, "\t  </config>\n");
  195         }
  196         sbuf_printf(sb, "\t</provider>\n");
  197 }
  198 
  199 
  200 static void
  201 g_conf_geom(struct sbuf *sb, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp)
  202 {
  203         struct g_consumer *cp2;
  204         struct g_provider *pp2;
  205 
  206         sbuf_printf(sb, "    <geom id=\"%p\">\n", gp);
  207         sbuf_printf(sb, "      <class ref=\"%p\"/>\n", gp->class);
  208         sbuf_printf(sb, "      <name>%s</name>\n", gp->name);
  209         sbuf_printf(sb, "      <rank>%d</rank>\n", gp->rank);
  210         if (gp->flags & G_GEOM_WITHER)
  211                 sbuf_printf(sb, "      <wither/>\n");
  212         else if (gp->dumpconf != NULL) {
  213                 sbuf_printf(sb, "      <config>\n");
  214                 gp->dumpconf(sb, "\t", gp, NULL, NULL);
  215                 sbuf_printf(sb, "      </config>\n");
  216         }
  217         LIST_FOREACH(cp2, &gp->consumer, consumer) {
  218                 if (cp != NULL && cp != cp2)
  219                         continue;
  220                 g_conf_consumer(sb, cp2);
  221         }
  222 
  223         LIST_FOREACH(pp2, &gp->provider, provider) {
  224                 if (pp != NULL && pp != pp2)
  225                         continue;
  226                 g_conf_provider(sb, pp2);
  227         }
  228         sbuf_printf(sb, "    </geom>\n");
  229 }
  230 
  231 static void
  232 g_conf_class(struct sbuf *sb, struct g_class *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp)
  233 {
  234         struct g_geom *gp2;
  235 
  236         sbuf_printf(sb, "  <class id=\"%p\">\n", mp);
  237         sbuf_printf(sb, "    <name>%s</name>\n", mp->name);
  238         LIST_FOREACH(gp2, &mp->geom, geom) {
  239                 if (gp != NULL && gp != gp2)
  240                         continue;
  241                 g_conf_geom(sb, gp2, pp, cp);
  242         }
  243         sbuf_printf(sb, "  </class>\n");
  244 }
  245 
  246 void
  247 g_conf_specific(struct sbuf *sb, struct g_class *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp)
  248 {
  249         struct g_class *mp2;
  250 
  251         g_topology_assert();
  252         sbuf_printf(sb, "<mesh>\n");
  253         LIST_FOREACH(mp2, &g_classes, class) {
  254                 if (mp != NULL && mp != mp2)
  255                         continue;
  256                 g_conf_class(sb, mp2, gp, pp, cp);
  257         }
  258         sbuf_printf(sb, "</mesh>\n");
  259         sbuf_finish(sb);
  260 }
  261 
  262 void
  263 g_confxml(void *p, int flag)
  264 {
  265 
  266         KASSERT(flag != EV_CANCEL, ("g_confxml was cancelled"));
  267         g_topology_assert();
  268         g_conf_specific(p, NULL, NULL, NULL, NULL);
  269 }
  270 
  271 void
  272 g_trace(int level, const char *fmt, ...)
  273 {
  274         va_list ap;
  275 
  276         if (!(g_debugflags & level))
  277                 return;
  278         va_start(ap, fmt);
  279         vprintf(fmt, ap);
  280         va_end(ap);
  281         printf("\n");
  282 }

Cache object: 13e1619ddefb664418fab02e90fc6791


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.