diff options
author | Peter Rajnoha <prajnoha@redhat.com> | 2014-12-01 14:19:30 +0100 |
---|---|---|
committer | Peter Rajnoha <prajnoha@redhat.com> | 2015-02-09 14:20:27 +0100 |
commit | e739a4983eaf36f13151cbacb157534914bf1818 (patch) | |
tree | 58e79f1d236988b17f87dd279e3b68cf0eb7022c | |
parent | fe28f7d26287617070dc5aca233a39ff88d311d4 (diff) | |
download | lvm2-e739a4983eaf36f13151cbacb157534914bf1818.tar.gz |
report: add report_for_selection and use it in select_match_{pv,vg,lv}
The report_for_selection does the actual "reporting for selection only".
The selection status will be saved in struct selection_handle's "selected"
variable.
-rw-r--r-- | lib/report/report.h | 4 | ||||
-rw-r--r-- | tools/reporter.c | 8 | ||||
-rw-r--r-- | tools/toollib.c | 45 |
3 files changed, 51 insertions, 6 deletions
diff --git a/lib/report/report.h b/lib/report/report.h index 80a75fd7a..5bd8b7930 100644 --- a/lib/report/report.h +++ b/lib/report/report.h @@ -71,6 +71,10 @@ void *report_init(struct cmd_context *cmd, const char *format, const char *keys, int quoted, int columns_as_rows, const char *selection); void *report_init_for_selection(struct cmd_context *cmd, report_type_t *report_type, const char *selection); +int report_for_selection(struct selection_handle *sh, + struct physical_volume *pv, + struct volume_group *vg, + struct logical_volume *lv); void report_free(void *handle); int report_object(void *handle, int selection_only, const struct volume_group *vg, const struct logical_volume *lv, const struct physical_volume *pv, diff --git a/tools/reporter.c b/tools/reporter.c index 56d453424..1c06fc1f2 100644 --- a/tools/reporter.c +++ b/tools/reporter.c @@ -447,6 +447,14 @@ static int _get_final_report_type(int args_are_pvs, return 1; } +int report_for_selection(struct selection_handle *sh, + struct physical_volume *pv, + struct volume_group *vg, + struct logical_volume *lv) +{ + return 1; +} + static int _report(struct cmd_context *cmd, int argc, char **argv, report_type_t report_type) { diff --git a/tools/toollib.c b/tools/toollib.c index 689fbe176..3d592047b 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -1620,10 +1620,21 @@ int select_match_vg(struct cmd_context *cmd, struct processing_handle *handle, struct volume_group *vg) { + struct selection_handle *sh = handle->selection_handle; + int r = 1; + if (handle->direct_reporting) - return 1; + goto out; - return 1; + sh->orig_report_type = VGS; + + if (!report_for_selection(sh, NULL, vg, NULL)) + goto_out; + + sh->orig_report_type = 0; + r = sh->selected; +out: + return r; } int select_match_lv(struct cmd_context *cmd, @@ -1631,10 +1642,21 @@ int select_match_lv(struct cmd_context *cmd, struct volume_group *vg, struct logical_volume *lv) { + struct selection_handle *sh = handle->selection_handle; + int r = 1; + if (handle->direct_reporting) - return 1; + goto out; - return 1; + sh->orig_report_type = LVS; + + if (!report_for_selection(sh, NULL, vg, lv)) + goto_out; + + sh->orig_report_type = 0; + r = sh->selected; +out: + return r; } int select_match_pv(struct cmd_context *cmd, @@ -1642,10 +1664,21 @@ int select_match_pv(struct cmd_context *cmd, struct volume_group *vg, struct physical_volume *pv) { + struct selection_handle *sh = handle->selection_handle; + int r = 1; + if (handle->direct_reporting) - return 1; + goto out; - return 1; + sh->orig_report_type = PVS; + + if (!report_for_selection(sh, pv, vg, NULL)) + return_0; + + sh->orig_report_type = 0; + r = sh->selected; +out: + return r; } static int _process_vgnameid_list(struct cmd_context *cmd, uint32_t flags, |