]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - mdassemble.c
util: Introduce md_get_array_info()
[thirdparty/mdadm.git] / mdassemble.c
index 78d363a328c7e7449cc3b23f91534ee1a88ea5ca..a24b324c9684caad135daa20e2fee145f3ab9dbf 100644 (file)
@@ -32,7 +32,7 @@ char const Name[] = "mdassemble";
 /* from mdopen.c */
 int open_mddev(char *dev, int report_errors/*unused*/)
 {
-       int mdfd = open(dev, O_RDWR);
+       int mdfd = open(dev, O_RDONLY);
        if (mdfd < 0)
                pr_err("error opening %s: %s\n",
                        dev, strerror(errno));
@@ -67,7 +67,7 @@ int main(int argc, char *argv[])
                        if (strcasecmp(array_list->devname, "<ignore>") == 0)
                                continue;
                        mdfd = open_mddev(array_list->devname, 0);
-                       if (mdfd >= 0 && ioctl(mdfd, GET_ARRAY_INFO, &array) == 0) {
+                       if (mdfd >= 0 && md_get_array_info(mdfd, &array) == 0) {
                                rv |= Manage_ro(array_list->devname, mdfd, -1); /* make it readwrite */
                                continue;
                        }