When we read devices from sysfs (../md/dev-*), store them in the same
order that they appear. That makes more sense when exposed to a
human (as the next patch will).
Signed-off-by: NeilBrown <neilb@suse.de>
char *base;
char *dbase;
struct mdinfo *sra;
- struct mdinfo *dev;
+ struct mdinfo *dev, **devp;
DIR *dir = NULL;
struct dirent *de;
goto abort;
sra->array.spare_disks = 0;
+ devp = &sra->devs;
+ sra->devs = NULL;
while ((de = readdir(dir)) != NULL) {
char *ep;
if (de->d_ino == 0 ||
free(dev);
goto abort;
}
-
+
}
strcpy(dev->sys_name, de->d_name);
dev->disk.raid_disk = strtoul(buf, &ep, 10);
}
/* finally add this disk to the array */
- dev->next = sra->devs;
- sra->devs = dev;
+ *devp = dev;
+ devp = & dev->next;
+ dev->next = NULL;
if (options & GET_OFFSET) {
strcpy(dbase, "offset");