diff options
author | Peter Rajnoha <prajnoha@redhat.com> | 2015-02-09 16:09:28 +0100 |
---|---|---|
committer | Peter Rajnoha <prajnoha@redhat.com> | 2015-02-09 16:21:20 +0100 |
commit | f8966d675841b78641314ff9aa6aebe2e037b35d (patch) | |
tree | 447985a13c0a141879fdd47f75443c5e06fb2b3a | |
parent | d6c3abda429685e14ad8e1ae7dff5f1353933877 (diff) | |
download | lvm2-dev-prajnoha-tool-select.tar.gz |
select: initialize selection handle for process_each_* fns with initial report typedev-prajnoha-tool-select
This is a followup patch for previous patchset that enables selection in
process_each_* fns to fix an issue where field prefixes are not
automatically used for fields in selection criteria.
Use initial report type that matches the intention of each process_each_* functions:
- _process_pvs_in_vg - PVS
- process_each_vg - VGS
- process_each_lv and process_each_lv_in_vg - LVS
This is not normally needed for the selection handle init, BUT we would
miss the field prefix matching, e.g.
lvchange -ay -S 'name=lvol0'
The "name" above would not work if we didn't initialize reporting with
the LVS type at its start. If we pass proper init type, reporting code
can deduce the prefix automatically ("lv_name" in this case).
This report type is then changed further based on what selection criteria we
have. When doing pure selection, not report output, the final report type
is purely based on combination of this initial report type and report types
of the fields used in selection criteria.
-rw-r--r-- | tools/pvchange.c | 2 | ||||
-rw-r--r-- | tools/toollib.c | 12 | ||||
-rw-r--r-- | tools/toollib.h | 3 |
3 files changed, 10 insertions, 7 deletions
diff --git a/tools/pvchange.c b/tools/pvchange.c index d5496d935..278d37740 100644 --- a/tools/pvchange.c +++ b/tools/pvchange.c @@ -167,7 +167,7 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv) } if (!(handle = init_processing_handle(cmd)) || - (!handle->direct_reporting && !init_selection_handle(cmd, handle))) { + (!handle->direct_reporting && !init_selection_handle(cmd, handle, PVS))) { log_error("Failed to initialize processing handle."); r = ECMD_FAILED; goto out; diff --git a/tools/toollib.c b/tools/toollib.c index 3d592047b..3d98884e7 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -1586,7 +1586,8 @@ struct processing_handle *init_processing_handle(struct cmd_context *cmd) return handle; } -int init_selection_handle(struct cmd_context *cmd, struct processing_handle *handle) +int init_selection_handle(struct cmd_context *cmd, struct processing_handle *handle, + report_type_t initial_report_type) { struct selection_handle *sh; @@ -1595,6 +1596,7 @@ int init_selection_handle(struct cmd_context *cmd, struct processing_handle *han return 0; } + sh->report_type = initial_report_type; if (!(sh->selection_rh = report_init_for_selection(cmd, &sh->report_type, arg_str_value(cmd, select_ARG, NULL)))) { dm_pool_free(cmd->mem, sh); @@ -1833,7 +1835,7 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv, goto_out; if (!handle->direct_reporting && !handle->selection_handle && - !init_selection_handle(cmd, handle)) + !init_selection_handle(cmd, handle, VGS)) goto_out; ret = _process_vgnameid_list(cmd, flags, &vgnameids_to_process, @@ -1878,7 +1880,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg, } if (!handle->direct_reporting && !handle->selection_handle && - !init_selection_handle(cmd, handle)) { + !init_selection_handle(cmd, handle, LVS)) { ret_max = ECMD_FAILED; goto_out; } @@ -2207,7 +2209,7 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv, uint32_t fla goto_out; if (!handle->direct_reporting && !handle->selection_handle && - !init_selection_handle(cmd, handle)) + !init_selection_handle(cmd, handle, LVS)) goto_out; /* @@ -2444,7 +2446,7 @@ static int _process_pvs_in_vg(struct cmd_context *cmd, } if (!handle->direct_reporting && !handle->selection_handle && - !init_selection_handle(cmd, handle)) { + !init_selection_handle(cmd, handle, PVS)) { ret_max = ECMD_FAILED; goto_out; } diff --git a/tools/toollib.h b/tools/toollib.h index e2245b065..aebb2dd2d 100644 --- a/tools/toollib.h +++ b/tools/toollib.h @@ -138,7 +138,8 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg, process_single_lv_fn_t process_single_lv); struct processing_handle *init_processing_handle(struct cmd_context *cmd); -int init_selection_handle(struct cmd_context *cmd, struct processing_handle *handle); +int init_selection_handle(struct cmd_context *cmd, struct processing_handle *handle, + report_type_t initial_report_type); void destroy_processing_handle(struct cmd_context *cmd, struct processing_handle *handle, int deallocate_handle_root); |