]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - util.c
sysfs: Use the presence of /sys/block/<dev>/md as indicator of valid device
[thirdparty/mdadm.git] / util.c
diff --git a/util.c b/util.c
index 725877d105bb137658d30d598476a3102074f870..9fc7ba03c2349fbf18371df6887e84d5d980ecec 100644 (file)
--- a/util.c
+++ b/util.c
@@ -220,6 +220,22 @@ int md_get_array_info(int fd, struct mdu_array_info_s *array)
        return ioctl(fd, GET_ARRAY_INFO, array);
 }
 
+/*
+ * Set array info
+ */
+int md_set_array_info(int fd, struct mdu_array_info_s *array)
+{
+       return ioctl(fd, SET_ARRAY_INFO, array);
+}
+
+/*
+ * Get disk info from the kernel.
+ */
+int md_get_disk_info(int fd, struct mdu_disk_info_s *disk)
+{
+       return ioctl(fd, GET_DISK_INFO, disk);
+}
+
 /*
  * Parse a 128 bit uuid in 4 integers
  * format is 32 hexx nibbles with options :.<space> separator
@@ -553,7 +569,7 @@ int enough_fd(int fd)
        avail = xcalloc(array.raid_disks, 1);
        for (i = 0; i < MAX_DISKS && array.nr_disks > 0; i++) {
                disk.number = i;
-               if (ioctl(fd, GET_DISK_INFO, &disk) != 0)
+               if (md_get_disk_info(fd, &disk) != 0)
                        continue;
                if (disk.major == 0 && disk.minor == 0)
                        continue;
@@ -1850,9 +1866,9 @@ int set_array_info(int mdfd, struct supertype *st, struct mdinfo *info)
                memset(&inf, 0, sizeof(inf));
                inf.major_version = info->array.major_version;
                inf.minor_version = info->array.minor_version;
-               rv = ioctl(mdfd, SET_ARRAY_INFO, &inf);
+               rv = md_set_array_info(mdfd, &inf);
        } else
-               rv = ioctl(mdfd, SET_ARRAY_INFO, NULL);
+               rv = md_set_array_info(mdfd, NULL);
        return rv;
 }