summaryrefslogtreecommitdiffstats
path: root/sys/dev/md
diff options
context:
space:
mode:
authorwkoszek <wkoszek@FreeBSD.org>2006-03-26 23:21:11 +0000
committerwkoszek <wkoszek@FreeBSD.org>2006-03-26 23:21:11 +0000
commit2a5afd7475409bb7cdb8473d9d796d7b58572117 (patch)
tree6b0b81c9335360ab57fddb6cc097e81ba548f541 /sys/dev/md
parent096cd178c10e12657491e485585f6e930deb4c48 (diff)
downloadFreeBSD-src-2a5afd7475409bb7cdb8473d9d796d7b58572117.zip
FreeBSD-src-2a5afd7475409bb7cdb8473d9d796d7b58572117.tar.gz
Teach md(4) and mdconfig(8) how to understand XML. Right now there won't be
a problem with listing large number of md(4) devices. Either 'list' or 'query' mode uses XML. Additionally, new functionality was introduced. It's possible to pass multiple devices to -u: # ./mdconfig -l -u md0,md1 Approved by: cognet (mentor)
Diffstat (limited to 'sys/dev/md')
-rw-r--r--sys/dev/md/md.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c
index bc99827..f91a93e 100644
--- a/sys/dev/md/md.c
+++ b/sys/dev/md/md.c
@@ -120,6 +120,8 @@ static g_init_t g_md_init;
static g_fini_t g_md_fini;
static g_start_t g_md_start;
static g_access_t g_md_access;
+static void g_md_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
+ struct g_consumer *cp __unused, struct g_provider *pp);
static int mdunits;
static struct cdev *status_dev = 0;
@@ -140,6 +142,7 @@ struct g_class g_md_class = {
.fini = g_md_fini,
.start = g_md_start,
.access = g_md_access,
+ .dumpconf = g_md_dumpconf,
};
DECLARE_GEOM_CLASS(g_md_class, g_md);
@@ -1178,6 +1181,65 @@ g_md_init(struct g_class *mp __unused)
}
static void
+g_md_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
+ struct g_consumer *cp __unused, struct g_provider *pp)
+{
+ struct md_s *mp;
+ char *type;
+
+ mp = gp->softc;
+ if (mp == NULL)
+ return;
+
+ switch (mp->type) {
+ case MD_MALLOC:
+ type = "malloc";
+ break;
+ case MD_PRELOAD:
+ type = "preload";
+ break;
+ case MD_VNODE:
+ type = "vnode";
+ break;
+ case MD_SWAP:
+ type = "swap";
+ break;
+ default:
+ type = "unknown";
+ break;
+ }
+
+ if (pp != NULL) {
+ if (indent == NULL) {
+ sbuf_printf(sb, " u %d", mp->unit);
+ sbuf_printf(sb, " s %ju", (uintmax_t) mp->sectorsize);
+ sbuf_printf(sb, " f %ju", (uintmax_t) mp->fwheads);
+ sbuf_printf(sb, " fs %ju", (uintmax_t) mp->fwsectors);
+ sbuf_printf(sb, " l %ju", (uintmax_t) mp->mediasize);
+ sbuf_printf(sb, " t %s", type);
+ if (mp->type == MD_VNODE && mp->vnode != NULL)
+ sbuf_printf(sb, " file %s", mp->file);
+ } else {
+ sbuf_printf(sb, "%s<unit>%d</unit>\n", indent,
+ mp->unit);
+ sbuf_printf(sb, "%s<sectorsize>%ju</sectorsize>\n",
+ indent, (uintmax_t) mp->sectorsize);
+ sbuf_printf(sb, "%s<fwheads>%ju</fwheads>\n",
+ indent, (uintmax_t) mp->fwheads);
+ sbuf_printf(sb, "%s<fwsectors>%ju</fwsectors>\n",
+ indent, (uintmax_t) mp->fwsectors);
+ sbuf_printf(sb, "%s<length>%ju</length>\n",
+ indent, (uintmax_t) mp->mediasize);
+ sbuf_printf(sb, "%s<type>%s</type>\n", indent,
+ type);
+ if (mp->type == MD_VNODE && mp->vnode != NULL)
+ sbuf_printf(sb, "%s<file>%s</file>\n",
+ indent, mp->file);
+ }
+ }
+}
+
+static void
g_md_fini(struct g_class *mp __unused)
{
OpenPOWER on IntegriCloud