- Remove gc_argname field. It was introduced for gpart(8), but if I
understand everything correctly, we don't really need it. - Provide default numeric value as strings. This allows to simplify a lot of code. - Bump version number.
This commit is contained in:
parent
480f6157fb
commit
946e2f3595
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=212554
34
sbin/geom/class/cache/geom_cache.c
vendored
34
sbin/geom/class/cache/geom_cache.c
vendored
@ -42,10 +42,8 @@ __FBSDID("$FreeBSD$");
|
||||
uint32_t lib_version = G_LIB_VERSION;
|
||||
uint32_t version = G_CACHE_VERSION;
|
||||
|
||||
static intmax_t blocksize_label = 65536;
|
||||
static intmax_t size_label = 100;
|
||||
static intmax_t blocksize_configure = 0;
|
||||
static intmax_t size_configure = 0;
|
||||
#define GCACHE_BLOCKSIZE "65536"
|
||||
#define GCACHE_SIZE "100"
|
||||
|
||||
static void cache_main(struct gctl_req *req, unsigned flags);
|
||||
static void cache_clear(struct gctl_req *req);
|
||||
@ -53,44 +51,44 @@ static void cache_dump(struct gctl_req *req);
|
||||
static void cache_label(struct gctl_req *req);
|
||||
|
||||
struct g_command class_commands[] = {
|
||||
{ "clear", G_FLAG_VERBOSE, cache_main, G_NULL_OPTS, NULL,
|
||||
{ "clear", G_FLAG_VERBOSE, cache_main, G_NULL_OPTS,
|
||||
"[-v] prov ..."
|
||||
},
|
||||
{ "configure", G_FLAG_VERBOSE, NULL,
|
||||
{
|
||||
{ 'b', "blocksize", &blocksize_configure, G_TYPE_NUMBER },
|
||||
{ 's', "size", &size_configure, G_TYPE_NUMBER },
|
||||
{ 'b', "blocksize", "0", G_TYPE_NUMBER },
|
||||
{ 's', "size", "0", G_TYPE_NUMBER },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-v] [-b blocksize] [-s size] name"
|
||||
"[-v] [-b blocksize] [-s size] name"
|
||||
},
|
||||
{ "create", G_FLAG_VERBOSE | G_FLAG_LOADKLD, NULL,
|
||||
{
|
||||
{ 'b', "blocksize", &blocksize_label, G_TYPE_NUMBER },
|
||||
{ 's', "size", &size_label, G_TYPE_NUMBER },
|
||||
{ 'b', "blocksize", GCACHE_BLOCKSIZE, G_TYPE_NUMBER },
|
||||
{ 's', "size", GCACHE_SIZE, G_TYPE_NUMBER },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-v] [-b blocksize] [-s size] name prov"
|
||||
"[-v] [-b blocksize] [-s size] name prov"
|
||||
},
|
||||
{ "destroy", G_FLAG_VERBOSE, NULL,
|
||||
{
|
||||
{ 'f', "force", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-fv] name ..."
|
||||
"[-fv] name ..."
|
||||
},
|
||||
{ "dump", 0, cache_main, G_NULL_OPTS, NULL,
|
||||
{ "dump", 0, cache_main, G_NULL_OPTS,
|
||||
"prov ..."
|
||||
},
|
||||
{ "label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, cache_main,
|
||||
{
|
||||
{ 'b', "blocksize", &blocksize_label, G_TYPE_NUMBER },
|
||||
{ 's', "size", &size_label, G_TYPE_NUMBER },
|
||||
{ 'b', "blocksize", GCACHE_BLOCKSIZE, G_TYPE_NUMBER },
|
||||
{ 's', "size", GCACHE_SIZE, G_TYPE_NUMBER },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-v] [-b blocksize] [-s size] name prov"
|
||||
"[-v] [-b blocksize] [-s size] name prov"
|
||||
},
|
||||
{ "reset", G_FLAG_VERBOSE, NULL, G_NULL_OPTS, NULL,
|
||||
{ "reset", G_FLAG_VERBOSE, NULL, G_NULL_OPTS,
|
||||
"[-v] name ..."
|
||||
},
|
||||
{ "stop", G_FLAG_VERBOSE, NULL,
|
||||
@ -98,7 +96,7 @@ struct g_command class_commands[] = {
|
||||
{ 'f', "force", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-fv] name ..."
|
||||
"[-fv] name ..."
|
||||
},
|
||||
G_CMD_SENTINEL
|
||||
};
|
||||
|
@ -51,20 +51,20 @@ static void concat_dump(struct gctl_req *req);
|
||||
static void concat_label(struct gctl_req *req);
|
||||
|
||||
struct g_command class_commands[] = {
|
||||
{ "clear", G_FLAG_VERBOSE, concat_main, G_NULL_OPTS, NULL,
|
||||
{ "clear", G_FLAG_VERBOSE, concat_main, G_NULL_OPTS,
|
||||
"[-v] prov ..."
|
||||
},
|
||||
{ "create", G_FLAG_VERBOSE | G_FLAG_LOADKLD, NULL, G_NULL_OPTS,
|
||||
NULL, "[-v] name prov ..."
|
||||
"[-v] name prov ..."
|
||||
},
|
||||
{ "destroy", G_FLAG_VERBOSE, NULL,
|
||||
{
|
||||
{ 'f', "force", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-fv] name ..."
|
||||
"[-fv] name ..."
|
||||
},
|
||||
{ "dump", 0, concat_main, G_NULL_OPTS, NULL,
|
||||
{ "dump", 0, concat_main, G_NULL_OPTS,
|
||||
"prov ..."
|
||||
},
|
||||
{ "label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, concat_main,
|
||||
@ -72,14 +72,14 @@ struct g_command class_commands[] = {
|
||||
{ 'h', "hardcode", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-hv] name prov ..."
|
||||
"[-hv] name prov ..."
|
||||
},
|
||||
{ "stop", G_FLAG_VERBOSE, NULL,
|
||||
{
|
||||
{ 'f', "force", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-fv] name ..."
|
||||
"[-fv] name ..."
|
||||
},
|
||||
G_CMD_SENTINEL
|
||||
};
|
||||
|
@ -57,11 +57,6 @@ uint32_t version = G_ELI_VERSION;
|
||||
#define GELI_BACKUP_DIR "/var/backups/"
|
||||
#define GELI_ENC_ALGO "aes"
|
||||
|
||||
static intmax_t keylen = 0;
|
||||
static intmax_t keyno = -1;
|
||||
static intmax_t iterations = -1;
|
||||
static intmax_t sectorsize = 0;
|
||||
|
||||
static void eli_main(struct gctl_req *req, unsigned flags);
|
||||
static void eli_init(struct gctl_req *req);
|
||||
static void eli_attach(struct gctl_req *req);
|
||||
@ -102,14 +97,14 @@ struct g_command class_commands[] = {
|
||||
{ 'b', "boot", NULL, G_TYPE_BOOL },
|
||||
{ 'B', "backupfile", "", G_TYPE_STRING },
|
||||
{ 'e', "ealgo", GELI_ENC_ALGO, G_TYPE_STRING },
|
||||
{ 'i', "iterations", &iterations, G_TYPE_NUMBER },
|
||||
{ 'i', "iterations", "-1", G_TYPE_NUMBER },
|
||||
{ 'K', "newkeyfile", "", G_TYPE_STRING },
|
||||
{ 'l', "keylen", &keylen, G_TYPE_NUMBER },
|
||||
{ 'l', "keylen", "0", G_TYPE_NUMBER },
|
||||
{ 'P', "nonewpassphrase", NULL, G_TYPE_BOOL },
|
||||
{ 's', "sectorsize", §orsize, G_TYPE_NUMBER },
|
||||
{ 's', "sectorsize", "0", G_TYPE_NUMBER },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-bPv] [-a aalgo] [-B backupfile] [-e ealgo] [-i iterations] [-l keylen] [-K newkeyfile] [-s sectorsize] prov"
|
||||
"[-bPv] [-a aalgo] [-B backupfile] [-e ealgo] [-i iterations] [-l keylen] [-K newkeyfile] [-s sectorsize] prov"
|
||||
},
|
||||
{ "label", G_FLAG_VERBOSE, eli_main,
|
||||
{
|
||||
@ -117,14 +112,14 @@ struct g_command class_commands[] = {
|
||||
{ 'b', "boot", NULL, G_TYPE_BOOL },
|
||||
{ 'B', "backupfile", "", G_TYPE_STRING },
|
||||
{ 'e', "ealgo", GELI_ENC_ALGO, G_TYPE_STRING },
|
||||
{ 'i', "iterations", &iterations, G_TYPE_NUMBER },
|
||||
{ 'i', "iterations", "-1", G_TYPE_NUMBER },
|
||||
{ 'K', "newkeyfile", "", G_TYPE_STRING },
|
||||
{ 'l', "keylen", &keylen, G_TYPE_NUMBER },
|
||||
{ 'l', "keylen", "0", G_TYPE_NUMBER },
|
||||
{ 'P', "nonewpassphrase", NULL, G_TYPE_BOOL },
|
||||
{ 's', "sectorsize", §orsize, G_TYPE_NUMBER },
|
||||
{ 's', "sectorsize", "0", G_TYPE_NUMBER },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "- an alias for 'init'"
|
||||
"- an alias for 'init'"
|
||||
},
|
||||
{ "attach", G_FLAG_VERBOSE | G_FLAG_LOADKLD, eli_main,
|
||||
{
|
||||
@ -134,7 +129,7 @@ struct g_command class_commands[] = {
|
||||
{ 'r', "readonly", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-dprv] [-k keyfile] prov"
|
||||
"[-dprv] [-k keyfile] prov"
|
||||
},
|
||||
{ "detach", 0, NULL,
|
||||
{
|
||||
@ -142,7 +137,7 @@ struct g_command class_commands[] = {
|
||||
{ 'l', "last", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-fl] prov ..."
|
||||
"[-fl] prov ..."
|
||||
},
|
||||
{ "stop", 0, NULL,
|
||||
{
|
||||
@ -150,18 +145,18 @@ struct g_command class_commands[] = {
|
||||
{ 'l', "last", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "- an alias for 'detach'"
|
||||
"- an alias for 'detach'"
|
||||
},
|
||||
{ "onetime", G_FLAG_VERBOSE | G_FLAG_LOADKLD, NULL,
|
||||
{
|
||||
{ 'a', "aalgo", "", G_TYPE_STRING },
|
||||
{ 'd', "detach", NULL, G_TYPE_BOOL },
|
||||
{ 'e', "ealgo", GELI_ENC_ALGO, G_TYPE_STRING },
|
||||
{ 'l', "keylen", &keylen, G_TYPE_NUMBER },
|
||||
{ 's', "sectorsize", §orsize, G_TYPE_NUMBER },
|
||||
{ 'l', "keylen", "0", G_TYPE_NUMBER },
|
||||
{ 's', "sectorsize", "0", G_TYPE_NUMBER },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-d] [-a aalgo] [-e ealgo] [-l keylen] [-s sectorsize] prov"
|
||||
"[-d] [-a aalgo] [-e ealgo] [-l keylen] [-s sectorsize] prov"
|
||||
},
|
||||
{ "configure", G_FLAG_VERBOSE, eli_main,
|
||||
{
|
||||
@ -169,46 +164,46 @@ struct g_command class_commands[] = {
|
||||
{ 'B', "noboot", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-bB] prov ..."
|
||||
"[-bB] prov ..."
|
||||
},
|
||||
{ "setkey", G_FLAG_VERBOSE, eli_main,
|
||||
{
|
||||
{ 'i', "iterations", &iterations, G_TYPE_NUMBER },
|
||||
{ 'i', "iterations", "-1", G_TYPE_NUMBER },
|
||||
{ 'k', "keyfile", "", G_TYPE_STRING },
|
||||
{ 'K', "newkeyfile", "", G_TYPE_STRING },
|
||||
{ 'n', "keyno", &keyno, G_TYPE_NUMBER },
|
||||
{ 'n', "keyno", "-1", G_TYPE_NUMBER },
|
||||
{ 'p', "nopassphrase", NULL, G_TYPE_BOOL },
|
||||
{ 'P', "nonewpassphrase", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-pPv] [-n keyno] [-i iterations] [-k keyfile] [-K newkeyfile] prov"
|
||||
"[-pPv] [-n keyno] [-i iterations] [-k keyfile] [-K newkeyfile] prov"
|
||||
},
|
||||
{ "delkey", G_FLAG_VERBOSE, eli_main,
|
||||
{
|
||||
{ 'a', "all", NULL, G_TYPE_BOOL },
|
||||
{ 'f', "force", NULL, G_TYPE_BOOL },
|
||||
{ 'n', "keyno", &keyno, G_TYPE_NUMBER },
|
||||
{ 'n', "keyno", "-1", G_TYPE_NUMBER },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-afv] [-n keyno] prov"
|
||||
"[-afv] [-n keyno] prov"
|
||||
},
|
||||
{ "kill", G_FLAG_VERBOSE, eli_main,
|
||||
{
|
||||
{ 'a', "all", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-av] [prov ...]"
|
||||
"[-av] [prov ...]"
|
||||
},
|
||||
{ "backup", G_FLAG_VERBOSE, eli_main, G_NULL_OPTS, NULL,
|
||||
{ "backup", G_FLAG_VERBOSE, eli_main, G_NULL_OPTS,
|
||||
"[-v] prov file"
|
||||
},
|
||||
{ "restore", G_FLAG_VERBOSE, eli_main, G_NULL_OPTS, NULL,
|
||||
{ "restore", G_FLAG_VERBOSE, eli_main, G_NULL_OPTS,
|
||||
"[-v] file prov"
|
||||
},
|
||||
{ "clear", G_FLAG_VERBOSE, eli_main, G_NULL_OPTS, NULL,
|
||||
{ "clear", G_FLAG_VERBOSE, eli_main, G_NULL_OPTS,
|
||||
"[-v] prov ..."
|
||||
},
|
||||
{ "dump", G_FLAG_VERBOSE, eli_main, G_NULL_OPTS, NULL,
|
||||
{ "dump", G_FLAG_VERBOSE, eli_main, G_NULL_OPTS,
|
||||
"[-v] prov ..."
|
||||
},
|
||||
G_CMD_SENTINEL
|
||||
|
@ -47,18 +47,16 @@ __FBSDID("$FreeBSD$");
|
||||
uint32_t lib_version = G_LIB_VERSION;
|
||||
uint32_t version = G_JOURNAL_VERSION;
|
||||
|
||||
static intmax_t default_jsize = -1;
|
||||
|
||||
static void journal_main(struct gctl_req *req, unsigned flags);
|
||||
static void journal_clear(struct gctl_req *req);
|
||||
static void journal_dump(struct gctl_req *req);
|
||||
static void journal_label(struct gctl_req *req);
|
||||
|
||||
struct g_command class_commands[] = {
|
||||
{ "clear", G_FLAG_VERBOSE, journal_main, G_NULL_OPTS, NULL,
|
||||
{ "clear", G_FLAG_VERBOSE, journal_main, G_NULL_OPTS,
|
||||
"[-v] prov ..."
|
||||
},
|
||||
{ "dump", 0, journal_main, G_NULL_OPTS, NULL,
|
||||
{ "dump", 0, journal_main, G_NULL_OPTS,
|
||||
"prov ..."
|
||||
},
|
||||
{ "label", G_FLAG_VERBOSE, journal_main,
|
||||
@ -66,19 +64,19 @@ struct g_command class_commands[] = {
|
||||
{ 'c', "checksum", NULL, G_TYPE_BOOL },
|
||||
{ 'f', "force", NULL, G_TYPE_BOOL },
|
||||
{ 'h', "hardcode", NULL, G_TYPE_BOOL },
|
||||
{ 's', "jsize", &default_jsize, G_TYPE_NUMBER },
|
||||
{ 's', "jsize", "-1", G_TYPE_NUMBER },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-cfhv] [-s jsize] dataprov [jprov]"
|
||||
"[-cfhv] [-s jsize] dataprov [jprov]"
|
||||
},
|
||||
{ "stop", G_FLAG_VERBOSE, NULL,
|
||||
{
|
||||
{ 'f', "force", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-fv] name ..."
|
||||
"[-fv] name ..."
|
||||
},
|
||||
{ "sync", G_FLAG_VERBOSE, NULL, G_NULL_OPTS, NULL,
|
||||
{ "sync", G_FLAG_VERBOSE, NULL, G_NULL_OPTS,
|
||||
"[-v]"
|
||||
},
|
||||
G_CMD_SENTINEL
|
||||
|
@ -55,31 +55,31 @@ static void label_dump(struct gctl_req *req);
|
||||
static void label_label(struct gctl_req *req);
|
||||
|
||||
struct g_command PUBSYM(class_commands)[] = {
|
||||
{ "clear", G_FLAG_VERBOSE, label_main, G_NULL_OPTS, NULL,
|
||||
{ "clear", G_FLAG_VERBOSE, label_main, G_NULL_OPTS,
|
||||
"[-v] dev ..."
|
||||
},
|
||||
{ "create", G_FLAG_VERBOSE | G_FLAG_LOADKLD, NULL, G_NULL_OPTS,
|
||||
NULL, "[-v] name dev"
|
||||
"[-v] name dev"
|
||||
},
|
||||
{ "destroy", G_FLAG_VERBOSE, NULL,
|
||||
{
|
||||
{ 'f', "force", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-fv] name ..."
|
||||
"[-fv] name ..."
|
||||
},
|
||||
{ "dump", 0, label_main, G_NULL_OPTS, NULL,
|
||||
{ "dump", 0, label_main, G_NULL_OPTS,
|
||||
"dev ..."
|
||||
},
|
||||
{ "label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, label_main, G_NULL_OPTS,
|
||||
NULL, "[-v] name dev"
|
||||
"[-v] name dev"
|
||||
},
|
||||
{ "stop", G_FLAG_VERBOSE, NULL,
|
||||
{
|
||||
{ 'f', "force", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-fv] name ..."
|
||||
"[-fv] name ..."
|
||||
},
|
||||
G_CMD_SENTINEL
|
||||
};
|
||||
|
@ -45,9 +45,8 @@ uint32_t lib_version = G_LIB_VERSION;
|
||||
uint32_t version = G_MIRROR_VERSION;
|
||||
|
||||
#define GMIRROR_BALANCE "load"
|
||||
|
||||
static intmax_t label_slice = 4096, configure_slice = -1;
|
||||
static intmax_t insert_priority = 0, configure_priority = -1;
|
||||
#define GMIRROR_SLICE "4096"
|
||||
#define GMIRROR_PRIORITY "0"
|
||||
|
||||
static void mirror_main(struct gctl_req *req, unsigned flags);
|
||||
static void mirror_activate(struct gctl_req *req);
|
||||
@ -56,10 +55,10 @@ static void mirror_dump(struct gctl_req *req);
|
||||
static void mirror_label(struct gctl_req *req);
|
||||
|
||||
struct g_command class_commands[] = {
|
||||
{ "activate", G_FLAG_VERBOSE, mirror_main, G_NULL_OPTS, NULL,
|
||||
{ "activate", G_FLAG_VERBOSE, mirror_main, G_NULL_OPTS,
|
||||
"[-v] name prov ..."
|
||||
},
|
||||
{ "clear", G_FLAG_VERBOSE, mirror_main, G_NULL_OPTS, NULL,
|
||||
{ "clear", G_FLAG_VERBOSE, mirror_main, G_NULL_OPTS,
|
||||
"[-v] prov ..."
|
||||
},
|
||||
{ "configure", G_FLAG_VERBOSE, NULL,
|
||||
@ -71,20 +70,20 @@ struct g_command class_commands[] = {
|
||||
{ 'F', "nofailsync", NULL, G_TYPE_BOOL },
|
||||
{ 'h', "hardcode", NULL, G_TYPE_BOOL },
|
||||
{ 'n', "noautosync", NULL, G_TYPE_BOOL },
|
||||
{ 'p', "priority", &configure_priority, G_TYPE_NUMBER },
|
||||
{ 's', "slice", &configure_slice, G_TYPE_NUMBER },
|
||||
{ 'p', "priority", "-1", G_TYPE_NUMBER },
|
||||
{ 's', "slice", "-1", G_TYPE_NUMBER },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-adfFhnv] [-b balance] [-s slice] name\n"
|
||||
"[-adfFhnv] [-b balance] [-s slice] name\n"
|
||||
"[-v] -p priority name prov"
|
||||
},
|
||||
{ "deactivate", G_FLAG_VERBOSE, NULL, G_NULL_OPTS, NULL,
|
||||
{ "deactivate", G_FLAG_VERBOSE, NULL, G_NULL_OPTS,
|
||||
"[-v] name prov ..."
|
||||
},
|
||||
{ "dump", 0, mirror_main, G_NULL_OPTS, NULL,
|
||||
{ "dump", 0, mirror_main, G_NULL_OPTS,
|
||||
"prov ..."
|
||||
},
|
||||
{ "forget", G_FLAG_VERBOSE, NULL, G_NULL_OPTS, NULL,
|
||||
{ "forget", G_FLAG_VERBOSE, NULL, G_NULL_OPTS,
|
||||
"name ..."
|
||||
},
|
||||
{ "label", G_FLAG_VERBOSE, mirror_main,
|
||||
@ -93,24 +92,24 @@ struct g_command class_commands[] = {
|
||||
{ 'F', "nofailsync", NULL, G_TYPE_BOOL },
|
||||
{ 'h', "hardcode", NULL, G_TYPE_BOOL },
|
||||
{ 'n', "noautosync", NULL, G_TYPE_BOOL },
|
||||
{ 's', "slice", &label_slice, G_TYPE_NUMBER },
|
||||
{ 's', "slice", GMIRROR_SLICE, G_TYPE_NUMBER },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-Fhnv] [-b balance] [-s slice] name prov ..."
|
||||
"[-Fhnv] [-b balance] [-s slice] name prov ..."
|
||||
},
|
||||
{ "insert", G_FLAG_VERBOSE, NULL,
|
||||
{
|
||||
{ 'h', "hardcode", NULL, G_TYPE_BOOL },
|
||||
{ 'i', "inactive", NULL, G_TYPE_BOOL },
|
||||
{ 'p', "priority", &insert_priority, G_TYPE_NUMBER },
|
||||
{ 'p', "priority", GMIRROR_PRIORITY, G_TYPE_NUMBER },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-hiv] [-p priority] name prov ..."
|
||||
"[-hiv] [-p priority] name prov ..."
|
||||
},
|
||||
{ "rebuild", G_FLAG_VERBOSE, NULL, G_NULL_OPTS, NULL,
|
||||
{ "rebuild", G_FLAG_VERBOSE, NULL, G_NULL_OPTS,
|
||||
"[-v] name prov ..."
|
||||
},
|
||||
{ "remove", G_FLAG_VERBOSE, NULL, G_NULL_OPTS, NULL,
|
||||
{ "remove", G_FLAG_VERBOSE, NULL, G_NULL_OPTS,
|
||||
"[-v] name prov ..."
|
||||
},
|
||||
{ "stop", G_FLAG_VERBOSE, NULL,
|
||||
@ -118,7 +117,7 @@ struct g_command class_commands[] = {
|
||||
{ 'f', "force", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-fv] name ..."
|
||||
"[-fv] name ..."
|
||||
},
|
||||
G_CMD_SENTINEL
|
||||
};
|
||||
|
@ -43,14 +43,14 @@ struct g_command class_commands[] = {
|
||||
{
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-v] dev ..."
|
||||
"[-v] dev ..."
|
||||
},
|
||||
{ "destroy", G_FLAG_VERBOSE, NULL,
|
||||
{
|
||||
{ 'f', "force", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-fv] prov ..."
|
||||
"[-fv] prov ..."
|
||||
},
|
||||
G_CMD_SENTINEL
|
||||
};
|
||||
|
@ -53,27 +53,27 @@ static void mp_add(struct gctl_req *);
|
||||
struct g_command class_commands[] = {
|
||||
{
|
||||
"label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, mp_main, G_NULL_OPTS,
|
||||
NULL, "[-v] name prov ..."
|
||||
"[-v] name prov ..."
|
||||
},
|
||||
{
|
||||
"add", G_FLAG_VERBOSE | G_FLAG_LOADKLD, mp_main, G_NULL_OPTS,
|
||||
NULL, "[-v] name prov ..."
|
||||
"[-v] name prov ..."
|
||||
},
|
||||
{
|
||||
"destroy", G_FLAG_VERBOSE, NULL, G_NULL_OPTS,
|
||||
NULL, "[-v] prov ..."
|
||||
"[-v] prov ..."
|
||||
},
|
||||
{
|
||||
"clear", G_FLAG_VERBOSE, mp_main, G_NULL_OPTS,
|
||||
NULL, "[-v] prov ..."
|
||||
"[-v] prov ..."
|
||||
},
|
||||
{
|
||||
"rotate", G_FLAG_VERBOSE, NULL, G_NULL_OPTS,
|
||||
NULL, "[-v] prov ..."
|
||||
"[-v] prov ..."
|
||||
},
|
||||
{
|
||||
"getactive", G_FLAG_VERBOSE, NULL, G_NULL_OPTS,
|
||||
NULL, "[-v] prov ..."
|
||||
"[-v] prov ..."
|
||||
},
|
||||
G_CMD_SENTINEL
|
||||
};
|
||||
|
@ -38,44 +38,37 @@ __FBSDID("$FreeBSD$");
|
||||
uint32_t lib_version = G_LIB_VERSION;
|
||||
uint32_t version = G_NOP_VERSION;
|
||||
|
||||
static intmax_t error = -1;
|
||||
static intmax_t rfailprob = -1;
|
||||
static intmax_t wfailprob = -1;
|
||||
static intmax_t offset = 0;
|
||||
static intmax_t secsize = 0;
|
||||
static intmax_t size = 0;
|
||||
|
||||
struct g_command class_commands[] = {
|
||||
{ "create", G_FLAG_VERBOSE | G_FLAG_LOADKLD, NULL,
|
||||
{
|
||||
{ 'e', "error", &error, G_TYPE_NUMBER },
|
||||
{ 'o', "offset", &offset, G_TYPE_NUMBER },
|
||||
{ 'r', "rfailprob", &rfailprob, G_TYPE_NUMBER },
|
||||
{ 's', "size", &size, G_TYPE_NUMBER },
|
||||
{ 'S', "secsize", &secsize, G_TYPE_NUMBER },
|
||||
{ 'w', "wfailprob", &wfailprob, G_TYPE_NUMBER },
|
||||
{ 'e', "error", "-1", G_TYPE_NUMBER },
|
||||
{ 'o', "offset", "0", G_TYPE_NUMBER },
|
||||
{ 'r', "rfailprob", "-1", G_TYPE_NUMBER },
|
||||
{ 's', "size", "0", G_TYPE_NUMBER },
|
||||
{ 'S', "secsize", "0", G_TYPE_NUMBER },
|
||||
{ 'w', "wfailprob", "-1", G_TYPE_NUMBER },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-v] [-e error] [-o offset] [-r rfailprob] [-s size] "
|
||||
"[-v] [-e error] [-o offset] [-r rfailprob] [-s size] "
|
||||
"[-S secsize] [-w wfailprob] dev ..."
|
||||
},
|
||||
{ "configure", G_FLAG_VERBOSE, NULL,
|
||||
{
|
||||
{ 'e', "error", &error, G_TYPE_NUMBER },
|
||||
{ 'r', "rfailprob", &rfailprob, G_TYPE_NUMBER },
|
||||
{ 'w', "wfailprob", &wfailprob, G_TYPE_NUMBER },
|
||||
{ 'e', "error", "-1", G_TYPE_NUMBER },
|
||||
{ 'r', "rfailprob", "-1", G_TYPE_NUMBER },
|
||||
{ 'w', "wfailprob", "-1", G_TYPE_NUMBER },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-v] [-e error] [-r rfailprob] [-w wfailprob] prov ..."
|
||||
"[-v] [-e error] [-r rfailprob] [-w wfailprob] prov ..."
|
||||
},
|
||||
{ "destroy", G_FLAG_VERBOSE, NULL,
|
||||
{
|
||||
{ 'f', "force", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-fv] prov ..."
|
||||
"[-fv] prov ..."
|
||||
},
|
||||
{ "reset", G_FLAG_VERBOSE, NULL, G_NULL_OPTS, NULL,
|
||||
{ "reset", G_FLAG_VERBOSE, NULL, G_NULL_OPTS,
|
||||
"[-v] prov ..."
|
||||
},
|
||||
G_CMD_SENTINEL
|
||||
|
@ -58,15 +58,15 @@ __FBSDID("$FreeBSD$");
|
||||
uint32_t PUBSYM(lib_version) = G_LIB_VERSION;
|
||||
uint32_t PUBSYM(version) = 0;
|
||||
|
||||
static char autofill[] = "*";
|
||||
static char flags[] = "C";
|
||||
|
||||
static char sstart[32];
|
||||
static char ssize[32];
|
||||
|
||||
static const char const bootcode_param[] = "bootcode";
|
||||
static const char const index_param[] = "index";
|
||||
static const char const partcode_param[] = "partcode";
|
||||
#define GPART_AUTOFILL "*"
|
||||
#define GPART_FLAGS "C"
|
||||
|
||||
#define GPART_PARAM_BOOTCODE "bootcode"
|
||||
#define GPART_PARAM_INDEX "index"
|
||||
#define GPART_PARAM_PARTCODE "partcode"
|
||||
|
||||
static struct gclass *find_class(struct gmesh *, const char *);
|
||||
static struct ggeom * find_geom(struct gclass *, const char *);
|
||||
@ -87,76 +87,81 @@ static void gpart_write_partcode_vtoc8(struct ggeom *, int, void *);
|
||||
|
||||
struct g_command PUBSYM(class_commands)[] = {
|
||||
{ "add", 0, gpart_issue, {
|
||||
{ 'b', "start", autofill, G_TYPE_STRING },
|
||||
{ 's', "size", autofill, G_TYPE_STRING },
|
||||
{ 'b', "start", GPART_AUTOFILL, G_TYPE_STRING },
|
||||
{ 's', "size", GPART_AUTOFILL, G_TYPE_STRING },
|
||||
{ 't', "type", NULL, G_TYPE_STRING },
|
||||
{ 'i', index_param, "", G_TYPE_ASCNUM },
|
||||
{ 'i', GPART_PARAM_INDEX, "", G_TYPE_ASCNUM },
|
||||
{ 'l', "label", "", G_TYPE_STRING },
|
||||
{ 'f', "flags", flags, G_TYPE_STRING },
|
||||
{ 'f', "flags", GPART_FLAGS, G_TYPE_STRING },
|
||||
G_OPT_SENTINEL },
|
||||
"geom", NULL
|
||||
"[-b start] [-s size] -t type [-i index] [-l label] [-f flags] geom"
|
||||
},
|
||||
{ "bootcode", 0, gpart_bootcode, {
|
||||
{ 'b', bootcode_param, "", G_TYPE_STRING },
|
||||
{ 'p', partcode_param, "", G_TYPE_STRING },
|
||||
{ 'i', index_param, "", G_TYPE_ASCNUM },
|
||||
{ 'f', "flags", flags, G_TYPE_STRING },
|
||||
{ 'b', GPART_PARAM_BOOTCODE, "", G_TYPE_STRING },
|
||||
{ 'p', GPART_PARAM_PARTCODE, "", G_TYPE_STRING },
|
||||
{ 'i', GPART_PARAM_INDEX, "", G_TYPE_ASCNUM },
|
||||
{ 'f', "flags", GPART_FLAGS, G_TYPE_STRING },
|
||||
G_OPT_SENTINEL },
|
||||
"geom", NULL
|
||||
"bootcode [-b bootcode] [-p partcode] [-i index] [-f flags] geom"
|
||||
},
|
||||
{ "commit", 0, gpart_issue, G_NULL_OPTS,
|
||||
"geom"
|
||||
},
|
||||
{ "commit", 0, gpart_issue, G_NULL_OPTS, "geom", NULL },
|
||||
{ "create", 0, gpart_issue, {
|
||||
{ 's', "scheme", NULL, G_TYPE_STRING },
|
||||
{ 'n', "entries", "", G_TYPE_ASCNUM },
|
||||
{ 'f', "flags", flags, G_TYPE_STRING },
|
||||
{ 'f', "flags", GPART_FLAGS, G_TYPE_STRING },
|
||||
G_OPT_SENTINEL },
|
||||
"provider", NULL
|
||||
"-s scheme [-n entries] [-f flags] provider"
|
||||
},
|
||||
{ "delete", 0, gpart_issue, {
|
||||
{ 'i', index_param, NULL, G_TYPE_ASCNUM },
|
||||
{ 'f', "flags", flags, G_TYPE_STRING },
|
||||
{ 'i', GPART_PARAM_INDEX, NULL, G_TYPE_ASCNUM },
|
||||
{ 'f', "flags", GPART_FLAGS, G_TYPE_STRING },
|
||||
G_OPT_SENTINEL },
|
||||
"geom", NULL
|
||||
"-i index [-f flags] geom"
|
||||
},
|
||||
{ "destroy", 0, gpart_issue, {
|
||||
{ 'f', "flags", flags, G_TYPE_STRING },
|
||||
{ 'f', "flags", GPART_FLAGS, G_TYPE_STRING },
|
||||
G_OPT_SENTINEL },
|
||||
"geom", NULL },
|
||||
"[-f flags] geom"
|
||||
},
|
||||
{ "modify", 0, gpart_issue, {
|
||||
{ 'i', index_param, NULL, G_TYPE_ASCNUM },
|
||||
{ 'i', GPART_PARAM_INDEX, NULL, G_TYPE_ASCNUM },
|
||||
{ 'l', "label", "", G_TYPE_STRING },
|
||||
{ 't', "type", "", G_TYPE_STRING },
|
||||
{ 'f', "flags", flags, G_TYPE_STRING },
|
||||
{ 'f', "flags", GPART_FLAGS, G_TYPE_STRING },
|
||||
G_OPT_SENTINEL },
|
||||
"geom", NULL
|
||||
"-i index [-l label] [-t type] [-f flags] geom"
|
||||
},
|
||||
{ "set", 0, gpart_issue, {
|
||||
{ 'a', "attrib", NULL, G_TYPE_STRING },
|
||||
{ 'i', index_param, NULL, G_TYPE_ASCNUM },
|
||||
{ 'f', "flags", flags, G_TYPE_STRING },
|
||||
{ 'i', GPART_PARAM_INDEX, NULL, G_TYPE_ASCNUM },
|
||||
{ 'f', "flags", GPART_FLAGS, G_TYPE_STRING },
|
||||
G_OPT_SENTINEL },
|
||||
"geom", NULL
|
||||
"-a attrib -i index [-f flags] geom"
|
||||
},
|
||||
{ "show", 0, gpart_show, {
|
||||
{ 'l', "show_label", NULL, G_TYPE_BOOL },
|
||||
{ 'r', "show_rawtype", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL },
|
||||
NULL, "[-lr] [geom ...]"
|
||||
"[-lr] [geom ...]"
|
||||
},
|
||||
{ "undo", 0, gpart_issue, G_NULL_OPTS,
|
||||
"geom"
|
||||
},
|
||||
{ "undo", 0, gpart_issue, G_NULL_OPTS, "geom", NULL },
|
||||
{ "unset", 0, gpart_issue, {
|
||||
{ 'a', "attrib", NULL, G_TYPE_STRING },
|
||||
{ 'i', index_param, NULL, G_TYPE_ASCNUM },
|
||||
{ 'f', "flags", flags, G_TYPE_STRING },
|
||||
{ 'i', GPART_PARAM_INDEX, NULL, G_TYPE_ASCNUM },
|
||||
{ 'f', "flags", GPART_FLAGS, G_TYPE_STRING },
|
||||
G_OPT_SENTINEL },
|
||||
"geom", NULL
|
||||
"-a attrib -i index [-f flags] geom"
|
||||
},
|
||||
{ "resize", 0, gpart_issue, {
|
||||
{ 's', "size", autofill, G_TYPE_STRING },
|
||||
{ 'i', index_param, NULL, G_TYPE_ASCNUM },
|
||||
{ 'f', "flags", flags, G_TYPE_STRING },
|
||||
{ 's', "size", GPART_AUTOFILL, G_TYPE_STRING },
|
||||
{ 'i', GPART_PARAM_INDEX, NULL, G_TYPE_ASCNUM },
|
||||
{ 'f', "flags", GPART_FLAGS, G_TYPE_STRING },
|
||||
G_OPT_SENTINEL },
|
||||
"geom", NULL
|
||||
"[-s size] -i index [-f flags] geom"
|
||||
},
|
||||
G_CMD_SENTINEL
|
||||
};
|
||||
@ -281,7 +286,7 @@ gpart_autofill_resize(struct gctl_req *req)
|
||||
char *val;
|
||||
int error, idx;
|
||||
|
||||
s = gctl_get_ascii(req, index_param);
|
||||
s = gctl_get_ascii(req, GPART_PARAM_INDEX);
|
||||
idx = strtol(s, &val, 10);
|
||||
if (idx < 1 || *s == '\0' || *val != '\0')
|
||||
errx(EXIT_FAILURE, "invalid partition index");
|
||||
@ -773,11 +778,11 @@ gpart_bootcode(struct gctl_req *req, unsigned int fl)
|
||||
size_t bootsize, partsize;
|
||||
int error, idx, vtoc8;
|
||||
|
||||
if (gctl_has_param(req, bootcode_param)) {
|
||||
s = gctl_get_ascii(req, bootcode_param);
|
||||
if (gctl_has_param(req, GPART_PARAM_BOOTCODE)) {
|
||||
s = gctl_get_ascii(req, GPART_PARAM_BOOTCODE);
|
||||
bootsize = 800 * 1024; /* Arbitrary limit. */
|
||||
bootcode = gpart_bootfile_read(s, &bootsize);
|
||||
error = gctl_change_param(req, bootcode_param, bootsize,
|
||||
error = gctl_change_param(req, GPART_PARAM_BOOTCODE, bootsize,
|
||||
bootcode);
|
||||
if (error)
|
||||
errc(EXIT_FAILURE, error, "internal error");
|
||||
@ -797,7 +802,7 @@ gpart_bootcode(struct gctl_req *req, unsigned int fl)
|
||||
geom_deletetree(&mesh);
|
||||
errx(EXIT_FAILURE, "Class %s not found.", s);
|
||||
}
|
||||
s = gctl_get_ascii(req, "geom");
|
||||
s = gctl_get_ascii(req, "arg0");
|
||||
if (s == NULL)
|
||||
abort();
|
||||
gp = find_geom(classp, s);
|
||||
@ -808,11 +813,11 @@ gpart_bootcode(struct gctl_req *req, unsigned int fl)
|
||||
if (strcmp(s, "VTOC8") == 0)
|
||||
vtoc8 = 1;
|
||||
|
||||
if (gctl_has_param(req, partcode_param)) {
|
||||
s = gctl_get_ascii(req, partcode_param);
|
||||
if (gctl_has_param(req, GPART_PARAM_PARTCODE)) {
|
||||
s = gctl_get_ascii(req, GPART_PARAM_PARTCODE);
|
||||
partsize = vtoc8 != 0 ? VTOC_BOOTSIZE : bootsize * 1024;
|
||||
partcode = gpart_bootfile_read(s, &partsize);
|
||||
error = gctl_delete_param(req, partcode_param);
|
||||
error = gctl_delete_param(req, GPART_PARAM_PARTCODE);
|
||||
if (error)
|
||||
errc(EXIT_FAILURE, error, "internal error");
|
||||
} else {
|
||||
@ -820,14 +825,14 @@ gpart_bootcode(struct gctl_req *req, unsigned int fl)
|
||||
partsize = 0;
|
||||
}
|
||||
|
||||
if (gctl_has_param(req, index_param)) {
|
||||
if (gctl_has_param(req, GPART_PARAM_INDEX)) {
|
||||
if (partcode == NULL)
|
||||
errx(EXIT_FAILURE, "-i is only valid with -p");
|
||||
s = gctl_get_ascii(req, index_param);
|
||||
s = gctl_get_ascii(req, GPART_PARAM_INDEX);
|
||||
idx = strtol(s, &sp, 10);
|
||||
if (idx < 1 || *s == '\0' || *sp != '\0')
|
||||
errx(EXIT_FAILURE, "invalid partition index");
|
||||
error = gctl_delete_param(req, index_param);
|
||||
error = gctl_delete_param(req, GPART_PARAM_INDEX);
|
||||
if (error)
|
||||
errc(EXIT_FAILURE, error, "internal error");
|
||||
} else
|
||||
@ -858,6 +863,10 @@ gpart_issue(struct gctl_req *req, unsigned int fl __unused)
|
||||
const char *errstr;
|
||||
int error, status;
|
||||
|
||||
if (gctl_get_int(req, "nargs") != 1)
|
||||
errx(EXIT_FAILURE, "Invalid number of arguments.");
|
||||
(void)gctl_delete_param(req, "nargs");
|
||||
|
||||
/* autofill parameters (if applicable). */
|
||||
error = gpart_autofill(req);
|
||||
if (error) {
|
||||
|
@ -45,15 +45,13 @@ __FBSDID("$FreeBSD$");
|
||||
uint32_t lib_version = G_LIB_VERSION;
|
||||
uint32_t version = G_RAID3_VERSION;
|
||||
|
||||
static intmax_t default_blocksize = 0;
|
||||
|
||||
static void raid3_main(struct gctl_req *req, unsigned f);
|
||||
static void raid3_clear(struct gctl_req *req);
|
||||
static void raid3_dump(struct gctl_req *req);
|
||||
static void raid3_label(struct gctl_req *req);
|
||||
|
||||
struct g_command class_commands[] = {
|
||||
{ "clear", G_FLAG_VERBOSE, raid3_main, G_NULL_OPTS, NULL,
|
||||
{ "clear", G_FLAG_VERBOSE, raid3_main, G_NULL_OPTS,
|
||||
"[-v] prov ..."
|
||||
},
|
||||
{ "configure", G_FLAG_VERBOSE, NULL,
|
||||
@ -70,9 +68,9 @@ struct g_command class_commands[] = {
|
||||
{ 'W', "noverify", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-adfFhnrRvwW] name"
|
||||
"[-adfFhnrRvwW] name"
|
||||
},
|
||||
{ "dump", 0, raid3_main, G_NULL_OPTS, NULL,
|
||||
{ "dump", 0, raid3_main, G_NULL_OPTS,
|
||||
"prov ..."
|
||||
},
|
||||
{ "insert", G_FLAG_VERBOSE, NULL,
|
||||
@ -81,7 +79,7 @@ struct g_command class_commands[] = {
|
||||
{ 'n', "number", NULL, G_TYPE_NUMBER },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-hv] <-n number> name prov"
|
||||
"[-hv] <-n number> name prov"
|
||||
},
|
||||
{ "label", G_FLAG_VERBOSE, raid3_main,
|
||||
{
|
||||
@ -89,13 +87,13 @@ struct g_command class_commands[] = {
|
||||
{ 'F', "nofailsync", NULL, G_TYPE_BOOL },
|
||||
{ 'n', "noautosync", NULL, G_TYPE_BOOL },
|
||||
{ 'r', "round_robin", NULL, G_TYPE_BOOL },
|
||||
{ 's', "blocksize", &default_blocksize, G_TYPE_NUMBER },
|
||||
{ 's', "sectorsize", "0", G_TYPE_NUMBER },
|
||||
{ 'w', "verify", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-hFnrvw] [-s blocksize] name prov prov prov ..."
|
||||
"[-hFnrvw] [-s blocksize] name prov prov prov ..."
|
||||
},
|
||||
{ "rebuild", G_FLAG_VERBOSE, NULL, G_NULL_OPTS, NULL,
|
||||
{ "rebuild", G_FLAG_VERBOSE, NULL, G_NULL_OPTS,
|
||||
"[-v] name prov"
|
||||
},
|
||||
{ "remove", G_FLAG_VERBOSE, NULL,
|
||||
@ -103,14 +101,14 @@ struct g_command class_commands[] = {
|
||||
{ 'n', "number", NULL, G_TYPE_NUMBER },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-v] <-n number> name"
|
||||
"[-v] <-n number> name"
|
||||
},
|
||||
{ "stop", G_FLAG_VERBOSE, NULL,
|
||||
{
|
||||
{ 'f', "force", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-fv] name ..."
|
||||
"[-fv] name ..."
|
||||
},
|
||||
G_CMD_SENTINEL
|
||||
};
|
||||
@ -193,7 +191,7 @@ raid3_label(struct gctl_req *req)
|
||||
* sectorsizes of every disk and find the smallest mediasize.
|
||||
*/
|
||||
mediasize = 0;
|
||||
sectorsize = gctl_get_intmax(req, "blocksize");
|
||||
sectorsize = gctl_get_intmax(req, "sectorsize");
|
||||
for (i = 1; i < nargs; i++) {
|
||||
str = gctl_get_ascii(req, "arg%d", i);
|
||||
msize = g_get_mediasize(str);
|
||||
|
@ -60,11 +60,13 @@ uint32_t version = G_SCHED_VERSION;
|
||||
* Adapt to differences in geom library.
|
||||
* in V1 struct g_command misses gc_argname, eld, and G_BOOL is undefined
|
||||
*/
|
||||
#if G_LIB_VERSION == 1
|
||||
#define G_ARGNAME
|
||||
#if G_LIB_VERSION <= 1
|
||||
#define G_TYPE_BOOL G_TYPE_NUMBER
|
||||
#else
|
||||
#endif
|
||||
#if G_LIB_VERSION >= 3 && G_LIB_VERSION <= 4
|
||||
#define G_ARGNAME NULL,
|
||||
#else
|
||||
#define G_ARGNAME
|
||||
#endif
|
||||
|
||||
static void
|
||||
|
@ -52,10 +52,10 @@ static void shsec_dump(struct gctl_req *req);
|
||||
static void shsec_label(struct gctl_req *req);
|
||||
|
||||
struct g_command class_commands[] = {
|
||||
{ "clear", G_FLAG_VERBOSE, shsec_main, G_NULL_OPTS, NULL,
|
||||
{ "clear", G_FLAG_VERBOSE, shsec_main, G_NULL_OPTS,
|
||||
"[-v] prov ..."
|
||||
},
|
||||
{ "dump", 0, shsec_main, G_NULL_OPTS, NULL,
|
||||
{ "dump", 0, shsec_main, G_NULL_OPTS,
|
||||
"prov ..."
|
||||
},
|
||||
{ "label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, shsec_main,
|
||||
@ -63,14 +63,14 @@ struct g_command class_commands[] = {
|
||||
{ 'h', "hardcode", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-hv] name prov prov ..."
|
||||
"[-hv] name prov prov ..."
|
||||
},
|
||||
{ "stop", G_FLAG_VERBOSE, NULL,
|
||||
{
|
||||
{ 'f', "force", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-fv] name ..."
|
||||
"[-fv] name ..."
|
||||
},
|
||||
G_CMD_SENTINEL
|
||||
};
|
||||
|
@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$");
|
||||
uint32_t lib_version = G_LIB_VERSION;
|
||||
uint32_t version = G_STRIPE_VERSION;
|
||||
|
||||
static intmax_t default_stripesize = 65536;
|
||||
#define GSTRIPE_STRIPESIZE "65536"
|
||||
|
||||
static void stripe_main(struct gctl_req *req, unsigned flags);
|
||||
static void stripe_clear(struct gctl_req *req);
|
||||
@ -54,40 +54,40 @@ 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, NULL,
|
||||
{ "clear", G_FLAG_VERBOSE, stripe_main, G_NULL_OPTS,
|
||||
"[-v] prov ..."
|
||||
},
|
||||
{ "create", G_FLAG_VERBOSE | G_FLAG_LOADKLD, NULL,
|
||||
{
|
||||
{ 's', "stripesize", &default_stripesize, G_TYPE_NUMBER },
|
||||
{ 's', "stripesize", GSTRIPE_STRIPESIZE, G_TYPE_NUMBER },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-hv] [-s stripesize] name prov prov ..."
|
||||
"[-hv] [-s stripesize] name prov prov ..."
|
||||
},
|
||||
{ "destroy", G_FLAG_VERBOSE, NULL,
|
||||
{
|
||||
{ 'f', "force", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-fv] name ..."
|
||||
"[-fv] name ..."
|
||||
},
|
||||
{ "dump", 0, stripe_main, G_NULL_OPTS, NULL,
|
||||
{ "dump", 0, stripe_main, G_NULL_OPTS,
|
||||
"prov ..."
|
||||
},
|
||||
{ "label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, stripe_main,
|
||||
{
|
||||
{ 'h', "hardcode", NULL, G_TYPE_BOOL },
|
||||
{ 's', "stripesize", &default_stripesize, G_TYPE_NUMBER },
|
||||
{ 's', "stripesize", GSTRIPE_STRIPESIZE, G_TYPE_NUMBER },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-hv] [-s stripesize] name prov prov ..."
|
||||
"[-hv] [-s stripesize] name prov prov ..."
|
||||
},
|
||||
{ "stop", G_FLAG_VERBOSE, NULL,
|
||||
{
|
||||
{ 'f', "force", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-fv] name ..."
|
||||
"[-fv] name ..."
|
||||
},
|
||||
G_CMD_SENTINEL
|
||||
};
|
||||
|
@ -48,8 +48,9 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
uint32_t lib_version = G_LIB_VERSION;
|
||||
uint32_t version = G_VIRSTOR_VERSION;
|
||||
static intmax_t chunk_size = 4 * 1024 * 1024; /* in kB (default: 4 MB) */
|
||||
static intmax_t vir_size = 2ULL << 40; /* in MB (default: 2 TB) */
|
||||
|
||||
#define GVIRSTOR_CHUNK_SIZE "4M"
|
||||
#define GVIRSTOR_VIR_SIZE "2T"
|
||||
|
||||
#if G_LIB_VERSION == 1
|
||||
/* Support RELENG_6 */
|
||||
@ -62,43 +63,43 @@ static intmax_t vir_size = 2ULL << 40; /* in MB (default: 2 TB) */
|
||||
static void virstor_main(struct gctl_req *req, unsigned flags);
|
||||
|
||||
struct g_command class_commands[] = {
|
||||
{"clear", G_FLAG_VERBOSE, virstor_main, G_NULL_OPTS, NULL,
|
||||
{ "clear", G_FLAG_VERBOSE, virstor_main, G_NULL_OPTS,
|
||||
"[-v] prov ..."
|
||||
},
|
||||
{"dump", 0, virstor_main, G_NULL_OPTS, NULL,
|
||||
{ "dump", 0, virstor_main, G_NULL_OPTS,
|
||||
"prov ..."
|
||||
},
|
||||
{"label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, virstor_main,
|
||||
{ "label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, virstor_main,
|
||||
{
|
||||
{'h', "hardcode", NULL, G_TYPE_BOOL},
|
||||
{'m', "chunk_size", &chunk_size, G_TYPE_NUMBER},
|
||||
{'s', "vir_size", &vir_size, G_TYPE_NUMBER},
|
||||
{ 'h', "hardcode", NULL, G_TYPE_BOOL},
|
||||
{ 'm', "chunk_size", GVIRSTOR_CHUNK_SIZE, G_TYPE_NUMBER},
|
||||
{ 's', "vir_size", GVIRSTOR_VIR_SIZE, G_TYPE_NUMBER},
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-h] [-v] [-m chunk_size] [-s vir_size] name provider0 [provider1 ...]"
|
||||
"[-h] [-v] [-m chunk_size] [-s vir_size] name provider0 [provider1 ...]"
|
||||
},
|
||||
{"destroy", G_FLAG_VERBOSE, NULL,
|
||||
{ "destroy", G_FLAG_VERBOSE, NULL,
|
||||
{
|
||||
{'f', "force", NULL, G_TYPE_BOOL},
|
||||
{ 'f', "force", NULL, G_TYPE_BOOL},
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-fv] name ..."
|
||||
"[-fv] name ..."
|
||||
},
|
||||
{"stop", G_FLAG_VERBOSE, NULL,
|
||||
{ "stop", G_FLAG_VERBOSE, NULL,
|
||||
{
|
||||
{'f', "force", NULL, G_TYPE_BOOL},
|
||||
{ 'f', "force", NULL, G_TYPE_BOOL},
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-fv] name ... (alias for \"destroy\")"
|
||||
"[-fv] name ... (alias for \"destroy\")"
|
||||
},
|
||||
{"add", G_FLAG_VERBOSE, NULL,
|
||||
{ "add", G_FLAG_VERBOSE, NULL,
|
||||
{
|
||||
{'h', "hardcode", NULL, G_TYPE_BOOL},
|
||||
{ 'h', "hardcode", NULL, G_TYPE_BOOL},
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-vh] name prov [prov ...]"
|
||||
"[-vh] name prov [prov ...]"
|
||||
},
|
||||
{"remove", G_FLAG_VERBOSE, NULL, G_NULL_OPTS, NULL,
|
||||
{ "remove", G_FLAG_VERBOSE, NULL, G_NULL_OPTS,
|
||||
"[-v] name ..."
|
||||
},
|
||||
G_CMD_SENTINEL
|
||||
|
@ -75,8 +75,8 @@ static void std_load(struct gctl_req *req, unsigned flags);
|
||||
static void std_unload(struct gctl_req *req, unsigned flags);
|
||||
|
||||
struct g_command std_commands[] = {
|
||||
{ "help", 0, std_help, G_NULL_OPTS, NULL, NULL },
|
||||
{ "list", 0, std_list, G_NULL_OPTS, NULL,
|
||||
{ "help", 0, std_help, G_NULL_OPTS, NULL },
|
||||
{ "list", 0, std_list, G_NULL_OPTS,
|
||||
"[name ...]"
|
||||
},
|
||||
{ "status", 0, std_status,
|
||||
@ -84,11 +84,11 @@ struct g_command std_commands[] = {
|
||||
{ 's', "script", NULL, G_TYPE_BOOL },
|
||||
G_OPT_SENTINEL
|
||||
},
|
||||
NULL, "[-s] [name ...]"
|
||||
"[-s] [name ...]"
|
||||
},
|
||||
{ "load", G_FLAG_VERBOSE | G_FLAG_LOADKLD, std_load, G_NULL_OPTS,
|
||||
NULL, NULL },
|
||||
{ "unload", G_FLAG_VERBOSE, std_unload, G_NULL_OPTS, NULL, NULL },
|
||||
NULL },
|
||||
{ "unload", G_FLAG_VERBOSE, std_unload, G_NULL_OPTS, NULL },
|
||||
G_CMD_SENTINEL
|
||||
};
|
||||
|
||||
@ -129,8 +129,6 @@ usage_command(struct g_command *cmd, const char *prefix)
|
||||
if (opt->go_val != NULL || G_OPT_TYPE(opt) == G_TYPE_BOOL)
|
||||
fprintf(stderr, "]");
|
||||
}
|
||||
if (cmd->gc_argname)
|
||||
fprintf(stderr, " %s", cmd->gc_argname);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
@ -348,25 +346,15 @@ parse_arguments(struct g_command *cmd, struct gctl_req *req, int *argc,
|
||||
warnx("Option '%c' not specified.",
|
||||
opt->go_char);
|
||||
usage();
|
||||
} else if (G_OPT_TYPE(opt) == G_TYPE_ASCNUM &&
|
||||
*(const char *)opt->go_val == '\0') {
|
||||
; /* add nothing. */
|
||||
} else {
|
||||
if (G_OPT_TYPE(opt) == G_TYPE_NUMBER) {
|
||||
gctl_ro_param(req, opt->go_name,
|
||||
sizeof(intmax_t), opt->go_val);
|
||||
} else if (G_OPT_TYPE(opt) == G_TYPE_STRING ||
|
||||
G_OPT_TYPE(opt) == G_TYPE_ASCNUM) {
|
||||
if (cmd->gc_argname == NULL ||
|
||||
opt->go_val == NULL ||
|
||||
*(const char *)opt->go_val != '\0')
|
||||
gctl_ro_param(req, opt->go_name,
|
||||
-1, opt->go_val);
|
||||
} else {
|
||||
assert(!"Invalid type");
|
||||
}
|
||||
set_option(req, opt, opt->go_val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd->gc_argname == NULL) {
|
||||
/*
|
||||
* Add rest of given arguments.
|
||||
*/
|
||||
@ -377,11 +365,6 @@ parse_arguments(struct g_command *cmd, struct gctl_req *req, int *argc,
|
||||
snprintf(argname, sizeof(argname), "arg%u", i);
|
||||
gctl_ro_param(req, argname, -1, (*argv)[i]);
|
||||
}
|
||||
} else {
|
||||
if (*argc != 1)
|
||||
usage();
|
||||
gctl_ro_param(req, cmd->gc_argname, -1, (*argv)[0]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#ifndef _GEOM_H_
|
||||
#define _GEOM_H_
|
||||
#define G_LIB_VERSION 4
|
||||
#define G_LIB_VERSION 5
|
||||
|
||||
#define G_FLAG_NONE 0x0000
|
||||
#define G_FLAG_VERBOSE 0x0001
|
||||
@ -49,7 +49,7 @@
|
||||
|
||||
#define G_OPT_SENTINEL { '\0', NULL, NULL, G_TYPE_NONE }
|
||||
#define G_NULL_OPTS { G_OPT_SENTINEL }
|
||||
#define G_CMD_SENTINEL { NULL, 0, NULL, G_NULL_OPTS, NULL, NULL }
|
||||
#define G_CMD_SENTINEL { NULL, 0, NULL, G_NULL_OPTS, NULL }
|
||||
|
||||
struct g_option {
|
||||
char go_char;
|
||||
@ -63,7 +63,6 @@ struct g_command {
|
||||
unsigned gc_flags;
|
||||
void (*gc_func)(struct gctl_req *, unsigned);
|
||||
struct g_option gc_options[G_OPT_MAX];
|
||||
const char *gc_argname;
|
||||
const char *gc_usage;
|
||||
};
|
||||
#endif /* !_GEOM_H_ */
|
||||
|
@ -1327,6 +1327,10 @@ g_part_ctlreq(struct gctl_req *req, struct g_class *mp, const char *verb)
|
||||
parm = 0;
|
||||
switch (ap->name[0]) {
|
||||
case 'a':
|
||||
if (!strcmp(ap->name, "arg0")) {
|
||||
parm = mparms &
|
||||
(G_PART_PARM_GEOM | G_PART_PARM_PROVIDER);
|
||||
}
|
||||
if (!strcmp(ap->name, "attrib"))
|
||||
parm = G_PART_PARM_ATTRIB;
|
||||
break;
|
||||
@ -1346,10 +1350,6 @@ g_part_ctlreq(struct gctl_req *req, struct g_class *mp, const char *verb)
|
||||
if (!strcmp(ap->name, "flags"))
|
||||
parm = G_PART_PARM_FLAGS;
|
||||
break;
|
||||
case 'g':
|
||||
if (!strcmp(ap->name, "geom"))
|
||||
parm = G_PART_PARM_GEOM;
|
||||
break;
|
||||
case 'i':
|
||||
if (!strcmp(ap->name, "index"))
|
||||
parm = G_PART_PARM_INDEX;
|
||||
@ -1362,10 +1362,6 @@ g_part_ctlreq(struct gctl_req *req, struct g_class *mp, const char *verb)
|
||||
if (!strcmp(ap->name, "output"))
|
||||
parm = G_PART_PARM_OUTPUT;
|
||||
break;
|
||||
case 'p':
|
||||
if (!strcmp(ap->name, "provider"))
|
||||
parm = G_PART_PARM_PROVIDER;
|
||||
break;
|
||||
case 's':
|
||||
if (!strcmp(ap->name, "scheme"))
|
||||
parm = G_PART_PARM_SCHEME;
|
||||
|
Loading…
Reference in New Issue
Block a user