diff --git a/tools/command-lines.in b/tools/command-lines.in index 0ee778274..b25b1ad02 100644 --- a/tools/command-lines.in +++ b/tools/command-lines.in @@ -1874,7 +1874,7 @@ ID: vgcreate_general --- vgdisplay --columns -OO: OO_REPORT, --activevolumegroups +OO: OO_REPORT OP: VG|Tag ... IO: --partial, --ignoreskippedcluster RULE: --noheadings not --headings diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c index 05d19d9f8..be50473c8 100644 --- a/tools/lvmcmdline.c +++ b/tools/lvmcmdline.c @@ -101,6 +101,7 @@ static const struct command_function _command_functions[CMD_COUNT] = { /* vgdisplay variants */ { vgdisplay_columns_CMD, vgdisplay_columns_cmd }, { vgdisplay_colon_CMD, vgdisplay_colon_cmd }, + { vgdisplay_general_CMD, vgdisplay_general_cmd }, /* lvconvert utilities related to repair. */ { lvconvert_repair_CMD, lvconvert_repair_cmd }, diff --git a/tools/tools.h b/tools/tools.h index 6215fcd39..d169f2591 100644 --- a/tools/tools.h +++ b/tools/tools.h @@ -195,6 +195,7 @@ int pvdisplay_columns_cmd(struct cmd_context *cmd, int argc, char **argv); int pvdisplay_cmd(struct cmd_context *cmd, int argc, char **argv); int vgdisplay_columns_cmd(struct cmd_context *cmd, int argc, char **argv); int vgdisplay_colon_cmd(struct cmd_context *cmd, int argc, char **argv); +int vgdisplay_general_cmd(struct cmd_context *cmd, int argc, char **argv); int lvconvert_repair_cmd(struct cmd_context *cmd, int argc, char **argv); int lvconvert_replace_pv_cmd(struct cmd_context *cmd, int argc, char **argv); diff --git a/tools/vgdisplay.c b/tools/vgdisplay.c index f4795e8c5..421dadec5 100644 --- a/tools/vgdisplay.c +++ b/tools/vgdisplay.c @@ -15,24 +15,31 @@ #include "tools.h" -static int _vgdisplay_single(struct cmd_context *cmd, const char *vg_name, +static int _vgdisplay_colon_single(struct cmd_context *cmd, const char *vg_name, struct volume_group *vg, struct processing_handle *handle __attribute__((unused))) { if (arg_is_set(cmd, activevolumegroups_ARG) && !lvs_in_vg_activated(vg)) return ECMD_PROCESSED; - if (arg_is_set(cmd, colon_ARG)) { - vgdisplay_colons(vg); + vgdisplay_colons(vg); + + return ECMD_PROCESSED; +} + +static int _vgdisplay_general_single(struct cmd_context *cmd, const char *vg_name, + struct volume_group *vg, + struct processing_handle *handle __attribute__((unused))) +{ + if (arg_is_set(cmd, activevolumegroups_ARG) && !lvs_in_vg_activated(vg)) return ECMD_PROCESSED; - } if (arg_is_set(cmd, short_ARG)) { vgdisplay_short(vg); return ECMD_PROCESSED; } - vgdisplay_full(vg); /* was vg_show */ + vgdisplay_full(vg); if (arg_is_set(cmd, verbose_ARG)) { vgdisplay_extents(vg); @@ -50,70 +57,35 @@ static int _vgdisplay_single(struct cmd_context *cmd, const char *vg_name, return ECMD_PROCESSED; } -int vgdisplay(struct cmd_context *cmd, int argc, char **argv) +int vgdisplay_colon_cmd(struct cmd_context *cmd, int argc, char **argv) { - if (arg_is_set(cmd, columns_ARG)) { - if (arg_is_set(cmd, colon_ARG) || - arg_is_set(cmd, activevolumegroups_ARG) || - arg_is_set(cmd, short_ARG)) { - log_error("Incompatible options selected"); - return EINVALID_CMD_LINE; - } - return vgs(cmd, argc, argv); - } - - if (arg_is_set(cmd, aligned_ARG) || - arg_is_set(cmd, binary_ARG) || - arg_is_set(cmd, noheadings_ARG) || - arg_is_set(cmd, options_ARG) || - arg_is_set(cmd, separator_ARG) || - arg_is_set(cmd, sort_ARG) || - arg_is_set(cmd, unbuffered_ARG)) { - log_error("Incompatible options selected."); - return EINVALID_CMD_LINE; - } - - if (arg_is_set(cmd, colon_ARG) && arg_is_set(cmd, short_ARG)) { - log_error("Option -c is not allowed with option -s"); - return EINVALID_CMD_LINE; - } - if (argc && arg_is_set(cmd, activevolumegroups_ARG)) { log_error("Option -A is not allowed with volume group names"); return EINVALID_CMD_LINE; } -/********* FIXME: Do without this - or else 2(+) passes! - Figure out longest volume group name - for (c = opt; opt < argc; opt++) { - len = strlen(argv[opt]); - if (len > max_len) - max_len = len; + return process_each_vg(cmd, argc, argv, NULL, NULL, 0, 0, NULL, _vgdisplay_colon_single); +} + +int vgdisplay_general_cmd(struct cmd_context *cmd, int argc, char **argv) +{ + if (argc && arg_is_set(cmd, activevolumegroups_ARG)) { + log_error("Option -A is not allowed with volume group names"); + return EINVALID_CMD_LINE; } -**********/ - return process_each_vg(cmd, argc, argv, NULL, NULL, 0, 0, NULL, - _vgdisplay_single); - -/******** FIXME Need to count number processed - Add this to process_each_vg if arg_is_set(cmd,activevolumegroups_ARG) ? - - if (opt == argc) { - log_print("no "); - if (arg_is_set(cmd,activevolumegroups_ARG)) - printf("active "); - printf("volume groups found\n\n"); - return LVM_E_NO_VG; - } -************/ + return process_each_vg(cmd, argc, argv, NULL, NULL, 0, 0, NULL, _vgdisplay_general_single); } int vgdisplay_columns_cmd(struct cmd_context *cmd, int argc, char **argv) { - return vgdisplay(cmd, argc, argv); + return vgs(cmd, argc, argv); } -int vgdisplay_colon_cmd(struct cmd_context *cmd, int argc, char **argv) +int vgdisplay(struct cmd_context *cmd, int argc, char **argv) { - return vgdisplay(cmd, argc, argv); + log_error(INTERNAL_ERROR "Missing function for command definition %d:%s.", + cmd->command->command_index, command_enum(cmd->command->command_enum)); + return ECMD_FAILED; } +