master - report: add report_for_selection and use it in select_match_{pv, vg, lv}
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=984ae7f72dee4f119eafc4e236a276a6c8a3fc95 Commit: 984ae7f72dee4f119eafc4e236a276a6c8a3fc95 Parent: e5b345aff389af24bde7986b236a92e166435f38 Author: Peter Rajnoha <[email protected]> AuthorDate: Mon Dec 1 14:19:30 2014 +0100 Committer: Peter Rajnoha <[email protected]> CommitterDate: Tue Feb 10 16:05:36 2015 +0100
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.
--- lib/report/report.h | 4 ++++ tools/reporter.c | 8 ++++++++ tools/toollib.c | 33 ++++++++++++++++++++++++++++++--- 3 files changed, 42 insertions(+), 3 deletions(-)
lib/report/report.h +4 -0
@@ -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,
tools/reporter.c +8 -0
@@ -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) {
tools/toollib.c +30 -3
@@ -1628,36 +1628,63 @@ void destroy_processing_handle(struct cmd_context *cmd, struct processing_handleint 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 ; }