]> sourceware.org Git - lvm2.git/commitdiff
lvconvert: handle old arg quirk when combining snapshot
authorDavid Teigland <teigland@redhat.com>
Wed, 15 Feb 2017 18:40:35 +0000 (12:40 -0600)
committerDavid Teigland <teigland@redhat.com>
Wed, 15 Feb 2017 18:40:35 +0000 (12:40 -0600)
The old ad hoc arg parsing when combining a split snapshot
allowed the first lv to have a vgname, but not the second.
Since lvconvert now uses the standard arg parsing in
process_each_lv(), the old one-off behavior requires a
work around.

tools/lvconvert.c

index 502d614e786798e477cd3e9d91c9334cc5fa5ba9..a2ad11558b3860d465d6b604865337506d81de74 100644 (file)
@@ -3649,6 +3649,43 @@ static int _lvconvert_combine_split_snapshot_single(struct cmd_context *cmd,
 
 int lvconvert_combine_split_snapshot_cmd(struct cmd_context *cmd, int argc, char **argv)
 {
+       const char *vgname = NULL;
+       const char *lvname1;
+       const char *lvname2;
+       char *vglv;
+       int vglv_sz;
+
+       /*
+        * Hack to accomodate an old parsing quirk that allowed the
+        * the VG name to be attached to only the LV in arg pos 1,
+        * i.e. lvconvert -s vgname/lvname lvname
+        *
+        * The LV name in arg pos 2 is the one that is processed
+        * by process_each_lv().  If that LV has no VG name, but
+        * the first LV does, then copy the VG name from arg pos 1
+        * and add it to the LV name in arg pos 2 so that the
+        * standard arg parsing in process_each_lv will find it.
+        *
+        * This is the only instance in all commands.
+        */
+
+       lvname1 = cmd->position_argv[0];
+       lvname2 = cmd->position_argv[1];
+
+       if (strstr("/", lvname1) && !strstr("/", lvname2) && !getenv("LVM_VG_NAME")) {
+               if (!validate_lvname_param(cmd, &vgname, &lvname1))
+                       return_ECMD_FAILED;
+
+               vglv_sz = strlen(vgname) + strlen(lvname2) + 2;
+               if (!(vglv = dm_pool_alloc(cmd->mem, vglv_sz)) ||
+                   dm_snprintf(vglv, vglv_sz, "%s/%s", vgname, lvname2) < 0) {
+                               log_error("vg/lv string alloc failed.");
+                       return_ECMD_FAILED;
+               }
+
+               cmd->position_argv[1] = vglv;
+       }
+
        return process_each_lv(cmd, 1, cmd->position_argv + 1, NULL, NULL, READ_FOR_UPDATE,
                               NULL, NULL, &_lvconvert_combine_split_snapshot_single);
 }
This page took 0.042701 seconds and 5 git commands to generate.