- Allow to specify value as const pointers.
- Make optional string values always an empty string.
This commit is contained in:
parent
b7d28b2e0b
commit
a478ea7490
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=212547
@ -55,15 +55,12 @@ uint32_t lib_version = G_LIB_VERSION;
|
|||||||
uint32_t version = G_ELI_VERSION;
|
uint32_t version = G_ELI_VERSION;
|
||||||
|
|
||||||
#define GELI_BACKUP_DIR "/var/backups/"
|
#define GELI_BACKUP_DIR "/var/backups/"
|
||||||
|
#define GELI_ENC_ALGO "aes"
|
||||||
|
|
||||||
static char aalgo[] = "none";
|
|
||||||
static char ealgo[] = "aes";
|
|
||||||
static intmax_t keylen = 0;
|
static intmax_t keylen = 0;
|
||||||
static intmax_t keyno = -1;
|
static intmax_t keyno = -1;
|
||||||
static intmax_t iterations = -1;
|
static intmax_t iterations = -1;
|
||||||
static intmax_t sectorsize = 0;
|
static intmax_t sectorsize = 0;
|
||||||
static char keyfile[] = "", newkeyfile[] = "";
|
|
||||||
static char backupfile[] = "";
|
|
||||||
|
|
||||||
static void eli_main(struct gctl_req *req, unsigned flags);
|
static void eli_main(struct gctl_req *req, unsigned flags);
|
||||||
static void eli_init(struct gctl_req *req);
|
static void eli_init(struct gctl_req *req);
|
||||||
@ -101,12 +98,12 @@ static int eli_backup_create(struct gctl_req *req, const char *prov,
|
|||||||
struct g_command class_commands[] = {
|
struct g_command class_commands[] = {
|
||||||
{ "init", G_FLAG_VERBOSE, eli_main,
|
{ "init", G_FLAG_VERBOSE, eli_main,
|
||||||
{
|
{
|
||||||
{ 'a', "aalgo", aalgo, G_TYPE_STRING },
|
{ 'a', "aalgo", "", G_TYPE_STRING },
|
||||||
{ 'b', "boot", NULL, G_TYPE_BOOL },
|
{ 'b', "boot", NULL, G_TYPE_BOOL },
|
||||||
{ 'B', "backupfile", backupfile, G_TYPE_STRING },
|
{ 'B', "backupfile", "", G_TYPE_STRING },
|
||||||
{ 'e', "ealgo", ealgo, G_TYPE_STRING },
|
{ 'e', "ealgo", GELI_ENC_ALGO, G_TYPE_STRING },
|
||||||
{ 'i', "iterations", &iterations, G_TYPE_NUMBER },
|
{ 'i', "iterations", &iterations, G_TYPE_NUMBER },
|
||||||
{ 'K', "newkeyfile", newkeyfile, G_TYPE_STRING },
|
{ 'K', "newkeyfile", "", G_TYPE_STRING },
|
||||||
{ 'l', "keylen", &keylen, G_TYPE_NUMBER },
|
{ 'l', "keylen", &keylen, G_TYPE_NUMBER },
|
||||||
{ 'P', "nonewpassphrase", NULL, G_TYPE_BOOL },
|
{ 'P', "nonewpassphrase", NULL, G_TYPE_BOOL },
|
||||||
{ 's', "sectorsize", §orsize, G_TYPE_NUMBER },
|
{ 's', "sectorsize", §orsize, G_TYPE_NUMBER },
|
||||||
@ -116,12 +113,12 @@ struct g_command class_commands[] = {
|
|||||||
},
|
},
|
||||||
{ "label", G_FLAG_VERBOSE, eli_main,
|
{ "label", G_FLAG_VERBOSE, eli_main,
|
||||||
{
|
{
|
||||||
{ 'a', "aalgo", aalgo, G_TYPE_STRING },
|
{ 'a', "aalgo", "", G_TYPE_STRING },
|
||||||
{ 'b', "boot", NULL, G_TYPE_BOOL },
|
{ 'b', "boot", NULL, G_TYPE_BOOL },
|
||||||
{ 'B', "backupfile", backupfile, G_TYPE_STRING },
|
{ 'B', "backupfile", "", G_TYPE_STRING },
|
||||||
{ 'e', "ealgo", ealgo, G_TYPE_STRING },
|
{ 'e', "ealgo", GELI_ENC_ALGO, G_TYPE_STRING },
|
||||||
{ 'i', "iterations", &iterations, G_TYPE_NUMBER },
|
{ 'i', "iterations", &iterations, G_TYPE_NUMBER },
|
||||||
{ 'K', "newkeyfile", newkeyfile, G_TYPE_STRING },
|
{ 'K', "newkeyfile", "", G_TYPE_STRING },
|
||||||
{ 'l', "keylen", &keylen, G_TYPE_NUMBER },
|
{ 'l', "keylen", &keylen, G_TYPE_NUMBER },
|
||||||
{ 'P', "nonewpassphrase", NULL, G_TYPE_BOOL },
|
{ 'P', "nonewpassphrase", NULL, G_TYPE_BOOL },
|
||||||
{ 's', "sectorsize", §orsize, G_TYPE_NUMBER },
|
{ 's', "sectorsize", §orsize, G_TYPE_NUMBER },
|
||||||
@ -132,7 +129,7 @@ struct g_command class_commands[] = {
|
|||||||
{ "attach", G_FLAG_VERBOSE | G_FLAG_LOADKLD, eli_main,
|
{ "attach", G_FLAG_VERBOSE | G_FLAG_LOADKLD, eli_main,
|
||||||
{
|
{
|
||||||
{ 'd', "detach", NULL, G_TYPE_BOOL },
|
{ 'd', "detach", NULL, G_TYPE_BOOL },
|
||||||
{ 'k', "keyfile", keyfile, G_TYPE_STRING },
|
{ 'k', "keyfile", "", G_TYPE_STRING },
|
||||||
{ 'p', "nopassphrase", NULL, G_TYPE_BOOL },
|
{ 'p', "nopassphrase", NULL, G_TYPE_BOOL },
|
||||||
{ 'r', "readonly", NULL, G_TYPE_BOOL },
|
{ 'r', "readonly", NULL, G_TYPE_BOOL },
|
||||||
G_OPT_SENTINEL
|
G_OPT_SENTINEL
|
||||||
@ -157,9 +154,9 @@ struct g_command class_commands[] = {
|
|||||||
},
|
},
|
||||||
{ "onetime", G_FLAG_VERBOSE | G_FLAG_LOADKLD, NULL,
|
{ "onetime", G_FLAG_VERBOSE | G_FLAG_LOADKLD, NULL,
|
||||||
{
|
{
|
||||||
{ 'a', "aalgo", aalgo, G_TYPE_STRING },
|
{ 'a', "aalgo", "", G_TYPE_STRING },
|
||||||
{ 'd', "detach", NULL, G_TYPE_BOOL },
|
{ 'd', "detach", NULL, G_TYPE_BOOL },
|
||||||
{ 'e', "ealgo", ealgo, G_TYPE_STRING },
|
{ 'e', "ealgo", GELI_ENC_ALGO, G_TYPE_STRING },
|
||||||
{ 'l', "keylen", &keylen, G_TYPE_NUMBER },
|
{ 'l', "keylen", &keylen, G_TYPE_NUMBER },
|
||||||
{ 's', "sectorsize", §orsize, G_TYPE_NUMBER },
|
{ 's', "sectorsize", §orsize, G_TYPE_NUMBER },
|
||||||
G_OPT_SENTINEL
|
G_OPT_SENTINEL
|
||||||
@ -177,8 +174,8 @@ struct g_command class_commands[] = {
|
|||||||
{ "setkey", G_FLAG_VERBOSE, eli_main,
|
{ "setkey", G_FLAG_VERBOSE, eli_main,
|
||||||
{
|
{
|
||||||
{ 'i', "iterations", &iterations, G_TYPE_NUMBER },
|
{ 'i', "iterations", &iterations, G_TYPE_NUMBER },
|
||||||
{ 'k', "keyfile", keyfile, G_TYPE_STRING },
|
{ 'k', "keyfile", "", G_TYPE_STRING },
|
||||||
{ 'K', "newkeyfile", newkeyfile, G_TYPE_STRING },
|
{ 'K', "newkeyfile", "", G_TYPE_STRING },
|
||||||
{ 'n', "keyno", &keyno, G_TYPE_NUMBER },
|
{ 'n', "keyno", &keyno, G_TYPE_NUMBER },
|
||||||
{ 'p', "nopassphrase", NULL, G_TYPE_BOOL },
|
{ 'p', "nopassphrase", NULL, G_TYPE_BOOL },
|
||||||
{ 'P', "nonewpassphrase", NULL, G_TYPE_BOOL },
|
{ 'P', "nonewpassphrase", NULL, G_TYPE_BOOL },
|
||||||
@ -551,7 +548,7 @@ eli_init(struct gctl_req *req)
|
|||||||
md.md_flags |= G_ELI_FLAG_BOOT;
|
md.md_flags |= G_ELI_FLAG_BOOT;
|
||||||
md.md_ealgo = CRYPTO_ALGORITHM_MIN - 1;
|
md.md_ealgo = CRYPTO_ALGORITHM_MIN - 1;
|
||||||
str = gctl_get_ascii(req, "aalgo");
|
str = gctl_get_ascii(req, "aalgo");
|
||||||
if (strcmp(str, "none") != 0) {
|
if (*str != '\0') {
|
||||||
md.md_aalgo = g_eli_str2aalgo(str);
|
md.md_aalgo = g_eli_str2aalgo(str);
|
||||||
if (md.md_aalgo >= CRYPTO_ALGORITHM_MIN &&
|
if (md.md_aalgo >= CRYPTO_ALGORITHM_MIN &&
|
||||||
md.md_aalgo <= CRYPTO_ALGORITHM_MAX) {
|
md.md_aalgo <= CRYPTO_ALGORITHM_MAX) {
|
||||||
|
@ -44,7 +44,8 @@ __FBSDID("$FreeBSD$");
|
|||||||
uint32_t lib_version = G_LIB_VERSION;
|
uint32_t lib_version = G_LIB_VERSION;
|
||||||
uint32_t version = G_MIRROR_VERSION;
|
uint32_t version = G_MIRROR_VERSION;
|
||||||
|
|
||||||
static char label_balance[] = "load", configure_balance[] = "none";
|
#define GMIRROR_BALANCE "load"
|
||||||
|
|
||||||
static intmax_t label_slice = 4096, configure_slice = -1;
|
static intmax_t label_slice = 4096, configure_slice = -1;
|
||||||
static intmax_t insert_priority = 0, configure_priority = -1;
|
static intmax_t insert_priority = 0, configure_priority = -1;
|
||||||
|
|
||||||
@ -64,7 +65,7 @@ struct g_command class_commands[] = {
|
|||||||
{ "configure", G_FLAG_VERBOSE, NULL,
|
{ "configure", G_FLAG_VERBOSE, NULL,
|
||||||
{
|
{
|
||||||
{ 'a', "autosync", NULL, G_TYPE_BOOL },
|
{ 'a', "autosync", NULL, G_TYPE_BOOL },
|
||||||
{ 'b', "balance", configure_balance, G_TYPE_STRING },
|
{ 'b', "balance", "", G_TYPE_STRING },
|
||||||
{ 'd', "dynamic", NULL, G_TYPE_BOOL },
|
{ 'd', "dynamic", NULL, G_TYPE_BOOL },
|
||||||
{ 'f', "failsync", NULL, G_TYPE_BOOL },
|
{ 'f', "failsync", NULL, G_TYPE_BOOL },
|
||||||
{ 'F', "nofailsync", NULL, G_TYPE_BOOL },
|
{ 'F', "nofailsync", NULL, G_TYPE_BOOL },
|
||||||
@ -88,7 +89,7 @@ struct g_command class_commands[] = {
|
|||||||
},
|
},
|
||||||
{ "label", G_FLAG_VERBOSE, mirror_main,
|
{ "label", G_FLAG_VERBOSE, mirror_main,
|
||||||
{
|
{
|
||||||
{ 'b', "balance", label_balance, G_TYPE_STRING },
|
{ 'b', "balance", GMIRROR_BALANCE, G_TYPE_STRING },
|
||||||
{ 'F', "nofailsync", NULL, G_TYPE_BOOL },
|
{ 'F', "nofailsync", NULL, G_TYPE_BOOL },
|
||||||
{ 'h', "hardcode", NULL, G_TYPE_BOOL },
|
{ 'h', "hardcode", NULL, G_TYPE_BOOL },
|
||||||
{ 'n', "noautosync", NULL, G_TYPE_BOOL },
|
{ 'n', "noautosync", NULL, G_TYPE_BOOL },
|
||||||
|
@ -59,7 +59,6 @@ uint32_t PUBSYM(lib_version) = G_LIB_VERSION;
|
|||||||
uint32_t PUBSYM(version) = 0;
|
uint32_t PUBSYM(version) = 0;
|
||||||
|
|
||||||
static char autofill[] = "*";
|
static char autofill[] = "*";
|
||||||
static char optional[] = "";
|
|
||||||
static char flags[] = "C";
|
static char flags[] = "C";
|
||||||
|
|
||||||
static char sstart[32];
|
static char sstart[32];
|
||||||
@ -91,16 +90,16 @@ struct g_command PUBSYM(class_commands)[] = {
|
|||||||
{ 'b', "start", autofill, G_TYPE_STRING },
|
{ 'b', "start", autofill, G_TYPE_STRING },
|
||||||
{ 's', "size", autofill, G_TYPE_STRING },
|
{ 's', "size", autofill, G_TYPE_STRING },
|
||||||
{ 't', "type", NULL, G_TYPE_STRING },
|
{ 't', "type", NULL, G_TYPE_STRING },
|
||||||
{ 'i', index_param, optional, G_TYPE_ASCNUM },
|
{ 'i', index_param, "", G_TYPE_ASCNUM },
|
||||||
{ 'l', "label", optional, G_TYPE_STRING },
|
{ 'l', "label", "", G_TYPE_STRING },
|
||||||
{ 'f', "flags", flags, G_TYPE_STRING },
|
{ 'f', "flags", flags, G_TYPE_STRING },
|
||||||
G_OPT_SENTINEL },
|
G_OPT_SENTINEL },
|
||||||
"geom", NULL
|
"geom", NULL
|
||||||
},
|
},
|
||||||
{ "bootcode", 0, gpart_bootcode, {
|
{ "bootcode", 0, gpart_bootcode, {
|
||||||
{ 'b', bootcode_param, optional, G_TYPE_STRING },
|
{ 'b', bootcode_param, "", G_TYPE_STRING },
|
||||||
{ 'p', partcode_param, optional, G_TYPE_STRING },
|
{ 'p', partcode_param, "", G_TYPE_STRING },
|
||||||
{ 'i', index_param, optional, G_TYPE_ASCNUM },
|
{ 'i', index_param, "", G_TYPE_ASCNUM },
|
||||||
{ 'f', "flags", flags, G_TYPE_STRING },
|
{ 'f', "flags", flags, G_TYPE_STRING },
|
||||||
G_OPT_SENTINEL },
|
G_OPT_SENTINEL },
|
||||||
"geom", NULL
|
"geom", NULL
|
||||||
@ -108,7 +107,7 @@ struct g_command PUBSYM(class_commands)[] = {
|
|||||||
{ "commit", 0, gpart_issue, G_NULL_OPTS, "geom", NULL },
|
{ "commit", 0, gpart_issue, G_NULL_OPTS, "geom", NULL },
|
||||||
{ "create", 0, gpart_issue, {
|
{ "create", 0, gpart_issue, {
|
||||||
{ 's', "scheme", NULL, G_TYPE_STRING },
|
{ 's', "scheme", NULL, G_TYPE_STRING },
|
||||||
{ 'n', "entries", optional, G_TYPE_ASCNUM },
|
{ 'n', "entries", "", G_TYPE_ASCNUM },
|
||||||
{ 'f', "flags", flags, G_TYPE_STRING },
|
{ 'f', "flags", flags, G_TYPE_STRING },
|
||||||
G_OPT_SENTINEL },
|
G_OPT_SENTINEL },
|
||||||
"provider", NULL
|
"provider", NULL
|
||||||
@ -125,8 +124,8 @@ struct g_command PUBSYM(class_commands)[] = {
|
|||||||
"geom", NULL },
|
"geom", NULL },
|
||||||
{ "modify", 0, gpart_issue, {
|
{ "modify", 0, gpart_issue, {
|
||||||
{ 'i', index_param, NULL, G_TYPE_ASCNUM },
|
{ 'i', index_param, NULL, G_TYPE_ASCNUM },
|
||||||
{ 'l', "label", optional, G_TYPE_STRING },
|
{ 'l', "label", "", G_TYPE_STRING },
|
||||||
{ 't', "type", optional, G_TYPE_STRING },
|
{ 't', "type", "", G_TYPE_STRING },
|
||||||
{ 'f', "flags", flags, G_TYPE_STRING },
|
{ 'f', "flags", flags, G_TYPE_STRING },
|
||||||
G_OPT_SENTINEL },
|
G_OPT_SENTINEL },
|
||||||
"geom", NULL
|
"geom", NULL
|
||||||
|
@ -54,7 +54,7 @@ uint32_t version = G_SCHED_VERSION;
|
|||||||
* storage for parameters used by this geom class.
|
* storage for parameters used by this geom class.
|
||||||
* Right now only the scheduler name is used.
|
* Right now only the scheduler name is used.
|
||||||
*/
|
*/
|
||||||
static char algo[] = "rr"; /* default scheduler */
|
#define GSCHED_ALGO "rr" /* default scheduler */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Adapt to differences in geom library.
|
* Adapt to differences in geom library.
|
||||||
@ -76,7 +76,7 @@ gcmd_createinsert(struct gctl_req *req, unsigned flags __unused)
|
|||||||
if (gctl_has_param(req, "algo"))
|
if (gctl_has_param(req, "algo"))
|
||||||
reqalgo = gctl_get_ascii(req, "algo");
|
reqalgo = gctl_get_ascii(req, "algo");
|
||||||
else
|
else
|
||||||
reqalgo = algo;
|
reqalgo = GSCHED_ALGO;
|
||||||
|
|
||||||
snprintf(name, sizeof(name), "gsched_%s", reqalgo);
|
snprintf(name, sizeof(name), "gsched_%s", reqalgo);
|
||||||
/*
|
/*
|
||||||
@ -91,21 +91,21 @@ gcmd_createinsert(struct gctl_req *req, unsigned flags __unused)
|
|||||||
struct g_command class_commands[] = {
|
struct g_command class_commands[] = {
|
||||||
{ "create", G_FLAG_VERBOSE | G_FLAG_LOADKLD, gcmd_createinsert,
|
{ "create", G_FLAG_VERBOSE | G_FLAG_LOADKLD, gcmd_createinsert,
|
||||||
{
|
{
|
||||||
{ 'a', "algo", algo, G_TYPE_STRING },
|
{ 'a', "algo", GSCHED_ALGO, G_TYPE_STRING },
|
||||||
G_OPT_SENTINEL
|
G_OPT_SENTINEL
|
||||||
},
|
},
|
||||||
G_ARGNAME "[-v] [-a algorithm_name] dev ..."
|
G_ARGNAME "[-v] [-a algorithm_name] dev ..."
|
||||||
},
|
},
|
||||||
{ "insert", G_FLAG_VERBOSE | G_FLAG_LOADKLD, gcmd_createinsert,
|
{ "insert", G_FLAG_VERBOSE | G_FLAG_LOADKLD, gcmd_createinsert,
|
||||||
{
|
{
|
||||||
{ 'a', "algo", algo, G_TYPE_STRING },
|
{ 'a', "algo", GSCHED_ALGO, G_TYPE_STRING },
|
||||||
G_OPT_SENTINEL
|
G_OPT_SENTINEL
|
||||||
},
|
},
|
||||||
G_ARGNAME "[-v] [-a algorithm_name] dev ..."
|
G_ARGNAME "[-v] [-a algorithm_name] dev ..."
|
||||||
},
|
},
|
||||||
{ "configure", G_FLAG_VERBOSE, NULL,
|
{ "configure", G_FLAG_VERBOSE, NULL,
|
||||||
{
|
{
|
||||||
{ 'a', "algo", algo, G_TYPE_STRING },
|
{ 'a', "algo", GSCHED_ALGO, G_TYPE_STRING },
|
||||||
G_OPT_SENTINEL
|
G_OPT_SENTINEL
|
||||||
},
|
},
|
||||||
G_ARGNAME "[-v] [-a algorithm_name] prov ..."
|
G_ARGNAME "[-v] [-a algorithm_name] prov ..."
|
||||||
|
@ -236,8 +236,8 @@ find_option(struct g_command *cmd, char ch)
|
|||||||
static void
|
static void
|
||||||
set_option(struct gctl_req *req, struct g_option *opt, const char *val)
|
set_option(struct gctl_req *req, struct g_option *opt, const char *val)
|
||||||
{
|
{
|
||||||
char *s;
|
|
||||||
uint64_t number;
|
uint64_t number;
|
||||||
|
void *ptr;
|
||||||
|
|
||||||
if (G_OPT_TYPE(opt) == G_TYPE_NUMBER ||
|
if (G_OPT_TYPE(opt) == G_TYPE_NUMBER ||
|
||||||
G_OPT_TYPE(opt) == G_TYPE_ASCNUM) {
|
G_OPT_TYPE(opt) == G_TYPE_ASCNUM) {
|
||||||
@ -245,27 +245,29 @@ set_option(struct gctl_req *req, struct g_option *opt, const char *val)
|
|||||||
err(EXIT_FAILURE, "Invalid value for '%c' argument.",
|
err(EXIT_FAILURE, "Invalid value for '%c' argument.",
|
||||||
opt->go_char);
|
opt->go_char);
|
||||||
}
|
}
|
||||||
if (G_OPT_TYPE(opt) == G_TYPE_NUMBER)
|
|
||||||
opt->go_val = malloc(sizeof(intmax_t));
|
|
||||||
else {
|
|
||||||
asprintf(&s, "%jd", number);
|
|
||||||
opt->go_val = s;
|
|
||||||
}
|
|
||||||
if (opt->go_val == NULL)
|
|
||||||
errx(EXIT_FAILURE, "No memory.");
|
|
||||||
if (G_OPT_TYPE(opt) == G_TYPE_NUMBER) {
|
if (G_OPT_TYPE(opt) == G_TYPE_NUMBER) {
|
||||||
*(intmax_t *)opt->go_val = number;
|
ptr = malloc(sizeof(intmax_t));
|
||||||
|
if (ptr == NULL)
|
||||||
|
errx(EXIT_FAILURE, "No memory.");
|
||||||
|
*(intmax_t *)ptr = number;
|
||||||
|
opt->go_val = ptr;
|
||||||
gctl_ro_param(req, opt->go_name, sizeof(intmax_t),
|
gctl_ro_param(req, opt->go_name, sizeof(intmax_t),
|
||||||
opt->go_val);
|
opt->go_val);
|
||||||
} else
|
} else {
|
||||||
|
asprintf((void *)(&ptr), "%jd", number);
|
||||||
|
if (ptr == NULL)
|
||||||
|
errx(EXIT_FAILURE, "No memory.");
|
||||||
|
opt->go_val = ptr;
|
||||||
gctl_ro_param(req, opt->go_name, -1, opt->go_val);
|
gctl_ro_param(req, opt->go_name, -1, opt->go_val);
|
||||||
|
}
|
||||||
} else if (G_OPT_TYPE(opt) == G_TYPE_STRING) {
|
} else if (G_OPT_TYPE(opt) == G_TYPE_STRING) {
|
||||||
gctl_ro_param(req, opt->go_name, -1, val);
|
gctl_ro_param(req, opt->go_name, -1, val);
|
||||||
} else if (G_OPT_TYPE(opt) == G_TYPE_BOOL) {
|
} else if (G_OPT_TYPE(opt) == G_TYPE_BOOL) {
|
||||||
opt->go_val = malloc(sizeof(int));
|
ptr = malloc(sizeof(int));
|
||||||
if (opt->go_val == NULL)
|
if (ptr == NULL)
|
||||||
errx(EXIT_FAILURE, "No memory.");
|
errx(EXIT_FAILURE, "No memory.");
|
||||||
*(int *)opt->go_val = *val - '0';
|
*(int *)ptr = *val - '0';
|
||||||
|
opt->go_val = ptr;
|
||||||
gctl_ro_param(req, opt->go_name, sizeof(int), opt->go_val);
|
gctl_ro_param(req, opt->go_name, sizeof(int), opt->go_val);
|
||||||
} else {
|
} else {
|
||||||
assert(!"Invalid type");
|
assert(!"Invalid type");
|
||||||
@ -354,7 +356,7 @@ parse_arguments(struct g_command *cmd, struct gctl_req *req, int *argc,
|
|||||||
G_OPT_TYPE(opt) == G_TYPE_ASCNUM) {
|
G_OPT_TYPE(opt) == G_TYPE_ASCNUM) {
|
||||||
if (cmd->gc_argname == NULL ||
|
if (cmd->gc_argname == NULL ||
|
||||||
opt->go_val == NULL ||
|
opt->go_val == NULL ||
|
||||||
*(char *)opt->go_val != '\0')
|
*(const char *)opt->go_val != '\0')
|
||||||
gctl_ro_param(req, opt->go_name,
|
gctl_ro_param(req, opt->go_name,
|
||||||
-1, opt->go_val);
|
-1, opt->go_val);
|
||||||
} else {
|
} else {
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
struct g_option {
|
struct g_option {
|
||||||
char go_char;
|
char go_char;
|
||||||
const char *go_name;
|
const char *go_name;
|
||||||
void *go_val;
|
const void *go_val;
|
||||||
unsigned go_type;
|
unsigned go_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ g_eli_ctl_onetime(struct gctl_req *req, struct g_class *mp)
|
|||||||
gctl_error(req, "No '%s' argument.", "aalgo");
|
gctl_error(req, "No '%s' argument.", "aalgo");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (strcmp(name, "none") != 0) {
|
if (*name != '\0') {
|
||||||
md.md_aalgo = g_eli_str2aalgo(name);
|
md.md_aalgo = g_eli_str2aalgo(name);
|
||||||
if (md.md_aalgo >= CRYPTO_ALGORITHM_MIN &&
|
if (md.md_aalgo >= CRYPTO_ALGORITHM_MIN &&
|
||||||
md.md_aalgo <= CRYPTO_ALGORITHM_MAX) {
|
md.md_aalgo <= CRYPTO_ALGORITHM_MAX) {
|
||||||
|
@ -192,7 +192,7 @@ g_mirror_ctl_configure(struct gctl_req *req, struct g_class *mp)
|
|||||||
gctl_error(req, "No such device: %s.", name);
|
gctl_error(req, "No such device: %s.", name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (strcmp(balancep, "none") == 0)
|
if (*balancep == '\0')
|
||||||
balance = sc->sc_balance;
|
balance = sc->sc_balance;
|
||||||
else {
|
else {
|
||||||
if (balance_id(balancep) == -1) {
|
if (balance_id(balancep) == -1) {
|
||||||
@ -215,7 +215,7 @@ g_mirror_ctl_configure(struct gctl_req *req, struct g_class *mp)
|
|||||||
/* Enforce usage() of -p not allowing any other options. */
|
/* Enforce usage() of -p not allowing any other options. */
|
||||||
if (do_priority && (*autosync || *noautosync || *failsync ||
|
if (do_priority && (*autosync || *noautosync || *failsync ||
|
||||||
*nofailsync || *hardcode || *dynamic || *slicep != -1 ||
|
*nofailsync || *hardcode || *dynamic || *slicep != -1 ||
|
||||||
strcmp(balancep, "none") != 0)) {
|
*balancep != '\0')) {
|
||||||
sx_xunlock(&sc->sc_lock);
|
sx_xunlock(&sc->sc_lock);
|
||||||
gctl_error(req, "only -p accepted when setting priority");
|
gctl_error(req, "only -p accepted when setting priority");
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user