mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
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.
This commit is contained in:
parent
e5b345aff3
commit
984ae7f72d
@ -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,
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user