1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Tighten region size validation.

This commit is contained in:
Alasdair Kergon 2006-04-28 15:01:39 +00:00
parent dfb5da937e
commit 089ae9a58e
3 changed files with 24 additions and 5 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.06 -
=================================
Tighten region size validation.
Ignore empty strings in config files.
Require non-zero regionsize and document parameter on lvcreate man page.
Invalidate cache if composition of VG changed externally.

View File

@ -101,6 +101,8 @@ static int _lvconvert_name_params(struct lvconvert_params *lp,
static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
int argc, char **argv)
{
int region_size;
memset(lp, 0, sizeof(*lp));
if (arg_count(cmd, mirrors_ARG) + arg_count(cmd, snapshot_ARG) != 1) {
@ -165,6 +167,7 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
* --regionsize is only valid if converting an LV into a mirror.
* Checked when we know the state of the LV being converted.
*/
if (arg_count(cmd, regionsize_ARG)) {
if (arg_sign_value(cmd, regionsize_ARG, 0) ==
SIGN_MINUS) {
@ -173,10 +176,17 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
}
lp->region_size = 2 * arg_uint_value(cmd,
regionsize_ARG, 0);
} else
lp->region_size = 2 * find_config_int(cmd->cft->root,
} else {
region_size = 2 * find_config_int(cmd->cft->root,
"activation/mirror_region_size",
DEFAULT_MIRROR_REGION_SIZE);
if (region_size < 0) {
log_error("Negative regionsize in "
"configuration file is invalid");
return 0;
}
lp->region_size = region_size;
}
if (lp->region_size & (lp->region_size - 1)) {
log_error("Region size (%" PRIu32

View File

@ -234,6 +234,7 @@ static int _read_mirror_params(struct lvcreate_params *lp,
int *pargc, char ***pargv)
{
int argc = *pargc;
int region_size;
if (argc && (unsigned) argc < lp->mirrors) {
log_error("Too few physical volumes on "
@ -247,10 +248,17 @@ static int _read_mirror_params(struct lvcreate_params *lp,
return 0;
}
lp->region_size = 2 * arg_uint_value(cmd, regionsize_ARG, 0);
} else
lp->region_size = 2 * find_config_int(cmd->cft->root,
} else {
region_size = 2 * find_config_int(cmd->cft->root,
"activation/mirror_region_size",
DEFAULT_MIRROR_REGION_SIZE);
if (region_size < 0) {
log_error("Negative regionsize in configuration file "
"is invalid");
return 0;
}
lp->region_size = region_size;
}
if (lp->region_size & (lp->region_size - 1)) {
log_error("Region size (%" PRIu32 ") must be a power of 2",