sysfs: Use the presence of /sys/block/<dev>/md as indicator of valid device
Rather than calling ioctl(RAID_VERSION), use the presence of /sys/block/<dev>/md as indicator of the device being valid and sysfs being active for it. The ioctl could return valid data, but sysfs not mounted, which renders sysfs_init() useless anyway. Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
This commit is contained in:
parent
13428e2e76
commit
67a02d5200
17
sysfs.c
17
sysfs.c
|
@ -86,15 +86,22 @@ void sysfs_init_dev(struct mdinfo *mdi, unsigned long devid)
|
||||||
|
|
||||||
void sysfs_init(struct mdinfo *mdi, int fd, char *devnm)
|
void sysfs_init(struct mdinfo *mdi, int fd, char *devnm)
|
||||||
{
|
{
|
||||||
|
struct stat stb;
|
||||||
|
char fname[MAX_SYSFS_PATH_LEN];
|
||||||
|
|
||||||
mdi->sys_name[0] = 0;
|
mdi->sys_name[0] = 0;
|
||||||
if (fd >= 0) {
|
if (fd >= 0)
|
||||||
mdu_version_t vers;
|
|
||||||
if (ioctl(fd, RAID_VERSION, &vers) != 0)
|
|
||||||
return;
|
|
||||||
devnm = fd2devnm(fd);
|
devnm = fd2devnm(fd);
|
||||||
}
|
|
||||||
if (devnm == NULL)
|
if (devnm == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
snprintf(fname, MAX_SYSFS_PATH_LEN, "/sys/block/%s/md", devnm);
|
||||||
|
|
||||||
|
if (stat(fname, &stb))
|
||||||
|
return;
|
||||||
|
if (!S_ISDIR(stb.st_mode))
|
||||||
|
return;
|
||||||
strcpy(mdi->sys_name, devnm);
|
strcpy(mdi->sys_name, devnm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue