]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Fix the count of member devices in mdstat_read function.
authorMarcin Labun <marcin.labun@intel.com>
Tue, 6 Jul 2010 07:49:37 +0000 (17:49 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 6 Jul 2010 08:02:22 +0000 (18:02 +1000)
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>
mdstat.c

index 3bb74fa27410c48feb6a0cad285da1ce23388852..47be2bba21fabaac7a617f8b4f0264f7fcd966a3 100644 (file)
--- a/mdstat.c
+++ b/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;
        char *t;
 
        if ((t = strchr(name, '[')) == NULL)
                /* not a device */
-               return;
+               return 0;
 
        new = malloc(sizeof(*new));
        new->name = strndup(name, t - name);
        new->next = *m;
        *m = new;
+       return 1;
 }
 
 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)
                                in_devs = 0;
                        else if (in_devs) {
-                               ent->devcnt++;
-                               add_member_devname(&ent->members, w);
+                               ent->devcnt +=
+                                       add_member_devname(&ent->members, w);
                                if (strncmp(w, "md", 2)==0) {
                                        /* This has an md device as a component.
                                         * If that device is already in the