]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Make sure sysfs_read never succeeds for a non-MD device.
authorNeil Brown <neilb@suse.de>
Fri, 14 Dec 2007 09:13:51 +0000 (20:13 +1100)
committerNeil Brown <neilb@suse.de>
Fri, 14 Dec 2007 09:13:51 +0000 (20:13 +1100)
... just in case.

sysfs.c

diff --git a/sysfs.c b/sysfs.c
index 16744f1b6e388cba4a0f5d2bcfd712e1ffcf1d37..1dbc680f8bf0a4b51b9c4e0f6aec8ffd0fc5561c 100644 (file)
--- 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