From: Jes Sorensen Date: Wed, 5 Apr 2017 18:01:30 +0000 (-0400) Subject: util/must_be_container: Use sysfs_read(GET_VERSION) to determine valid array X-Git-Tag: mdadm-4.1-rc1~213 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5c924f441cedce2a13c48b12be35250560ee575;p=thirdparty%2Fmdadm.git util/must_be_container: Use sysfs_read(GET_VERSION) to determine valid array Use sysfs_read() instead of ioctl(RAID_VERSION) to determine this is in fact a valid raid array fd. Signed-off-by: Jes Sorensen --- diff --git a/util.c b/util.c index 9fc7ba03..56daee34 100644 --- 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)