From 898b3d4d78b0ed64aee0e0dcdffb652a3a928a78 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Sat, 27 Jan 2007 02:09:06 +0000 Subject: [PATCH] Fix vgs to treat args as VGs even when PV fields are displayed. --- WHATS_NEW | 1 + tools/reporter.c | 32 +++++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 1d9356a79..311bb5963 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.21 - =================================== + Fix vgs to treat args as VGs even when PV fields are displayed. Fix md signature check to handle both endiannesses. Version 2.02.20 - 25th January 2007 diff --git a/tools/reporter.c b/tools/reporter.c index ad5be4feb..e092aad4d 100644 --- a/tools/reporter.c +++ b/tools/reporter.c @@ -138,6 +138,18 @@ out: return ret; } +static int _pvs_in_vg(struct cmd_context *cmd, const char *vg_name, + struct volume_group *vg, int consistent, + void *handle) +{ + if (!vg) { + log_error("Volume group %s not found", vg_name); + return ECMD_FAILED; + } + + return process_each_pv_in_vg(cmd, vg, NULL, handle, &_pvs_single); +} + static int _report(struct cmd_context *cmd, int argc, char **argv, report_type_t report_type) { @@ -146,8 +158,8 @@ static int _report(struct cmd_context *cmd, int argc, char **argv, char *str; const char *keys = NULL, *options = NULL, *separator; int r = ECMD_PROCESSED; - int aligned, buffered, headings; + unsigned args_are_pvs; aligned = find_config_tree_int(cmd, "report/aligned", DEFAULT_REP_ALIGNED); @@ -158,6 +170,8 @@ static int _report(struct cmd_context *cmd, int argc, char **argv, separator = find_config_tree_str(cmd, "report/separator", DEFAULT_REP_SEPARATOR); + args_are_pvs = (report_type == PVS || report_type == PVSEGS) ? 1 : 0; + switch (report_type) { case LVS: keys = find_config_tree_str(cmd, "report/lvs_sort", @@ -292,16 +306,24 @@ static int _report(struct cmd_context *cmd, int argc, char **argv, report_handle, &_vgs_single); break; case PVS: - r = process_each_pv(cmd, argc, argv, NULL, report_handle, - &_pvs_single); + if (args_are_pvs) + r = process_each_pv(cmd, argc, argv, NULL, + report_handle, &_pvs_single); + else + r = process_each_vg(cmd, argc, argv, LCK_VG_READ, 0, + report_handle, &_pvs_in_vg); break; case SEGS: r = process_each_lv(cmd, argc, argv, LCK_VG_READ, report_handle, &_lvsegs_single); break; case PVSEGS: - r = process_each_pv(cmd, argc, argv, NULL, report_handle, - &_pvsegs_single); + if (args_are_pvs) + r = process_each_pv(cmd, argc, argv, NULL, + report_handle, &_pvsegs_single); + else + r = process_each_vg(cmd, argc, argv, LCK_VG_READ, 0, + report_handle, &_pvs_in_vg); break; }