summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2016-01-28 10:37:08 -0600
committerDavid Teigland <teigland@redhat.com>2016-01-28 10:37:08 -0600
commitdabb54859f44e321b00eaa35e7dbb40e9b120078 (patch)
treea92c5486a81380f69a5b8bc9f7b62c5462f3567c
parent4cda7e108ddd6d68fd1a1e7f2d6529d4c8633974 (diff)
downloadlvm2-dev-dct-pvcreate-19.tar.gz
toollib: keep PV args in the same orderdev-dct-pvcreate-19
-rw-r--r--tools/toollib.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/tools/toollib.c b/tools/toollib.c
index 9486bc92c..90de9879c 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -3659,6 +3659,18 @@ static struct pvcreate_device *_pvcreate_list_find_dev(struct dm_list *devices,
return NULL;
}
+static struct pvcreate_device *_pvcreate_list_find_name(struct dm_list *devices, const char *name)
+{
+ struct pvcreate_device *pd;
+
+ dm_list_iterate_items(pd, devices) {
+ if (!strcmp(pd->name, name))
+ return pd;
+ }
+
+ return NULL;
+}
+
/*
* If this function decides that a arg_devices entry cannot be used, but the
* command might be able to continue without it, then it moves that entry from
@@ -4047,6 +4059,7 @@ int pvcreate_each_device(struct cmd_context *cmd,
struct pvcreate_prompt *prompt, *prompt2;
struct physical_volume *pv;
struct volume_group *orphan_vg;
+ struct dm_list arg_sort;
struct pv_list *pvl;
struct pv_list *vgpvl;
const char *pv_name;
@@ -4055,6 +4068,8 @@ int pvcreate_each_device(struct cmd_context *cmd,
int found;
int i;
+ dm_list_init(&arg_sort);
+
handle->custom_handle = pp;
/*
@@ -4274,6 +4289,15 @@ int pvcreate_each_device(struct cmd_context *cmd,
do_command:
+ /*
+ * Reorder arg_process entries to match the original order of args.
+ */
+ dm_list_splice(&arg_sort, &pp->arg_process);
+ for (i = 0; i < pp->pv_count; i++) {
+ if ((pd = _pvcreate_list_find_name(&arg_sort, pp->pv_names[i])))
+ dm_list_move(&pp->arg_process, &pd->list);
+ }
+
if (pp->is_remove)
dm_list_splice(&pp->arg_remove, &pp->arg_process);
else