]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
util/must_be_container: Use sysfs_read(GET_VERSION) to determine valid array
authorJes Sorensen <Jes.Sorensen@gmail.com>
Wed, 5 Apr 2017 18:01:30 +0000 (14:01 -0400)
committerJes Sorensen <Jes.Sorensen@gmail.com>
Wed, 5 Apr 2017 18:01:30 +0000 (14:01 -0400)
Use sysfs_read() instead of ioctl(RAID_VERSION) to determine this is
in fact a valid raid array fd.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
util.c

diff --git a/util.c b/util.c
index 9fc7ba03c2349fbf18371df6887e84d5d980ecec..56daee34c5b76c3195d52beb9064be200040492a 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1376,9 +1376,14 @@ int get_dev_sector_size(int fd, char *dname, unsigned int *sectsizep)
  */
 int must_be_container(int fd)
 {
+       struct mdinfo *mdi;
        unsigned long long size;
-       if (md_get_version(fd) < 0)
+
+       mdi = sysfs_read(fd, NULL, GET_VERSION);
+       if (!mdi)
                return 0;
+       sysfs_free(mdi);
+
        if (get_dev_size(fd, NULL, &size) == 0)
                return 1;
        if (size == 0)