diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2014-10-06 13:54:34 +0200 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2014-10-06 15:23:07 +0200 |
commit | 57a52e787843ce1f370f7e60d2f75f78d9f03d54 (patch) | |
tree | 386baf3d2060097d7895e9d4f933203eead98c49 | |
parent | a0693da97f6873b08d33f8c44baacde77e28e33a (diff) | |
download | lvm2-57a52e787843ce1f370f7e60d2f75f78d9f03d54.tar.gz |
lvcreate: validate sizes
Earlier validation of --size and --extents.
Reject 0 size on command line instantly.
-rw-r--r-- | tools/lvcreate.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/tools/lvcreate.c b/tools/lvcreate.c index 0a0ce1d8c..97c8d9457 100644 --- a/tools/lvcreate.c +++ b/tools/lvcreate.c @@ -506,20 +506,26 @@ static int _read_size_params(struct lvcreate_params *lp, if (arg_count(cmd, extents_ARG)) { if (arg_sign_value(cmd, extents_ARG, SIGN_NONE) == SIGN_MINUS) { - log_error("Negative number of extents is invalid"); + log_error("Negative number of extents is invalid."); + return 0; + } + if (!(lp->extents = arg_uint_value(cmd, extents_ARG, 0))) { + log_error("Number of extents may not be zero."); return 0; } - lp->extents = arg_uint_value(cmd, extents_ARG, 0); lcp->percent = arg_percent_value(cmd, extents_ARG, PERCENT_NONE); } /* Size returned in kilobyte units; held in sectors */ if (arg_count(cmd, size_ARG)) { if (arg_sign_value(cmd, size_ARG, SIGN_NONE) == SIGN_MINUS) { - log_error("Negative size is invalid"); + log_error("Negative size is invalid."); + return 0; + } + if (!(lcp->size = arg_uint64_value(cmd, size_ARG, UINT64_C(0)))) { + log_error("Size may not be zero."); return 0; } - lcp->size = arg_uint64_value(cmd, size_ARG, UINT64_C(0)); lcp->percent = PERCENT_NONE; } |