Fix the count of member devices in mdstat_read function.
Correction of the number of container or volume member devices (devcnt in struct mdstat_ent). The number after the last devices was counted towards member of devices. Signed-off-by: Marcin Labun <marcin.labun@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
aae3cdc35a
commit
0ad6835c98
9
mdstat.c
9
mdstat.c
|
@ -94,19 +94,20 @@ static void free_member_devnames(struct dev_member *m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_member_devname(struct dev_member **m, char *name)
|
static int add_member_devname(struct dev_member **m, char *name)
|
||||||
{
|
{
|
||||||
struct dev_member *new;
|
struct dev_member *new;
|
||||||
char *t;
|
char *t;
|
||||||
|
|
||||||
if ((t = strchr(name, '[')) == NULL)
|
if ((t = strchr(name, '[')) == NULL)
|
||||||
/* not a device */
|
/* not a device */
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
new = malloc(sizeof(*new));
|
new = malloc(sizeof(*new));
|
||||||
new->name = strndup(name, t - name);
|
new->name = strndup(name, t - name);
|
||||||
new->next = *m;
|
new->next = *m;
|
||||||
*m = new;
|
*m = new;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_mdstat(struct mdstat_ent *ms)
|
void free_mdstat(struct mdstat_ent *ms)
|
||||||
|
@ -207,8 +208,8 @@ struct mdstat_ent *mdstat_read(int hold, int start)
|
||||||
} else if (in_devs && strcmp(w, "blocks")==0)
|
} else if (in_devs && strcmp(w, "blocks")==0)
|
||||||
in_devs = 0;
|
in_devs = 0;
|
||||||
else if (in_devs) {
|
else if (in_devs) {
|
||||||
ent->devcnt++;
|
ent->devcnt +=
|
||||||
add_member_devname(&ent->members, w);
|
add_member_devname(&ent->members, w);
|
||||||
if (strncmp(w, "md", 2)==0) {
|
if (strncmp(w, "md", 2)==0) {
|
||||||
/* This has an md device as a component.
|
/* This has an md device as a component.
|
||||||
* If that device is already in the
|
* If that device is already in the
|
||||||
|
|
Loading…
Reference in New Issue