All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Rajnoha <prajnoha@fedoraproject.org>
To: lvm-devel@redhat.com
Subject: master - toollib: pass struct processing_handle to _select_match_* functions
Date: Tue, 10 Feb 2015 15:12:52 +0000 (UTC)	[thread overview]
Message-ID: <20150210151252.DCD3B60F67@fedorahosted.org> (raw)

Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c3180c4a05ea947b379e9e9bc51e50d0ca329980
Commit:        c3180c4a05ea947b379e9e9bc51e50d0ca329980
Parent:        a64b39aef80d790dd4afe4ce8fdaa0ed1b0e2c48
Author:        Peter Rajnoha <prajnoha@redhat.com>
AuthorDate:    Fri Nov 28 14:34:56 2014 +0100
Committer:     Peter Rajnoha <prajnoha@redhat.com>
CommitterDate: Tue Feb 10 16:05:26 2015 +0100

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.
---
 tools/toollib.c |   32 ++++++++++++++++++++++++--------
 tools/toollib.h |   12 ++++++------
 2 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/tools/toollib.c b/tools/toollib.c
index 759769e..13cb034 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -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)
diff --git a/tools/toollib.h b/tools/toollib.h
index cc86227..ead36d3 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -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,



                 reply	other threads:[~2015-02-10 15:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150210151252.DCD3B60F67@fedorahosted.org \
    --to=prajnoha@fedoraproject.org \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.