1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

lvcreate: validate sizes

Earlier validation of --size and --extents.
Reject 0 size on command line instantly.
This commit is contained in:
Zdenek Kabelac 2014-10-06 13:54:34 +02:00
parent a0693da97f
commit 57a52e7878

View File

@ -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;
}