]> sourceware.org Git - lvm2.git/commitdiff
lvcreate: LVM_VG_NAME applies even without name arg
authorDavid Teigland <teigland@redhat.com>
Wed, 15 Feb 2017 18:07:51 +0000 (12:07 -0600)
committerDavid Teigland <teigland@redhat.com>
Wed, 15 Feb 2017 18:07:51 +0000 (12:07 -0600)
There was a small flaw in the logic regarding when LVM_VG_NAME
can replace a VG position arg.

tools/lvmcmdline.c

index 02aaff286a068e20c7182e903d7d0cb54774c125..41ae8c4b8b84577b6f7abf454940c35f32d83555 100644 (file)
@@ -1280,6 +1280,7 @@ check_val:
 static int _command_required_pos_matches(struct cmd_context *cmd, int ci, int rp, char **argv)
 {
        const char *name;
+       char *gotenv = NULL;
 
        /*
         * rp is the index in required_pos_args[] of the required positional arg.
@@ -1311,14 +1312,19 @@ static int _command_required_pos_matches(struct cmd_context *cmd, int ci, int rp
        if (!strcmp(cmd->name, "lvcreate") &&
            (rp == 0) &&
            val_bit_is_set(commands[ci].required_pos_args[rp].def.val_bits, vg_VAL) &&
-           (arg_is_set(cmd, name_ARG) || arg_is_set(cmd, thinpool_ARG) || arg_is_set(cmd, cachepool_ARG))) {
+           (arg_is_set(cmd, name_ARG) ||
+            arg_is_set(cmd, thinpool_ARG) ||
+            arg_is_set(cmd, cachepool_ARG) ||
+            (gotenv = getenv("LVM_VG_NAME")))) {
+
+               if (gotenv)
+                       return 1;
+
                if ((name = arg_str_value(cmd, name_ARG, NULL))) {
-                       if (strstr(name, "/") || getenv("LVM_VG_NAME"))
+                       if (strstr(name, "/"))
                                return 1;
                }
 
-               /* FIXME: does LVM_VG_NAME also work with --thinpool/--cachepool ? */
-
                if ((name = arg_str_value(cmd, thinpool_ARG, NULL))) {
                        if (strstr(name, "/"))
                                return 1;
This page took 0.041901 seconds and 5 git commands to generate.