]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Monitor.c
util: Introduce md_get_disk_info()
[thirdparty/mdadm.git] / Monitor.c
index 802a9d9864b9cbec68ec8d2214642970070160a7..2c0f717ce505c4572f21b9ca4d709cf9efba14e0 100644 (file)
--- a/Monitor.c
+++ b/Monitor.c
@@ -497,7 +497,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
                return 0;
        }
        fcntl(fd, F_SETFD, FD_CLOEXEC);
-       if (ioctl(fd, GET_ARRAY_INFO, &array)<0) {
+       if (md_get_array_info(fd, &array) < 0) {
                if (!st->err)
                        alert("DeviceDisappeared", dev, NULL, ainfo);
                st->err++;
@@ -608,7 +608,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
             i++) {
                mdu_disk_info_t disc;
                disc.number = i;
-               if (ioctl(fd, GET_DISK_INFO, &disc) >= 0) {
+               if (md_get_disk_info(fd, &disc) >= 0) {
                        info[i].state = disc.state;
                        info[i].major = disc.major;
                        info[i].minor = disc.minor;
@@ -709,9 +709,10 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist,
 
                        st->devname = xstrdup(name);
                        if ((fd = open(st->devname, O_RDONLY)) < 0 ||
-                           ioctl(fd, GET_ARRAY_INFO, &array)< 0) {
+                           md_get_array_info(fd, &array) < 0) {
                                /* no such array */
-                               if (fd >=0) close(fd);
+                               if (fd >= 0)
+                                       close(fd);
                                put_md_name(st->devname);
                                free(st->devname);
                                if (st->metadata) {
@@ -994,6 +995,7 @@ int Wait(char *dev)
 {
        struct stat stb;
        char devnm[32];
+       char *tmp;
        int rv = 1;
        int frozen_remaining = 3;
 
@@ -1002,7 +1004,12 @@ int Wait(char *dev)
                        strerror(errno));
                return 2;
        }
-       strcpy(devnm, stat2devnm(&stb));
+       tmp = stat2devnm(&stb);
+       if (!tmp) {
+               pr_err("%s is not a block device.\n", dev);
+               return 2;
+       }
+       strcpy(devnm, tmp);
 
        while(1) {
                struct mdstat_ent *ms = mdstat_read(1, 0);