diff options
author | Peter Rajnoha <prajnoha@redhat.com> | 2014-12-01 14:19:30 +0100 |
---|---|---|
committer | Peter Rajnoha <prajnoha@redhat.com> | 2015-02-10 16:05:36 +0100 |
commit | 984ae7f72dee4f119eafc4e236a276a6c8a3fc95 (patch) | |
tree | 0a31611f8c08a593f13f3967b37ab32f00ca3da8 | |
parent | e5b345aff389af24bde7986b236a92e166435f38 (diff) | |
download | lvm2-984ae7f72dee4f119eafc4e236a276a6c8a3fc95.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 | 33 |
3 files changed, 42 insertions, 3 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 4e41e90bc..730195686 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 7d406ba62..34286e328 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -1628,36 +1628,63 @@ void destroy_processing_handle(struct cmd_context *cmd, struct processing_handle int select_match_vg(struct cmd_context *cmd, struct processing_handle *handle, struct volume_group *vg, int *selected) { + struct selection_handle *sh = handle->selection_handle; + if (!handle->internal_report_for_select) { *selected = 1; return 1; } - *selected = 1; + sh->orig_report_type = VGS; + + if (!report_for_selection(sh, NULL, vg, NULL)) + return_0; + + sh->orig_report_type = 0; + *selected = sh->selected; + return 1; } int select_match_lv(struct cmd_context *cmd, struct processing_handle *handle, struct volume_group *vg, struct logical_volume *lv, int *selected) { + struct selection_handle *sh = handle->selection_handle; + if (!handle->internal_report_for_select) { *selected = 1; return 1; } - *selected = 1; + sh->orig_report_type = LVS; + + if (!report_for_selection(sh, NULL, vg, lv)) + return_0; + + sh->orig_report_type = 0; + *selected = sh->selected; + return 1; } int select_match_pv(struct cmd_context *cmd, struct processing_handle *handle, struct volume_group *vg, struct physical_volume *pv, int *selected) { + struct selection_handle *sh = handle->selection_handle; + if (!handle->internal_report_for_select) { *selected = 1; return 1; } - *selected = 1; + sh->orig_report_type = PVS; + + if (!report_for_selection(sh, pv, vg, NULL)) + return_0; + + sh->orig_report_type = 0; + *selected = sh->selected; + return 1; } |