diff options
author | NeilBrown <neilb@suse.de> | 2013-06-19 02:33:47 +0200 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2013-06-19 02:33:47 +0200 |
commit | 64e103fe19c84b9ec828a833c1def500d1b70c67 (patch) | |
tree | e53c40444a07e5ec2e04f1057b3d3eb011246298 /sysfs.c | |
parent | raid6check: Check return value of lseek64() (diff) | |
download | mdadm-64e103fe19c84b9ec828a833c1def500d1b70c67.tar.xz mdadm-64e103fe19c84b9ec828a833c1def500d1b70c67.zip |
sysfs_read: return devices in same order as in filesystem.
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>
Diffstat (limited to 'sysfs.c')
-rw-r--r-- | sysfs.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -96,7 +96,7 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options) char *base; char *dbase; struct mdinfo *sra; - struct mdinfo *dev; + struct mdinfo *dev, **devp; DIR *dir = NULL; struct dirent *de; @@ -235,6 +235,8 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options) 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 || @@ -266,7 +268,7 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options) free(dev); goto abort; } - + } strcpy(dev->sys_name, de->d_name); dev->disk.raid_disk = strtoul(buf, &ep, 10); @@ -292,8 +294,9 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options) } /* 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"); |