]> sourceware.org Git - lvm2.git/commitdiff
pool: validate sizes
authorZdenek Kabelac <zkabelac@redhat.com>
Fri, 31 Oct 2014 10:41:49 +0000 (11:41 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 3 Nov 2014 13:19:32 +0000 (14:19 +0100)
0 size are not supported as well as negative.

tools/toollib.c

index dd098119bf33010c9592e695be0f467be90d6c97..e87fd30c49af2147e776e17643d1ad12e30d3db4 100644 (file)
@@ -975,12 +975,21 @@ int get_pool_params(struct cmd_context *cmd,
                }
        }
 
-       if (arg_count(cmd, chunksize_ARG)) {
-               if (arg_sign_value(cmd, chunksize_ARG, SIGN_NONE) == SIGN_MINUS) {
-                       log_error("Negative chunk size is invalid.");
-                       return 0;
-               }
+       if (arg_from_list_is_negative(cmd, "may not be negative",
+                                     chunksize_ARG,
+                                     pooldatasize_ARG,
+                                     poolmetadatasize_ARG,
+                                     -1))
+               return_0;
+
+       if (arg_from_list_is_zero(cmd, "may not be zero",
+                                 chunksize_ARG,
+                                 pooldatasize_ARG,
+                                 poolmetadatasize_ARG,
+                                 -1))
+               return_0;
 
+       if (arg_is_set(cmd, chunksize_ARG)) {
                *passed_args |= PASS_ARG_CHUNK_SIZE;
                *chunk_size = arg_uint_value(cmd, chunksize_ARG, 0);
 
This page took 0.035234 seconds and 5 git commands to generate.