summaryrefslogtreecommitdiff
path: root/tools/toollib.h
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2016-11-29 12:00:15 -0600
committerDavid Teigland <teigland@redhat.com>2017-02-13 08:20:10 -0600
commit9c6c55c314199a9ba26fe1b864306b2ca8a8dbcd (patch)
treeec7c1cf043023cc2335a61016c47604237b215d2 /tools/toollib.h
parent1e2420bca85da9a37570871cd70192e9ae831786 (diff)
downloadlvm2-9c6c55c314199a9ba26fe1b864306b2ca8a8dbcd.tar.gz
process_each_lv: add check_single_lv function
The new check_single_lv() function is called prior to the existing process_single_lv(). If the check function returns 0, the LV will not be processed. The check_single_lv function is meant to be a standard method to validate the combination of specific command + specific LV, and decide if the combination is allowed. The check_single function can be used by anything that calls process_each_lv. As commands are migrated to take advantage of command definitions, each command definition gets its own entry point which calls process_each for itself, passing a pair of check_single/process_single functions which can be specific to the narrowly defined command def.
Diffstat (limited to 'tools/toollib.h')
-rw-r--r--tools/toollib.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/toollib.h b/tools/toollib.h
index d44b825ef..67e45a2ec 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -98,6 +98,18 @@ typedef int (*process_single_pvseg_fn_t) (struct cmd_context * cmd,
struct pv_segment * pvseg,
struct processing_handle *handle);
+/*
+ * Called prior to process_single_lv() to decide if the LV should be
+ * processed. If this returns 0, the LV is not processed.
+ *
+ * This can evaluate the combination of command definition and
+ * the LV object to decide if the combination is allowed.
+ */
+typedef int (*check_single_lv_fn_t) (struct cmd_context *cmd,
+ struct logical_volume *lv,
+ struct processing_handle *handle,
+ int lv_is_named_arg);
+
int process_each_vg(struct cmd_context *cmd,
int argc, char **argv,
const char *one_vgname,
@@ -125,6 +137,7 @@ int process_each_segment_in_pv(struct cmd_context *cmd,
int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
const char *one_vgname, const char *one_lvname,
uint32_t flags, struct processing_handle *handle,
+ check_single_lv_fn_t check_single_lv,
process_single_lv_fn_t process_single_lv);
@@ -141,6 +154,7 @@ int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
struct dm_list *arg_lvnames, const struct dm_list *tagsl,
int stop_on_error, struct processing_handle *handle,
+ check_single_lv_fn_t check_single_lv,
process_single_lv_fn_t process_single_lv);
struct processing_handle *init_processing_handle(struct cmd_context *cmd, struct processing_handle *parent_handle);