From: Neil Brown Date: Fri, 14 Dec 2007 09:13:51 +0000 (+1100) Subject: Make sure sysfs_read never succeeds for a non-MD device. X-Git-Tag: mdadm-2.6.5~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2faf1f5f635419a922cf0072c435a23a78b793a7;p=thirdparty%2Fmdadm.git Make sure sysfs_read never succeeds for a non-MD device. ... just in case. --- diff --git a/sysfs.c b/sysfs.c index 16744f1b..1dbc680f 100644 --- a/sysfs.c +++ b/sysfs.c @@ -76,7 +76,10 @@ struct sysarray *sysfs_read(int fd, int devnum, unsigned long options) if (fd >= 0) { struct stat stb; - if (fstat(fd, &stb)) return NULL; + mdu_version_t vers; + if (fstat(fd, &stb)) return NULL; + if (ioctl(fd, RAID_VERSION, &vers) != 0) + return NULL; if (major(stb.st_rdev)==9) sprintf(sra->name, "md%d", minor(stb.st_rdev)); else