summaryrefslogtreecommitdiffstats
path: root/sbin/geom/class/stripe
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2004-07-18 08:00:30 +0000
committerpjd <pjd@FreeBSD.org>2004-07-18 08:00:30 +0000
commitdc0d79acb9ae46349d52709494439489723bcf99 (patch)
tree56759b660cfd0721069bfd93f9afb21b36c16e60 /sbin/geom/class/stripe
parent423139e3683de5f3751e84c86119b44eaa4acbf9 (diff)
downloadFreeBSD-src-dc0d79acb9ae46349d52709494439489723bcf99.zip
FreeBSD-src-dc0d79acb9ae46349d52709494439489723bcf99.tar.gz
MFp4: Add 'dump' command to gconcat(8), glabel(8) and gstripe(8) which allow
to dump metadata from given components.
Diffstat (limited to 'sbin/geom/class/stripe')
-rw-r--r--sbin/geom/class/stripe/geom_stripe.c57
-rw-r--r--sbin/geom/class/stripe/gstripe.86
2 files changed, 62 insertions, 1 deletions
diff --git a/sbin/geom/class/stripe/geom_stripe.c b/sbin/geom/class/stripe/geom_stripe.c
index cde7613..5b6a9a3 100644
--- a/sbin/geom/class/stripe/geom_stripe.c
+++ b/sbin/geom/class/stripe/geom_stripe.c
@@ -48,8 +48,9 @@ uint32_t version = G_STRIPE_VERSION;
static intmax_t stripesize = 4096;
static void stripe_main(struct gctl_req *req, unsigned flags);
-static void stripe_label(struct gctl_req *req);
static void stripe_clear(struct gctl_req *req);
+static void stripe_dump(struct gctl_req *req);
+static void stripe_label(struct gctl_req *req);
struct g_command class_commands[] = {
{ "clear", G_FLAG_VERBOSE, stripe_main, G_NULL_OPTS },
@@ -65,6 +66,7 @@ struct g_command class_commands[] = {
G_OPT_SENTINEL
}
},
+ { "dump", 0, stripe_main, G_NULL_OPTS },
{ "label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, stripe_main,
{
{ 's', "stripesize", &stripesize, G_TYPE_NUMBER },
@@ -92,6 +94,7 @@ usage(const char *name)
fprintf(stderr, " %s label [-v] [-s stripesize] <name> <dev1> <dev2> [dev3 [...]]\n", name);
fprintf(stderr, " %s stop [-fv] <name> [name2 [...]]\n", name);
fprintf(stderr, " %s clear [-v] <dev1> [dev2 [...]]\n", name);
+ fprintf(stderr, " %s dump <dev1> [dev2 [...]]\n", name);
}
static void
@@ -111,6 +114,8 @@ stripe_main(struct gctl_req *req, unsigned flags)
stripe_label(req);
else if (strcmp(name, "clear") == 0)
stripe_clear(req);
+ else if (strcmp(name, "dump") == 0)
+ stripe_dump(req);
else
gctl_error(req, "Unknown command: %s.", name);
}
@@ -222,3 +227,53 @@ stripe_clear(struct gctl_req *req)
printf("Metadata cleared on %s.\n", name);
}
}
+
+static void
+stripe_metadata_dump(const struct g_stripe_metadata *md)
+{
+
+ printf(" Magic string: %s\n", md->md_magic);
+ printf(" Metadata version: %u\n", (u_int)md->md_version);
+ printf(" Device name: %s\n", md->md_name);
+ printf(" Device ID: %u\n", (u_int)md->md_id);
+ printf(" Disk number: %u\n", (u_int)md->md_no);
+ printf("Total number of disks: %u\n", (u_int)md->md_all);
+ printf(" Stripe size: %u\n", (u_int)md->md_stripesize);
+}
+
+static void
+stripe_dump(struct gctl_req *req)
+{
+ struct g_stripe_metadata md, tmpmd;
+ const char *name;
+ char param[16];
+ int *nargs, error, i;
+
+ nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
+ if (nargs == NULL) {
+ gctl_error(req, "No '%s' argument.", "nargs");
+ return;
+ }
+ if (*nargs < 1) {
+ gctl_error(req, "Too few arguments.");
+ return;
+ }
+
+ for (i = 0; i < *nargs; i++) {
+ snprintf(param, sizeof(param), "arg%u", i);
+ name = gctl_get_asciiparam(req, param);
+
+ error = g_metadata_read(name, (u_char *)&tmpmd, sizeof(tmpmd),
+ G_STRIPE_MAGIC);
+ if (error != 0) {
+ fprintf(stderr, "Can't read metadata from %s: %s.\n",
+ name, strerror(error));
+ gctl_error(req, "Not fully done.");
+ continue;
+ }
+ stripe_metadata_decode((u_char *)&tmpmd, &md);
+ printf("Metadata on %s:\n", name);
+ stripe_metadata_dump(&md);
+ printf("\n");
+ }
+}
diff --git a/sbin/geom/class/stripe/gstripe.8 b/sbin/geom/class/stripe/gstripe.8
index 327cd9a..59b0709 100644
--- a/sbin/geom/class/stripe/gstripe.8
+++ b/sbin/geom/class/stripe/gstripe.8
@@ -63,6 +63,10 @@
.Ar dev1
.Op Ar dev2 Op Ar ...
.Nm
+.Cm dump
+.Ar dev1
+.Op Ar dev2 Op Ar ...
+.Nm
.Cm list
.Op Ar prov Op Ar ...
.Nm
@@ -120,6 +124,8 @@ Same as
.Cm stop .
.It Cm clear
Clear metadata on the given devices.
+.It Cm dump
+Dump metadata stored on the given devices.
.It Cm list
List all or the given currently configured devices.
.It Cm load
OpenPOWER on IntegriCloud