diff options
author | pjd <pjd@FreeBSD.org> | 2010-09-14 11:13:46 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2010-09-14 11:13:46 +0000 |
commit | 1896db90b9dc7534f80f6ec2a8b4f41d6564f4b8 (patch) | |
tree | 2dc18672ff17bea92dbda0824e9f9e12930b5907 | |
parent | af9e1720ca752925cc004f5ed7ac7ee609ff51f5 (diff) | |
download | FreeBSD-src-1896db90b9dc7534f80f6ec2a8b4f41d6564f4b8.zip FreeBSD-src-1896db90b9dc7534f80f6ec2a8b4f41d6564f4b8.tar.gz |
Introduce special G_VAL_OPTIONAL define, which when given in value field
tells geom(8) to ignore it when it is not given and don't try to obtain
default value.
-rw-r--r-- | sbin/geom/class/part/geom_part.c | 16 | ||||
-rw-r--r-- | sbin/geom/core/geom.c | 5 | ||||
-rw-r--r-- | sbin/geom/core/geom.h | 2 |
3 files changed, 12 insertions, 11 deletions
diff --git a/sbin/geom/class/part/geom_part.c b/sbin/geom/class/part/geom_part.c index 673d90c..972e2ff 100644 --- a/sbin/geom/class/part/geom_part.c +++ b/sbin/geom/class/part/geom_part.c @@ -90,16 +90,16 @@ struct g_command PUBSYM(class_commands)[] = { { 'b', "start", GPART_AUTOFILL, G_TYPE_STRING }, { 's', "size", GPART_AUTOFILL, G_TYPE_STRING }, { 't', "type", NULL, G_TYPE_STRING }, - { 'i', GPART_PARAM_INDEX, "", G_TYPE_ASCNUM }, - { 'l', "label", "", G_TYPE_STRING }, + { 'i', GPART_PARAM_INDEX, G_VAL_OPTIONAL, G_TYPE_ASCNUM }, + { 'l', "label", G_VAL_OPTIONAL, G_TYPE_STRING }, { 'f', "flags", GPART_FLAGS, G_TYPE_STRING }, G_OPT_SENTINEL }, "[-b start] [-s size] -t type [-i index] [-l label] [-f flags] geom" }, { "bootcode", 0, gpart_bootcode, { - { 'b', GPART_PARAM_BOOTCODE, "", G_TYPE_STRING }, - { 'p', GPART_PARAM_PARTCODE, "", G_TYPE_STRING }, - { 'i', GPART_PARAM_INDEX, "", G_TYPE_ASCNUM }, + { 'b', GPART_PARAM_BOOTCODE, G_VAL_OPTIONAL, G_TYPE_STRING }, + { 'p', GPART_PARAM_PARTCODE, G_VAL_OPTIONAL, G_TYPE_STRING }, + { 'i', GPART_PARAM_INDEX, G_VAL_OPTIONAL, G_TYPE_ASCNUM }, { 'f', "flags", GPART_FLAGS, G_TYPE_STRING }, G_OPT_SENTINEL }, "bootcode [-b bootcode] [-p partcode] [-i index] [-f flags] geom" @@ -109,7 +109,7 @@ struct g_command PUBSYM(class_commands)[] = { }, { "create", 0, gpart_issue, { { 's', "scheme", NULL, G_TYPE_STRING }, - { 'n', "entries", "", G_TYPE_ASCNUM }, + { 'n', "entries", G_VAL_OPTIONAL, G_TYPE_ASCNUM }, { 'f', "flags", GPART_FLAGS, G_TYPE_STRING }, G_OPT_SENTINEL }, "-s scheme [-n entries] [-f flags] provider" @@ -127,8 +127,8 @@ struct g_command PUBSYM(class_commands)[] = { }, { "modify", 0, gpart_issue, { { 'i', GPART_PARAM_INDEX, NULL, G_TYPE_ASCNUM }, - { 'l', "label", "", G_TYPE_STRING }, - { 't', "type", "", G_TYPE_STRING }, + { 'l', "label", G_VAL_OPTIONAL, G_TYPE_STRING }, + { 't', "type", G_VAL_OPTIONAL, G_TYPE_STRING }, { 'f', "flags", GPART_FLAGS, G_TYPE_STRING }, G_OPT_SENTINEL }, "-i index [-l label] [-t type] [-f flags] geom" diff --git a/sbin/geom/core/geom.c b/sbin/geom/core/geom.c index 39731e9..d83a232 100644 --- a/sbin/geom/core/geom.c +++ b/sbin/geom/core/geom.c @@ -374,9 +374,8 @@ 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 (opt->go_val == G_VAL_OPTIONAL) { + /* add nothing. */ } else { set_option(req, opt, opt->go_val); } diff --git a/sbin/geom/core/geom.h b/sbin/geom/core/geom.h index c88005e..a148dda 100644 --- a/sbin/geom/core/geom.h +++ b/sbin/geom/core/geom.h @@ -53,6 +53,8 @@ #define G_OPT_NUM(opt) (((opt)->go_type & G_TYPE_NUMMASK) >> G_TYPE_NUMSHIFT) #define G_OPT_NUMINC(opt) ((opt)->go_type += (1 << G_TYPE_NUMSHIFT)) +#define G_VAL_OPTIONAL ((void *)-1) + #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 } |