mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-11 20:58:50 +03:00
Don't assume exactly two mirrors when parsing mirror status
This commit is contained in:
parent
40ec1e8a36
commit
dbb43034e6
@ -1,5 +1,6 @@
|
|||||||
Version 2.01.15 -
|
Version 2.01.15 -
|
||||||
=================================
|
=================================
|
||||||
|
Don't assume exactly two mirrors when parsing mirror status.
|
||||||
Suppress fsync() error message on filesystems that don't support it.
|
Suppress fsync() error message on filesystems that don't support it.
|
||||||
Fix yes_no_prompt() error handling.
|
Fix yes_no_prompt() error handling.
|
||||||
Add lvm.conf comment warning against multiple filter lines.
|
Add lvm.conf comment warning against multiple filter lines.
|
||||||
|
@ -279,18 +279,41 @@ static int _target_percent(void **target_state, struct pool *mem,
|
|||||||
{
|
{
|
||||||
struct mirror_state *mirr_state;
|
struct mirror_state *mirr_state;
|
||||||
uint64_t numerator, denominator;
|
uint64_t numerator, denominator;
|
||||||
|
unsigned mirror_count, m;
|
||||||
|
int used;
|
||||||
|
char *pos = params;
|
||||||
|
|
||||||
if (!*target_state)
|
if (!*target_state)
|
||||||
*target_state = _init_target(mem, cft);
|
*target_state = _init_target(mem, cft);
|
||||||
|
|
||||||
mirr_state = *target_state;
|
mirr_state = *target_state;
|
||||||
|
|
||||||
|
/* Status line: <#mirrors> (maj:min)+ <synced>/<total_regions> */
|
||||||
log_debug("Mirror status: %s", params);
|
log_debug("Mirror status: %s", params);
|
||||||
if (sscanf(params, "%*d %*x:%*x %*x:%*x %" PRIu64
|
|
||||||
"/%" PRIu64, &numerator, &denominator) != 2) {
|
if (sscanf(pos, "%u %n", mirror_count, used) != 1) {
|
||||||
log_error("Failure parsing mirror status: %s", params);
|
log_error("Failure parsing mirror status mirror count: %s",
|
||||||
|
params);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
pos += used;
|
||||||
|
|
||||||
|
for (m = 0; m < mirror_count; m++) {
|
||||||
|
if (sscanf(pos, "%*x:%*x %n", &used) != 0) {
|
||||||
|
log_error("Failure parsing mirror status devices: %s",
|
||||||
|
params);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
pos += used;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sscanf(pos, "%" PRIu64 "/%" PRIu64 "%n", &numerator, &denominator,
|
||||||
|
&used) != 2) {
|
||||||
|
log_error("Failure parsing mirror status fraction: %s", params);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
pos += used;
|
||||||
|
|
||||||
*total_numerator += numerator;
|
*total_numerator += numerator;
|
||||||
*total_denominator += denominator;
|
*total_denominator += denominator;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user