summaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authorJes Sorensen <Jes.Sorensen@gmail.com>2017-03-29 20:35:41 +0200
committerJes Sorensen <Jes.Sorensen@gmail.com>2017-03-29 20:35:41 +0200
commit9cd39f015558dba82c293a4433b481b921ceec87 (patch)
tree324f4d170f41b88d9941b06c832638a0ba232950 /util.c
parentGrow: Fixup a pile of cosmetic issues (diff)
downloadmdadm-9cd39f015558dba82c293a4433b481b921ceec87.tar.xz
mdadm-9cd39f015558dba82c293a4433b481b921ceec87.zip
util: Introduce md_get_array_info()
Remove most direct ioctl calls for GET_ARRAY_INFO, except for one, which will be addressed in the next patch. This is the start of the effort to clean up the use of ioctl calls and introduce a more structured API, which will use sysfs and fall back to ioctl for backup. Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
Diffstat (limited to 'util.c')
-rw-r--r--util.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/util.c b/util.c
index 374015ed..725877d1 100644
--- a/util.c
+++ b/util.c
@@ -212,6 +212,15 @@ int cluster_release_dlmlock(int lockid)
#endif
/*
+ * Get array info from the kernel. Longer term we want to deprecate the
+ * ioctl and get it from sysfs.
+ */
+int md_get_array_info(int fd, struct mdu_array_info_s *array)
+{
+ return ioctl(fd, GET_ARRAY_INFO, array);
+}
+
+/*
* Parse a 128 bit uuid in 4 integers
* format is 32 hexx nibbles with options :.<space> separator
* If not exactly 32 hex digits are found, return 0
@@ -539,8 +548,7 @@ int enough_fd(int fd)
int i, rv;
char *avail;
- if (ioctl(fd, GET_ARRAY_INFO, &array) != 0 ||
- array.raid_disks <= 0)
+ if (md_get_array_info(fd, &array) != 0 || array.raid_disks <= 0)
return 0;
avail = xcalloc(array.raid_disks, 1);
for (i = 0; i < MAX_DISKS && array.nr_disks > 0; i++) {
@@ -1175,7 +1183,7 @@ struct supertype *super_by_fd(int fd, char **subarrayp)
minor = sra->array.minor_version;
verstr = sra->text_version;
} else {
- if (ioctl(fd, GET_ARRAY_INFO, &array))
+ if (md_get_array_info(fd, &array))
array.major_version = array.minor_version = 0;
vers = array.major_version;
minor = array.minor_version;