"To see the bootloader area start and size of\n"
"an existing PV use pvs -o +pv_ba_start,pv_ba_size.\n")
-arg(cache_long_ARG, '\0', "cache", 0, 0, 0,
+arg(cache_long_ARG, '\0', "cache", 0, ARG_LONG_OPT, 0,
"#pvscan\n"
"Scan one or more devices and record that they are online.\n"
"#vgscan\n"
"(Also see dm-thin-pool kernel module option no_space_timeout.)\n"
"See \\fBlvmthin\\fP(7) for more information.\n")
-arg(force_long_ARG, '\0', "force", 0, ARG_COUNTABLE, 0,
+arg(force_long_ARG, '\0', "force", 0, ARG_COUNTABLE | ARG_LONG_OPT, 0,
"Force metadata restore even with thin pool LVs.\n"
"Use with extreme caution. Most changes to thin metadata\n"
"cannot be reverted.\n"
arg(startpoll_ARG, '\0', "startpoll", 0, 0, 0,
"Start polling an LV to continue processing a conversion.\n")
-arg(stripes_long_ARG, '\0', "stripes", number_VAL, 0, 0,
+arg(stripes_long_ARG, '\0', "stripes", number_VAL, ARG_LONG_OPT, 0,
"Specifies the number of stripes in a striped LV. This is the number of\n"
"PVs (devices) that a striped LV is spread across. Data that\n"
"appears sequential in the LV is spread across multiple devices in units of\n"
/* create table of option names, e.g. --foo, and corresponding enum from args.h */
static const struct opt_name opt_names[ARG_COUNT + 1] = {
-#define arg(a, b, c, d, e, f, g) { # a, b, a, "--" c, d, e, f, g },
+#define arg(a, b, c, d, e, f, g) { g, "--" c, b, a, d, e, f },
#include "args.h"
#undef arg
};
* check left & right side for possible match
*/
for (i = middle;;) {
- if ((!p && !strstr(opt_names_alpha[i]->name, "_long_ARG")) ||
+ if ((!p && !(opt_names_alpha[i]->flags & ARG_LONG_OPT)) ||
(p && !opt_names_alpha[i]->short_opt))
return opt_names_alpha[i]->opt_enum; /* Found */
/* Check if there is something on the 'left-side' */
for (i = middle + 1; i <= last; ++i) {
if (strcmp(opt_names_alpha[i]->long_opt, long_name))
break;
- if ((!p && !strstr(opt_names_alpha[i]->name, "_long_ARG")) ||
+ if ((!p && !(opt_names_alpha[i]->flags & ARG_LONG_OPT)) ||
(p && !opt_names_alpha[i]->short_opt))
return opt_names_alpha[i]->opt_enum; /* Found */
}
/* see global opt_names[] */
struct opt_name {
- const char name[27]; /* "foo_ARG" */
+ const char *desc;
+ const char long_opt[27];/* --foo */
const char short_opt; /* -f */
uint16_t opt_enum; /* foo_ARG */
- const char long_opt[28]; /* --foo */
uint16_t val_enum; /* xyz_VAL when --foo takes a val like "--foo xyz" */
uint16_t flags;
uint16_t prio;
- const char *desc;
};
/* see global val_names[] */
* For now, any command id not included here uses the old command fn.
*/
static const struct command_function _command_functions[CMD_COUNT] = {
+ { CMD_NONE, NULL },
{ lvmconfig_general_CMD, lvmconfig },
{ lvchange_properties_CMD, lvchange_properties_cmd },
{ lvchange_resync_CMD, lvchange_resync_cmd },
static command_fn _find_command_id_function(int command_enum)
{
- int i;
-
- if (!command_enum)
- return NULL;
+ unsigned i;
- for (i = 0; i < CMD_COUNT; i++) {
+ for (i = 0; i < CMD_COUNT; i++)
if (_command_functions[i].command_enum == command_enum)
return _command_functions[i].fn;
- }
+
return NULL;
}
#define ARG_COUNTABLE 0x00000001
#define ARG_GROUPABLE 0x00000002
#define ARG_NONINTERACTIVE 0x00000004
+#define ARG_LONG_OPT 0x00000008
struct arg_values;
/* needed to include vals.h */
#define ARG_COUNTABLE 0x00000001 /* E.g. -vvvv */
#define ARG_GROUPABLE 0x00000002 /* E.g. --addtag */
#define ARG_NONINTERACTIVE 0x00000004 /* only for use in noninteractive mode */
+#define ARG_LONG_OPT 0x00000008 /* arg has long format option */
struct arg_values {
char *value;