summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2014-12-02 13:14:12 +0100
committerPeter Rajnoha <prajnoha@redhat.com>2015-02-10 16:05:25 +0100
commita64b39aef80d790dd4afe4ce8fdaa0ed1b0e2c48 (patch)
treeea348808a3ddd39c39cf065ae8d9831c82e88e9f /tools
parent51d96a170314b7ce75f233d42501262805384770 (diff)
downloadlvm2-a64b39aef80d790dd4afe4ce8fdaa0ed1b0e2c48.tar.gz
report: add report_init_for_selection fn and modify report_object to support reporting for selection only
The new "report_init_for_selection" is just a wrapper over dm_report_init_with_selection that initializes reporting for selection only. This means we're not going to do the actual reporting to output for display and as such we intialize reporting as if no fields are reported or sorted. The only fields "reported" are taken from the selection criteria string and all such fields are marked as hidden automatically (FLD_HIDDEN flag). These fields are used solely for selection criteria matching. Also, modify existing report_object function that was used for reporting to output for display. Now, it can either cause reporting to output or reporting for selection only. The selection result is stored in struct selection_handle's "selected" variable which can be handled further by any report_object caller.
Diffstat (limited to 'tools')
-rw-r--r--tools/reporter.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/tools/reporter.c b/tools/reporter.c
index 3d7e5ddd6..3cba020c6 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -32,7 +32,10 @@ static int _vgs_single(struct cmd_context *cmd __attribute__((unused)),
const char *vg_name, struct volume_group *vg,
struct processing_handle *handle)
{
- if (!report_object(handle->custom_handle, vg, NULL, NULL, NULL, NULL, NULL, NULL))
+ struct selection_handle *sh = handle->selection_handle;
+
+ if (!report_object(sh ? : handle->custom_handle, sh != NULL,
+ vg, NULL, NULL, NULL, NULL, NULL, NULL))
return_ECMD_FAILED;
check_current_backup(vg);
@@ -88,6 +91,7 @@ static int _do_lvs_with_info_and_status_single(struct cmd_context *cmd,
int do_info, int do_status,
struct processing_handle *handle)
{
+ struct selection_handle *sh = handle->selection_handle;
struct lv_with_info_and_seg_status status = {
.seg_status.type = SEG_STATUS_NONE
};
@@ -96,8 +100,8 @@ static int _do_lvs_with_info_and_status_single(struct cmd_context *cmd,
if (!_do_info_and_status(cmd, lv, NULL, &status, do_info, do_status))
goto_out;
- if (!report_object(handle->custom_handle, lv->vg, lv,
- NULL, NULL, NULL, &status, NULL))
+ if (!report_object(sh ? : handle->custom_handle, sh != NULL,
+ lv->vg, lv, NULL, NULL, NULL, &status, NULL))
goto out;
r = ECMD_PROCESSED;
@@ -137,6 +141,7 @@ static int _do_segs_with_info_and_status_single(struct cmd_context *cmd,
int do_info, int do_status,
struct processing_handle *handle)
{
+ struct selection_handle *sh = handle->selection_handle;
struct lv_with_info_and_seg_status status = {
.seg_status.type = SEG_STATUS_NONE
};
@@ -145,9 +150,9 @@ static int _do_segs_with_info_and_status_single(struct cmd_context *cmd,
if (!_do_info_and_status(cmd, seg->lv, seg, &status, do_info, do_status))
goto_out;
- if (!report_object(handle->custom_handle, seg->lv->vg, seg->lv, NULL, seg, NULL,
- &status, NULL))
- goto_out;
+ if (!report_object(sh ? : handle->custom_handle, sh != NULL,
+ seg->lv->vg, seg->lv, NULL, seg, NULL, &status, NULL))
+ goto_out;
r = ECMD_PROCESSED;
out:
@@ -224,6 +229,7 @@ static int _do_pvsegs_sub_single(struct cmd_context *cmd,
int do_status,
struct processing_handle *handle)
{
+ struct selection_handle *sh = handle->selection_handle;
int ret = ECMD_PROCESSED;
struct lv_segment *seg = pvseg->lvseg;
@@ -268,9 +274,10 @@ static int _do_pvsegs_sub_single(struct cmd_context *cmd,
if (seg && !_do_info_and_status(cmd, seg->lv, seg, &status, do_info, do_status))
goto_out;
- if (!report_object(handle->custom_handle, vg, seg ? seg->lv : &_free_logical_volume,
- pvseg->pv, seg ? : &_free_lv_segment, pvseg, &status,
- pv_label(pvseg->pv))) {
+ if (!report_object(sh ? : handle->custom_handle, sh != NULL,
+ vg, seg ? seg->lv : &_free_logical_volume,
+ pvseg->pv, seg ? : &_free_lv_segment, pvseg,
+ &status, pv_label(pvseg->pv))) {
ret = ECMD_FAILED;
goto_out;
}
@@ -350,7 +357,10 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
struct physical_volume *pv,
struct processing_handle *handle)
{
- if (!report_object(handle->custom_handle, vg, NULL, pv, NULL, NULL, NULL, NULL))
+ struct selection_handle *sh = handle->selection_handle;
+
+ if (!report_object(sh ? : handle->custom_handle, sh != NULL,
+ vg, NULL, pv, NULL, NULL, NULL, NULL))
return_ECMD_FAILED;
return ECMD_PROCESSED;
@@ -359,7 +369,10 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
static int _label_single(struct cmd_context *cmd, struct label *label,
struct processing_handle *handle)
{
- if (!report_object(handle->custom_handle, NULL, NULL, NULL, NULL, NULL, NULL, label))
+ struct selection_handle *sh = handle->selection_handle;
+
+ if (!report_object(sh ? : handle->custom_handle, sh != NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, label))
return_ECMD_FAILED;
return ECMD_PROCESSED;