summaryrefslogtreecommitdiffstats
path: root/sbin/geom/class/stripe/geom_stripe.c
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2004-08-09 11:29:42 +0000
committerpjd <pjd@FreeBSD.org>2004-08-09 11:29:42 +0000
commita98f2557009185f782b7d19053597e414ef9fb3a (patch)
tree46ee8e035f9336efb5b00d5af5c35f6afc1a3c96 /sbin/geom/class/stripe/geom_stripe.c
parent62b3492f0e226a7641b06a30d62538c7d1f6fb17 (diff)
downloadFreeBSD-src-a98f2557009185f782b7d19053597e414ef9fb3a.zip
FreeBSD-src-a98f2557009185f782b7d19053597e414ef9fb3a.tar.gz
- Introduce option for hardcoding providers' names into metadata.
It allows to fix problems when last provider's sector is shared between few providers. - Bump version number for CONCAT and STRIPE and add code for backward compatibility. - Do not bump version number of MIRROR, as it wasn't officially introduced yet. Even if someone started to play with it, there is no big deal, because wrong MD5 sum of metadata will deny those providers. - Update manual pages. - Add version history to g_(stripe|concat).h files.
Diffstat (limited to 'sbin/geom/class/stripe/geom_stripe.c')
-rw-r--r--sbin/geom/class/stripe/geom_stripe.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/sbin/geom/class/stripe/geom_stripe.c b/sbin/geom/class/stripe/geom_stripe.c
index 5b6a9a3..9c47ef4 100644
--- a/sbin/geom/class/stripe/geom_stripe.c
+++ b/sbin/geom/class/stripe/geom_stripe.c
@@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <errno.h>
+#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
@@ -69,6 +70,7 @@ struct g_command class_commands[] = {
{ "dump", 0, stripe_main, G_NULL_OPTS },
{ "label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, stripe_main,
{
+ { 'h', "hardcode", NULL, G_TYPE_NONE },
{ 's', "stripesize", &stripesize, G_TYPE_NUMBER },
G_OPT_SENTINEL
}
@@ -89,12 +91,12 @@ void
usage(const char *name)
{
- fprintf(stderr, "usage: %s create [-v] [-s stripesize] <name> <dev1> <dev2> [dev3 [...]]\n", name);
- fprintf(stderr, " %s destroy [-fv] <name> [name2 [...]]\n", 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);
+ fprintf(stderr, "usage: %s create [-hv] [-s stripesize] <name> <prov> <prov> [prov [...]]\n", name);
+ fprintf(stderr, " %s destroy [-fv] <name> [name [...]]\n", name);
+ fprintf(stderr, " %s label [-hv] [-s stripesize] <name> <prov> <prov> [prov [...]]\n", name);
+ fprintf(stderr, " %s stop [-fv] <name> [name [...]]\n", name);
+ fprintf(stderr, " %s clear [-v] <prov> [prov [...]]\n", name);
+ fprintf(stderr, " %s dump <prov> [prov [...]]\n", name);
}
static void
@@ -129,7 +131,7 @@ stripe_label(struct gctl_req *req)
const char *name;
char param[16];
unsigned i;
- int *nargs, error;
+ int *hardcode, *nargs, error;
nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
if (nargs == NULL) {
@@ -140,6 +142,11 @@ stripe_label(struct gctl_req *req)
gctl_error(req, "Too few arguments.");
return;
}
+ hardcode = gctl_get_paraml(req, "hardcode", sizeof(*hardcode));
+ if (hardcode == NULL) {
+ gctl_error(req, "No '%s' argument.", "hardcode");
+ return;
+ }
/*
* Clear last sector first to spoil all components if device exists.
@@ -181,6 +188,13 @@ stripe_label(struct gctl_req *req)
name = gctl_get_asciiparam(req, param);
md.md_no = i - 1;
+ if (!*hardcode)
+ bzero(md.md_provider, sizeof(md.md_provider));
+ else {
+ if (strncmp(name, _PATH_DEV, strlen(_PATH_DEV)) == 0)
+ name += strlen(_PATH_DEV);
+ strlcpy(md.md_provider, name, sizeof(md.md_provider));
+ }
stripe_metadata_encode(&md, sector);
error = g_metadata_store(name, sector, sizeof(sector));
if (error != 0) {
@@ -239,6 +253,7 @@ stripe_metadata_dump(const struct g_stripe_metadata *md)
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);
+ printf(" Hardcoded provider: %s\n", md->md_provider);
}
static void
OpenPOWER on IntegriCloud