1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

pvdisplay: split code for variants using command defs

Also fix the use of --all that was mistakenly included
as an accepted option for vgdisplay and two cases of pvdisplay
in commit "tools: enhance lvdisplay vgdisplay pvdisplay"
This commit is contained in:
David Teigland 2024-12-05 14:50:06 -06:00
parent 9beea2db69
commit ccde015712
4 changed files with 21 additions and 56 deletions

View File

@ -209,14 +209,14 @@ OO_ALL: --commandprofile String, --config String, --debug,
# #
# options for pvdisplay, lvdisplay, vgdisplay # options for pvdisplay, lvdisplay, vgdisplay
# #
OO_REPORTING: --all, --configreport ConfigReport, --foreign, OO_REPORTING: --configreport ConfigReport, --foreign,
--ignorelockingfailure, --logonly, --readonly, --reportformat ReportFmt, --ignorelockingfailure, --logonly, --readonly, --reportformat ReportFmt,
--select String, --shared, --units Units --select String, --shared, --units Units
# #
# options for pvs, lvs, vgs, fullreport # options for pvs, lvs, vgs, fullreport
# #
OO_REPORT: OO_REPORTING, --aligned, --binary, OO_REPORT: OO_REPORTING, --all, --aligned, --binary,
--headings HeadingsType, --nameprefixes, --noheadings, --headings HeadingsType, --nameprefixes, --noheadings,
--nosuffix, --options String, --rows, --separator String, --nosuffix, --options String, --rows, --separator String,
--sort String, --unbuffered, --unquoted --sort String, --unbuffered, --unquoted
@ -1400,14 +1400,14 @@ ID: lvdisplay_columns
DESC: Display output in columns like lvs. DESC: Display output in columns like lvs.
lvdisplay --colon lvdisplay --colon
OO: OO_REPORTING, --history, --segments OO: OO_REPORTING, --all, --history, --segments
OP: VG|LV|Tag ... OP: VG|LV|Tag ...
IO: --partial, --ignoreskippedcluster IO: --partial, --ignoreskippedcluster
ID: lvdisplay_colon ID: lvdisplay_colon
DESC: Generate colon separated output. DESC: Generate colon separated output.
lvdisplay lvdisplay
OO: OO_REPORTING, --history, --segments, --maps OO: OO_REPORTING, --all, --history, --segments, --maps
OP: VG|LV|Tag ... OP: VG|LV|Tag ...
IO: --partial, --ignoreskippedcluster IO: --partial, --ignoreskippedcluster
ID: lvdisplay_general ID: lvdisplay_general
@ -1658,6 +1658,7 @@ OO: OO_REPORTING, --maps, --segments, --short
OP: PV|Tag ... OP: PV|Tag ...
IO: --partial, --ignoreskippedcluster IO: --partial, --ignoreskippedcluster
ID: pvdisplay_general ID: pvdisplay_general
DESC: Display Physical Volumes.
--- ---

View File

@ -95,7 +95,8 @@ static const struct command_function _command_functions[CMD_COUNT] = {
/* pvdisplay variants */ /* pvdisplay variants */
{ pvdisplay_columns_CMD, pvdisplay_columns_cmd }, { pvdisplay_columns_CMD, pvdisplay_columns_cmd },
{ pvdisplay_colon_CMD, pvdisplay_colon_cmd }, { pvdisplay_colon_CMD, pvdisplay_cmd },
{ pvdisplay_general_CMD, pvdisplay_cmd },
/* vgdisplay variants */ /* vgdisplay variants */
{ vgdisplay_columns_CMD, vgdisplay_columns_cmd }, { vgdisplay_columns_CMD, vgdisplay_columns_cmd },

View File

@ -44,12 +44,10 @@ static int _pvdisplay_single(struct cmd_context *cmd,
log_print_unless_silent("\"%s\" is a new physical volume of \"%s\"", log_print_unless_silent("\"%s\" is a new physical volume of \"%s\"",
pv_name, display_size(cmd, size)); pv_name, display_size(cmd, size));
if (arg_is_set(cmd, colon_ARG)) { if (arg_is_set(cmd, colon_ARG))
pvdisplay_colons(pv); pvdisplay_colons(pv);
goto out; else
} pvdisplay_full(cmd, pv, NULL);
pvdisplay_full(cmd, pv, NULL);
if (arg_is_set(cmd, maps_ARG)) if (arg_is_set(cmd, maps_ARG))
pvdisplay_segments(pv); pvdisplay_segments(pv);
@ -58,41 +56,13 @@ out:
return ret; return ret;
} }
int pvdisplay(struct cmd_context *cmd, int argc, char **argv) int pvdisplay_cmd(struct cmd_context *cmd, int argc, char **argv)
{ {
int ret; return process_each_pv(cmd, argc, argv, NULL, 0, 0, NULL, _pvdisplay_single);
}
if (arg_is_set(cmd, columns_ARG)) {
if (arg_is_set(cmd, colon_ARG) || arg_is_set(cmd, maps_ARG) ||
arg_is_set(cmd, short_ARG)) {
log_error("Incompatible options selected");
return EINVALID_CMD_LINE;
}
return pvs(cmd, argc, argv);
}
if (arg_is_set(cmd, aligned_ARG) ||
arg_is_set(cmd, all_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, maps_ARG)) {
log_error("Option -c not allowed with option -m");
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;
}
int pvdisplay_columns_cmd(struct cmd_context *cmd, int argc, char **argv)
{
/* /*
* Without -a, command only looks at PVs and can use hints, * Without -a, command only looks at PVs and can use hints,
* with -a, the command looks at all (non-hinted) devices. * with -a, the command looks at all (non-hinted) devices.
@ -100,19 +70,12 @@ int pvdisplay(struct cmd_context *cmd, int argc, char **argv)
if (arg_is_set(cmd, all_ARG)) if (arg_is_set(cmd, all_ARG))
cmd->use_hints = 0; cmd->use_hints = 0;
ret = process_each_pv(cmd, argc, argv, NULL, return pvs(cmd, argc, argv);
arg_is_set(cmd, all_ARG), 0,
NULL, _pvdisplay_single);
return ret;
} }
int pvdisplay_columns_cmd(struct cmd_context *cmd, int argc, char **argv) int pvdisplay(struct cmd_context *cmd, int argc, char **argv)
{ {
return pvdisplay(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;
int pvdisplay_colon_cmd(struct cmd_context *cmd, int argc, char **argv)
{
return pvdisplay(cmd, argc, argv);
} }

View File

@ -192,7 +192,7 @@ int lvdisplay_columns_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvdisplay_colon_cmd(struct cmd_context *cmd, int argc, char **argv); int lvdisplay_colon_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvdisplay_general_cmd(struct cmd_context *cmd, int argc, char **argv); int lvdisplay_general_cmd(struct cmd_context *cmd, int argc, char **argv);
int pvdisplay_columns_cmd(struct cmd_context *cmd, int argc, char **argv); int pvdisplay_columns_cmd(struct cmd_context *cmd, int argc, char **argv);
int pvdisplay_colon_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_columns_cmd(struct cmd_context *cmd, int argc, char **argv);
int vgdisplay_colon_cmd(struct cmd_context *cmd, int argc, char **argv); int vgdisplay_colon_cmd(struct cmd_context *cmd, int argc, char **argv);