summaryrefslogtreecommitdiffstats
path: root/sbin/geom/class/concat/geom_concat.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/concat/geom_concat.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/concat/geom_concat.c')
-rw-r--r--sbin/geom/class/concat/geom_concat.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/sbin/geom/class/concat/geom_concat.c b/sbin/geom/class/concat/geom_concat.c
index 49e6101..c97027a 100644
--- a/sbin/geom/class/concat/geom_concat.c
+++ b/sbin/geom/class/concat/geom_concat.c
@@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <errno.h>
+#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -59,7 +60,12 @@ struct g_command class_commands[] = {
}
},
{ "dump", 0, concat_main, G_NULL_OPTS },
- { "label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, concat_main, G_NULL_OPTS },
+ { "label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, concat_main,
+ {
+ { 'h', "hardcode", NULL, G_TYPE_NONE },
+ G_OPT_SENTINEL
+ }
+ },
{ "stop", G_FLAG_VERBOSE, NULL,
{
{ 'f', "force", NULL, G_TYPE_NONE },
@@ -77,12 +83,12 @@ void
usage(const char *name)
{
- fprintf(stderr, "usage: %s create [-v] <name> <dev1> <dev2> [dev3 [...]]\n", name);
- fprintf(stderr, " %s destroy [-fv] <name> [name2 [...]]\n", name);
- fprintf(stderr, " %s label [-v] <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 [-v] <name> <prov> <prov> [prov [...]]\n", name);
+ fprintf(stderr, " %s destroy [-fv] <name> [name [...]]\n", name);
+ fprintf(stderr, " %s label [-hv] <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
@@ -116,7 +122,7 @@ concat_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) {
@@ -127,6 +133,11 @@ concat_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.
@@ -162,6 +173,13 @@ concat_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));
+ }
concat_metadata_encode(&md, sector);
error = g_metadata_store(name, sector, sizeof(sector));
if (error != 0) {
@@ -219,6 +237,7 @@ concat_metadata_dump(const struct g_concat_metadata *md)
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(" Hardcoded provider: %s\n", md->md_provider);
}
static void
OpenPOWER on IntegriCloud