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:
parent
9beea2db69
commit
ccde015712
@ -209,14 +209,14 @@ OO_ALL: --commandprofile String, --config String, --debug,
|
||||
#
|
||||
# options for pvdisplay, lvdisplay, vgdisplay
|
||||
#
|
||||
OO_REPORTING: --all, --configreport ConfigReport, --foreign,
|
||||
OO_REPORTING: --configreport ConfigReport, --foreign,
|
||||
--ignorelockingfailure, --logonly, --readonly, --reportformat ReportFmt,
|
||||
--select String, --shared, --units Units
|
||||
|
||||
#
|
||||
# options for pvs, lvs, vgs, fullreport
|
||||
#
|
||||
OO_REPORT: OO_REPORTING, --aligned, --binary,
|
||||
OO_REPORT: OO_REPORTING, --all, --aligned, --binary,
|
||||
--headings HeadingsType, --nameprefixes, --noheadings,
|
||||
--nosuffix, --options String, --rows, --separator String,
|
||||
--sort String, --unbuffered, --unquoted
|
||||
@ -1400,14 +1400,14 @@ ID: lvdisplay_columns
|
||||
DESC: Display output in columns like lvs.
|
||||
|
||||
lvdisplay --colon
|
||||
OO: OO_REPORTING, --history, --segments
|
||||
OO: OO_REPORTING, --all, --history, --segments
|
||||
OP: VG|LV|Tag ...
|
||||
IO: --partial, --ignoreskippedcluster
|
||||
ID: lvdisplay_colon
|
||||
DESC: Generate colon separated output.
|
||||
|
||||
lvdisplay
|
||||
OO: OO_REPORTING, --history, --segments, --maps
|
||||
OO: OO_REPORTING, --all, --history, --segments, --maps
|
||||
OP: VG|LV|Tag ...
|
||||
IO: --partial, --ignoreskippedcluster
|
||||
ID: lvdisplay_general
|
||||
@ -1658,6 +1658,7 @@ OO: OO_REPORTING, --maps, --segments, --short
|
||||
OP: PV|Tag ...
|
||||
IO: --partial, --ignoreskippedcluster
|
||||
ID: pvdisplay_general
|
||||
DESC: Display Physical Volumes.
|
||||
|
||||
---
|
||||
|
||||
|
@ -95,7 +95,8 @@ static const struct command_function _command_functions[CMD_COUNT] = {
|
||||
|
||||
/* pvdisplay variants */
|
||||
{ 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_columns_CMD, vgdisplay_columns_cmd },
|
||||
|
@ -44,12 +44,10 @@ static int _pvdisplay_single(struct cmd_context *cmd,
|
||||
log_print_unless_silent("\"%s\" is a new physical volume of \"%s\"",
|
||||
pv_name, display_size(cmd, size));
|
||||
|
||||
if (arg_is_set(cmd, colon_ARG)) {
|
||||
if (arg_is_set(cmd, colon_ARG))
|
||||
pvdisplay_colons(pv);
|
||||
goto out;
|
||||
}
|
||||
|
||||
pvdisplay_full(cmd, pv, NULL);
|
||||
else
|
||||
pvdisplay_full(cmd, pv, NULL);
|
||||
|
||||
if (arg_is_set(cmd, maps_ARG))
|
||||
pvdisplay_segments(pv);
|
||||
@ -58,41 +56,13 @@ out:
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
return process_each_pv(cmd, argc, argv, NULL, 0, 0, NULL, _pvdisplay_single);
|
||||
}
|
||||
|
||||
int pvdisplay_columns_cmd(struct cmd_context *cmd, int argc, char **argv)
|
||||
{
|
||||
/*
|
||||
* Without -a, command only looks at PVs and can use hints,
|
||||
* 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))
|
||||
cmd->use_hints = 0;
|
||||
|
||||
ret = process_each_pv(cmd, argc, argv, NULL,
|
||||
arg_is_set(cmd, all_ARG), 0,
|
||||
NULL, _pvdisplay_single);
|
||||
|
||||
return ret;
|
||||
return pvs(cmd, argc, argv);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
int pvdisplay_colon_cmd(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;
|
||||
}
|
||||
|
@ -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_general_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_colon_cmd(struct cmd_context *cmd, int argc, char **argv);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user