summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2014-10-31 11:41:49 +0100
committerZdenek Kabelac <zkabelac@redhat.com>2014-11-03 14:19:32 +0100
commit897b09157922a510d6c9f5556eea4fc243b84702 (patch)
treeaa12ba8b079a6f23f91a6845eac295fdca51c55a
parentdc11dcf11d90f24c8d37988f3029e29cc6a45441 (diff)
downloadlvm2-897b09157922a510d6c9f5556eea4fc243b84702.tar.gz
pool: validate sizes
0 size are not supported as well as negative.
-rw-r--r--tools/toollib.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/tools/toollib.c b/tools/toollib.c
index dd098119b..e87fd30c4 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -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);