summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2017-02-08 10:33:16 -0600
committerDavid Teigland <teigland@redhat.com>2017-02-08 10:33:16 -0600
commitc8945374d58651b33184f17dc26cb08fa8929b68 (patch)
tree3f255335dd3c3b2341678f646a8caf1c53498856
parent1f67df932d94a2fcdf67e1d4689a5cce8ef87285 (diff)
downloadlvm2-c8945374d58651b33184f17dc26cb08fa8929b68.tar.gz
commands: rename structure fields
remove "line" from command_line_id/command_line_enum
-rw-r--r--tools/command.c2
-rw-r--r--tools/command.h11
-rw-r--r--tools/lvchange.c10
-rw-r--r--tools/lvconvert.c26
-rw-r--r--tools/lvmcmdline.c22
-rw-r--r--tools/toollib.c6
6 files changed, 39 insertions, 38 deletions
diff --git a/tools/command.c b/tools/command.c
index 71c52cd21..beebd8b9e 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -1356,7 +1356,7 @@ int define_commands(void)
}
if (is_id_line(line_argv[0])) {
- cmd->command_line_id = strdup(line_argv[1]);
+ cmd->command_id = strdup(line_argv[1]);
continue;
}
diff --git a/tools/command.h b/tools/command.h
index 7cacc1a1f..298488540 100644
--- a/tools/command.h
+++ b/tools/command.h
@@ -22,11 +22,11 @@ struct cmd_context;
typedef int (*command_fn) (struct cmd_context *cmd, int argc, char **argv);
/* new per-command-line-id functions */
-typedef int (*command_line_fn) (struct cmd_context *cmd, int argc, char **argv);
+typedef int (*command_id_fn) (struct cmd_context *cmd, int argc, char **argv);
struct command_function {
- int command_line_enum;
- command_line_fn fn;
+ int command_enum;
+ command_id_fn fn;
};
#define MAX_COMMAND_NAMES 64
@@ -171,8 +171,9 @@ struct cmd_rule {
struct command {
const char *name;
const char *desc; /* specific command description from command-lines.h */
- const char *command_line_id; /* ID string in command-lines.in */
- int command_line_enum; /* <command_line_id>_CMD */
+ const char *command_id; /* ID string in command-lines.in */
+ int command_enum; /* <command_id>_CMD */
+ int command_index; /* position in commands[] */
struct command_function *functions; /* new style */
command_fn fn; /* old style */
diff --git a/tools/lvchange.c b/tools/lvchange.c
index b75d0581d..2aaeb0827 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1017,7 +1017,7 @@ static int _lvchange_properties_check(struct cmd_context *cmd,
if (!lv_is_visible(lv)) {
if (lv_is_named_arg)
log_error("Operation not permitted (%s %d) on hidden LV %s.",
- cmd->command->command_line_id, cmd->command->command_line_enum,
+ cmd->command->command_id, cmd->command->command_enum,
display_lvname(lv));
return 0;
}
@@ -1130,7 +1130,7 @@ static int _lvchange_activate_check(struct cmd_context *cmd,
if (!lv_is_visible(lv)) {
if (lv_is_named_arg)
log_error("Operation not permitted (%s %d) on hidden LV %s.",
- cmd->command->command_line_id, cmd->command->command_line_enum,
+ cmd->command->command_id, cmd->command->command_enum,
display_lvname(lv));
return 0;
}
@@ -1186,7 +1186,7 @@ static int _lvchange_refresh_check(struct cmd_context *cmd,
if (!lv_is_visible(lv)) {
if (lv_is_named_arg)
log_error("Operation not permitted (%s %d) on hidden LV %s.",
- cmd->command->command_line_id, cmd->command->command_line_enum,
+ cmd->command->command_id, cmd->command->command_enum,
display_lvname(lv));
return 0;
}
@@ -1368,7 +1368,7 @@ static int _lvchange_persistent_check(struct cmd_context *cmd,
if (!lv_is_visible(lv)) {
if (lv_is_named_arg)
log_error("Operation not permitted (%s %d) on hidden LV %s.",
- cmd->command->command_line_id, cmd->command->command_line_enum,
+ cmd->command->command_id, cmd->command->command_enum,
display_lvname(lv));
return 0;
}
@@ -1386,7 +1386,7 @@ int lvchange_persistent_cmd(struct cmd_context *cmd, int argc, char **argv)
int lvchange(struct cmd_context *cmd, int argc, char **argv)
{
log_error(INTERNAL_ERROR "Missing function for command definition %s.",
- cmd->command->command_line_id);
+ cmd->command->command_id);
return ECMD_FAILED;
}
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 3d0a8cd2c..0a0702a05 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3718,7 +3718,7 @@ static int _lvconvert_to_pool_single(struct cmd_context *cmd,
int to_thinpool = 0;
int to_cachepool = 0;
- switch (cmd->command->command_line_enum) {
+ switch (cmd->command->command_enum) {
case lvconvert_to_thinpool_CMD:
to_thinpool = 1;
break;
@@ -3767,7 +3767,7 @@ int lvconvert_to_pool_noarg_cmd(struct cmd_context *cmd, int argc, char **argv)
char *pool_data_name;
int i, p;
- switch (cmd->command->command_line_enum) {
+ switch (cmd->command->command_enum) {
case lvconvert_to_thinpool_noarg_CMD:
pool_data_name = (char *)arg_str_value(cmd, thinpool_ARG, NULL);
new_command = get_command(lvconvert_to_thinpool_CMD);
@@ -3782,8 +3782,8 @@ int lvconvert_to_pool_noarg_cmd(struct cmd_context *cmd, int argc, char **argv)
};
log_debug("Changing command line id %s %d to standard form %s %d",
- cmd->command->command_line_id, cmd->command->command_line_enum,
- new_command->command_line_id, new_command->command_line_enum);
+ cmd->command->command_id, cmd->command->command_enum,
+ new_command->command_id, new_command->command_enum);
/* Make the LV the first position arg. */
@@ -4046,7 +4046,7 @@ int lvconvert_swap_pool_metadata_noarg_cmd(struct cmd_context *cmd, int argc, ch
struct command *new_command;
char *pool_name;
- switch (cmd->command->command_line_enum) {
+ switch (cmd->command->command_enum) {
case lvconvert_swap_thinpool_metadata_CMD:
pool_name = (char *)arg_str_value(cmd, thinpool_ARG, NULL);
break;
@@ -4061,8 +4061,8 @@ int lvconvert_swap_pool_metadata_noarg_cmd(struct cmd_context *cmd, int argc, ch
new_command = get_command(lvconvert_swap_pool_metadata_CMD);
log_debug("Changing command line id %s %d to standard form %s %d",
- cmd->command->command_line_id, cmd->command->command_line_enum,
- new_command->command_line_id, new_command->command_line_enum);
+ cmd->command->command_id, cmd->command->command_enum,
+ new_command->command_id, new_command->command_enum);
/* Make the LV the first position arg. */
@@ -4126,7 +4126,7 @@ static int _lvconvert_split_cachepool_single(struct cmd_context *cmd,
return ECMD_FAILED;
}
- switch (cmd->command->command_line_enum) {
+ switch (cmd->command->command_enum) {
case lvconvert_split_and_keep_cachepool_CMD:
ret = _lvconvert_split_and_keep_cachepool(cmd, cache_lv, cachepool_lv);
break;
@@ -4147,7 +4147,7 @@ static int _lvconvert_split_cachepool_single(struct cmd_context *cmd,
int lvconvert_split_cachepool_cmd(struct cmd_context *cmd, int argc, char **argv)
{
- if (cmd->command->command_line_enum == lvconvert_split_and_remove_cachepool_CMD) {
+ if (cmd->command->command_enum == lvconvert_split_and_remove_cachepool_CMD) {
cmd->handles_missing_pvs = 1;
cmd->partial_activation = 1;
}
@@ -4227,7 +4227,7 @@ static int _lvconvert_raid_types_check(struct cmd_context *cmd, struct logical_v
case cachepool_LVT:
case snapshot_LVT:
log_error("Operation not permitted (%s %d) on LV %s type %s.",
- cmd->command->command_line_id, cmd->command->command_line_enum,
+ cmd->command->command_id, cmd->command->command_enum,
display_lvname(lv), lvtype ? lvtype->name : "unknown");
return 0;
}
@@ -4236,7 +4236,7 @@ static int _lvconvert_raid_types_check(struct cmd_context *cmd, struct logical_v
fail_hidden:
log_error("Operation not permitted (%s %d) on hidden LV %s.",
- cmd->command->command_line_id, cmd->command->command_line_enum,
+ cmd->command->command_id, cmd->command->command_enum,
display_lvname(lv));
return 0;
}
@@ -4297,7 +4297,7 @@ static int _lvconvert_visible_check(struct cmd_context *cmd, struct logical_volu
{
if (!lv_is_visible(lv)) {
log_error("Operation not permitted (%s %d) on hidden LV %s.",
- cmd->command->command_line_id, cmd->command->command_line_enum,
+ cmd->command->command_id, cmd->command->command_enum,
display_lvname(lv));
return 0;
}
@@ -4517,7 +4517,7 @@ int lvconvert_merge_cmd(struct cmd_context *cmd, int argc, char **argv)
int lvconvert(struct cmd_context *cmd, int argc, char **argv)
{
log_error(INTERNAL_ERROR "Missing function for command definition %s.",
- cmd->command->command_line_id);
+ cmd->command->command_id);
return ECMD_FAILED;
}
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index a7bb69688..fabfee34e 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1112,15 +1112,15 @@ static struct command_name *find_command_name(const char *name)
return NULL;
}
-static struct command_function *_find_command_id_function(int command_line_enum)
+static struct command_function *_find_command_id_function(int command_enum)
{
int i;
- if (!command_line_enum)
+ if (!command_enum)
return NULL;
for (i = 0; i < CMD_COUNT; i++) {
- if (command_functions[i].command_line_enum == command_line_enum)
+ if (command_functions[i].command_enum == command_enum)
return &command_functions[i];
}
return NULL;
@@ -1145,10 +1145,10 @@ void lvm_register_commands(void)
_cmdline.num_commands = COMMAND_COUNT;
for (i = 0; i < COMMAND_COUNT; i++) {
- commands[i].command_line_enum = command_id_to_enum(commands[i].command_line_id);
+ commands[i].command_enum = command_id_to_enum(commands[i].command_id);
/* new style */
- commands[i].functions = _find_command_id_function(commands[i].command_line_enum);
+ commands[i].functions = _find_command_id_function(commands[i].command_enum);
/* old style */
if (!commands[i].functions) {
@@ -1188,7 +1188,7 @@ struct command *get_command(int cmd_enum)
int i;
for (i = 0; i < COMMAND_COUNT; i++) {
- if (commands[i].command_line_enum == cmd_enum)
+ if (commands[i].command_enum == cmd_enum)
return &commands[i];
}
@@ -1560,7 +1560,7 @@ static struct command *_find_command(struct cmd_context *cmd, const char *path,
if (best_unused_count) {
for (i = 0; i < best_unused_count; i++) {
log_error("Invalid option for command (%s %d): %s.",
- commands[best_i].command_line_id, best_i,
+ commands[best_i].command_id, best_i,
arg_long_option_name(best_unused_options[i]));
}
return NULL;
@@ -1591,7 +1591,7 @@ static struct command *_find_command(struct cmd_context *cmd, const char *path,
if (count >= (commands[best_i].rp_count + commands[best_i].op_count)) {
log_error("Invalid positional argument for command (%s %d): %s.",
- commands[best_i].command_line_id, best_i, argv[count]);
+ commands[best_i].command_id, best_i, argv[count]);
/* FIXME: to warn/ignore, clear so it can't be used when processing. */
/*
@@ -1636,7 +1636,7 @@ out:
memset(buf, 0, sizeof(buf));
opt_array_to_str(cmd, rule->check_opts, rule->check_opts_count, buf, sizeof(buf));
log_error("Invalid options for command (%s %d): %s",
- commands[best_i].command_line_id, best_i, buf);
+ commands[best_i].command_id, best_i, buf);
return NULL;
}
@@ -1644,13 +1644,13 @@ out:
memset(buf, 0, sizeof(buf));
opt_array_to_str(cmd, rule->check_opts, rule->check_opts_count, buf, sizeof(buf));
log_error("Required options for command (%s %d): %s",
- commands[best_i].command_line_id, best_i, buf);
+ commands[best_i].command_id, best_i, buf);
return NULL;
}
}
}
- log_debug("command line id: %s %d", commands[best_i].command_line_id, best_i);
+ log_debug("command line id: %s %d", commands[best_i].command_id, best_i);
return &commands[best_i];
}
diff --git a/tools/toollib.c b/tools/toollib.c
index 0026ae826..9dccb4e25 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -2689,7 +2689,7 @@ static int _check_lv_types(struct cmd_context *cmd, struct logical_volume *lv, i
if (!val_bit_is_set(cmd->command->required_pos_args[pos-1].def.val_bits, lv_VAL)) {
log_error(INTERNAL_ERROR "Command (%s %d) arg position %d does not permit an LV (%llx)",
- cmd->command->command_line_id, cmd->command->command_line_enum,
+ cmd->command->command_id, cmd->command->command_enum,
pos, (unsigned long long)cmd->command->required_pos_args[pos-1].def.val_bits);
return 0;
}
@@ -3106,7 +3106,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
/* FIXME: include this result in report log? */
if (lv_is_named_arg) {
log_error("Operation not permitted (%s %d) on LV %s.",
- cmd->command->command_line_id, cmd->command->command_line_enum,
+ cmd->command->command_id, cmd->command->command_enum,
display_lvname(lvl->lv));
ret_max = ECMD_FAILED;
}
@@ -3117,7 +3117,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
/* FIXME: include this result in report log? */
if (lv_is_named_arg) {
log_error("Operation not permitted (%s %d) on LV %s.",
- cmd->command->command_line_id, cmd->command->command_line_enum,
+ cmd->command->command_id, cmd->command->command_enum,
display_lvname(lvl->lv));
ret_max = ECMD_FAILED;
}