1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

toollib: pass struct processing_handle to _select_match_* functions

The "struct processing_handle" contains handles to drive the selection/matching
so pass it to the _select_match_* functions which are entry points to the
selection mechanism used in process_each_* and related functions.

This is revised and edited version of former Dave Teigland's patch which
provided starting point for all the select support in process_each_* fns.
This commit is contained in:
Peter Rajnoha 2014-11-28 14:34:56 +01:00
parent a64b39aef8
commit c3180c4a05
2 changed files with 30 additions and 14 deletions

View File

@ -1542,22 +1542,38 @@ static int _get_vgnameids_on_system(struct cmd_context *cmd,
return ECMD_PROCESSED;
}
int select_match_vg(struct cmd_context *cmd, struct volume_group *vg, int *selected)
int select_match_vg(struct cmd_context *cmd, struct processing_handle *handle,
struct volume_group *vg, int *selected)
{
if (!handle->internal_report_for_select) {
*selected = 1;
return 1;
}
*selected = 1;
return 1;
}
int select_match_lv(struct cmd_context *cmd, struct volume_group *vg,
struct logical_volume *lv, int *selected)
int select_match_lv(struct cmd_context *cmd, struct processing_handle *handle,
struct volume_group *vg, struct logical_volume *lv, int *selected)
{
if (!handle->internal_report_for_select) {
*selected = 1;
return 1;
}
*selected = 1;
return 1;
}
int select_match_pv(struct cmd_context *cmd, struct volume_group *vg,
struct physical_volume *pv, int *selected)
int select_match_pv(struct cmd_context *cmd, struct processing_handle *handle,
struct volume_group *vg, struct physical_volume *pv, int *selected)
{
if (!handle->internal_report_for_select) {
*selected = 1;
return 1;
}
*selected = 1;
return 1;
}
@ -1609,7 +1625,7 @@ static int _process_vgnameid_list(struct cmd_context *cmd, uint32_t flags,
if ((process_all ||
(!dm_list_empty(arg_vgnames) && str_list_match_item(arg_vgnames, vg_name)) ||
(!dm_list_empty(arg_tags) && str_list_match_list(arg_tags, &vg->tags, NULL))) &&
select_match_vg(cmd, vg, &selected) && selected) {
select_match_vg(cmd, handle, vg, &selected) && selected) {
ret = process_single_vg(cmd, vg_name, vg, handle);
if (ret != ECMD_PROCESSED)
stack;
@ -1797,7 +1813,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
if (!process_lv && tags_supplied && str_list_match_list(tags_in, &lvl->lv->tags, NULL))
process_lv = 1;
process_lv = process_lv && select_match_lv(cmd, vg, lvl->lv, &selected) && selected;
process_lv = process_lv && select_match_lv(cmd, handle, vg, lvl->lv, &selected) && selected;
if (sigint_caught())
return_ECMD_FAILED;
@ -2307,7 +2323,7 @@ static int _process_pvs_in_vg(struct cmd_context *cmd,
str_list_match_list(arg_tags, &pv->tags, NULL))
process_pv = 1;
process_pv = process_pv && select_match_pv(cmd, vg, pv, &selected) && selected;
process_pv = process_pv && select_match_pv(cmd, handle, vg, pv, &selected) && selected;
if (process_pv) {
if (skip)

View File

@ -137,12 +137,12 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
int stop_on_error, struct processing_handle *handle,
process_single_lv_fn_t process_single_lv);
int select_match_vg(struct cmd_context *cmd, struct volume_group *vg,
int *selected);
int select_match_lv(struct cmd_context *cmd, struct volume_group *vg,
struct logical_volume *lv, int *selected);
int select_match_pv(struct cmd_context *cmd, struct volume_group *vg,
struct physical_volume *pv, int *selected);
int select_match_vg(struct cmd_context *cmd, struct processing_handle *handle,
struct volume_group *vg, int *selected);
int select_match_lv(struct cmd_context *cmd, struct processing_handle *handle,
struct volume_group *vg, struct logical_volume *lv, int *selected);
int select_match_pv(struct cmd_context *cmd, struct processing_handle *handle,
struct volume_group *vg, struct physical_volume *pv, int *selected);
const char *extract_vgname(struct cmd_context *cmd, const char *lv_name);
const char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,