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

cleanup: shift detection of chunksize sign

Sign should be checked prior opening of VG.
Since get_pool_params() needs profiles,
we need to move check for sign earlier.
This commit is contained in:
Zdenek Kabelac 2014-07-07 22:40:36 +02:00
parent 9955204e0d
commit fe3ea94e58
3 changed files with 18 additions and 13 deletions

View File

@ -447,10 +447,12 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
return 0;
}
if (arg_sign_value(cmd, chunksize_ARG, SIGN_NONE) == SIGN_MINUS) {
log_error("Negative chunk size is invalid");
if (arg_count(cmd, chunksize_ARG) &&
(arg_sign_value(cmd, chunksize_ARG, SIGN_NONE) == SIGN_MINUS)) {
log_error("Negative chunk size is invalid.");
return 0;
}
lp->chunk_size = arg_uint_value(cmd, chunksize_ARG, 8);
if (lp->chunk_size < 8 || lp->chunk_size > 1024 ||
(lp->chunk_size & (lp->chunk_size - 1))) {
@ -540,10 +542,15 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
lp->segtype = get_segtype_from_string(cmd, arg_str_value(cmd, type_ARG, cache_pool ? "cache-pool" : "thin-pool"));
if (!lp->segtype)
return_0;
if (arg_count(cmd, chunksize_ARG) &&
(arg_sign_value(cmd, chunksize_ARG, SIGN_NONE) == SIGN_MINUS)) {
log_error("Negative chunk size is invalid.");
return 0;
}
} else { /* Mirrors (and some RAID functions) */
if (arg_count(cmd, chunksize_ARG)) {
log_error("--chunksize is only available with "
"snapshots or thin pools.");
log_error("--chunksize is only available with snapshots or pools.");
return 0;
}

View File

@ -1033,6 +1033,12 @@ static int _lvcreate_params(struct lvcreate_params *lp,
lp->wipe_signatures = 0;
}
if (arg_count(cmd, chunksize_ARG) &&
(arg_sign_value(cmd, chunksize_ARG, SIGN_NONE) == SIGN_MINUS)) {
log_error("Negative chunk size is invalid.");
return 0;
}
if (!_lvcreate_name_params(lp, cmd, &argc, &argv) ||
!_read_size_params(lp, lcp, cmd) ||
!get_stripe_params(cmd, &lp->stripes, &lp->stripe_size) ||
@ -1047,10 +1053,6 @@ static int _lvcreate_params(struct lvcreate_params *lp,
return_0;
if (lp->snapshot && (lp->extents || lcp->size)) {
if (arg_sign_value(cmd, chunksize_ARG, SIGN_NONE) == SIGN_MINUS) {
log_error("Negative chunk size is invalid.");
return 0;
}
lp->chunk_size = arg_uint_value(cmd, chunksize_ARG, 8);
if (lp->chunk_size < 8 || lp->chunk_size > 1024 ||
(lp->chunk_size & (lp->chunk_size - 1))) {
@ -1063,7 +1065,7 @@ static int _lvcreate_params(struct lvcreate_params *lp,
if (!(lp->segtype = get_segtype_from_string(cmd, "snapshot")))
return_0;
} else if (!lp->create_pool && arg_count(cmd, chunksize_ARG)) {
log_error("--chunksize is only available with snapshots and thin pools.");
log_error("--chunksize is only available with snapshots and pools.");
return 0;
}

View File

@ -1688,10 +1688,6 @@ 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;
}
*passed_args |= PASS_ARG_CHUNK_SIZE;
*chunk_size = arg_uint_value(cmd, chunksize_ARG, cache_pool ?
DM_CACHE_MIN_DATA_BLOCK_SIZE :