]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - msg.c
Create.c: fix uclibc build
[thirdparty/mdadm.git] / msg.c
diff --git a/msg.c b/msg.c
index 70cefe8f1e44c84d1bb8b9cfe42fac9baab4d6d7..ba0e25be906d5b80de7a9f55ffd504e23accc876 100644 (file)
--- a/msg.c
+++ b/msg.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2008 Intel Corporation
  *
- *     mdmon socket / message handling
+ *     mdmon socket / message handling
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -78,7 +78,6 @@ static int recv_buf(int fd, void* buf, int len, int tmo)
        return 0;
 }
 
-
 int send_message(int fd, struct metadata_update *msg, int tmo)
 {
        __s32 len = msg->len;
@@ -171,7 +170,7 @@ int connect_monitor(char *devname)
 
        addr.sun_family = PF_LOCAL;
        strcpy(addr.sun_path, path);
-       if (connect(sfd, &addr, sizeof(addr)) < 0) {
+       if (connect(sfd, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
                close(sfd);
                return -1;
        }
@@ -216,20 +215,6 @@ int ping_monitor(char *devname)
        return err;
 }
 
-/* ping monitor using device number */
-int ping_monitor_by_id(int devnum)
-{
-       int err = -1;
-       char *container = devnum2devname(devnum);
-
-       if (container) {
-               err = ping_monitor(container);
-               free(container);
-       }
-
-       return err;
-}
-
 static char *ping_monitor_version(char *devname)
 {
        int sfd = connect_monitor(devname);
@@ -291,9 +276,8 @@ int block_subarray(struct mdinfo *sra)
 int check_mdmon_version(char *container)
 {
        char *version = NULL;
-       int devnum = devname2devnum(container);
 
-       if (!mdmon_running(devnum)) {
+       if (!mdmon_running(container)) {
                /* if mdmon is not active we assume that any instance that is
                 * later started will match the current mdadm version, if this
                 * assumption is violated we may inadvertantly rebuild an array
@@ -340,7 +324,7 @@ int block_monitor(char *container, const int freeze)
 {
        struct mdstat_ent *ent, *e, *e2;
        struct mdinfo *sra = NULL;
-       char buf[64];
+       char buf[SYSFS_MAX_BUF_SIZE];
        int rv = 0;
 
        if (check_mdmon_version(container))
@@ -357,7 +341,7 @@ int block_monitor(char *container, const int freeze)
                if (!is_container_member(e, container))
                        continue;
                sysfs_free(sra);
-               sra = sysfs_read(-1, e->devnum, GET_VERSION);
+               sra = sysfs_read(-1, e->devnm, GET_VERSION);
                if (!sra) {
                        pr_err("failed to read sysfs for subarray%s\n",
                               to_subarray(e, container));
@@ -382,7 +366,7 @@ int block_monitor(char *container, const int freeze)
                     !sysfs_attribute_available(sra, NULL, "sync_action")) ||
                    (freeze &&
                     sysfs_attribute_available(sra, NULL, "sync_action") &&
-                    sysfs_get_str(sra, NULL, "sync_action", buf, 20) > 0 &&
+                    sysfs_get_str(sra, NULL, "sync_action", buf, sizeof(buf)) > 0 &&
                     strcmp(buf, "frozen\n") == 0))
                        /* pass */;
                else {
@@ -393,7 +377,7 @@ int block_monitor(char *container, const int freeze)
                 * or part-spares
                 */
                sysfs_free(sra);
-               sra = sysfs_read(-1, e->devnum, GET_DEVS | GET_STATE);
+               sra = sysfs_read(-1, e->devnm, GET_DEVS | GET_STATE);
                if (sra && sra->array.spare_disks > 0) {
                        unblock_subarray(sra, freeze);
                        break;
@@ -409,9 +393,9 @@ int block_monitor(char *container, const int freeze)
                        if (!is_container_member(e2, container))
                                continue;
                        sysfs_free(sra);
-                       sra = sysfs_read(-1, e2->devnum, GET_VERSION);
+                       sra = sysfs_read(-1, e2->devnm, GET_VERSION);
                        if (unblock_subarray(sra, freeze))
-                               pr_err("Failed to unfreeze %s\n", e2->dev);
+                               pr_err("Failed to unfreeze %s\n", e2->devnm);
                }
 
                ping_monitor(container); /* cleared frozen */
@@ -441,13 +425,13 @@ void unblock_monitor(char *container, const int unfreeze)
                if (!is_container_member(e, container))
                        continue;
                sysfs_free(sra);
-               sra = sysfs_read(-1, e->devnum, GET_VERSION|GET_LEVEL);
+               sra = sysfs_read(-1, e->devnm, GET_VERSION|GET_LEVEL);
                if (!sra)
                        continue;
                if (sra->array.level > 0)
                        to_ping++;
                if (unblock_subarray(sra, unfreeze))
-                       pr_err("Failed to unfreeze %s\n", e->dev);
+                       pr_err("Failed to unfreeze %s\n", e->devnm);
        }
        if (to_ping)
                ping_monitor(container);
@@ -456,8 +440,6 @@ void unblock_monitor(char *container, const int unfreeze)
        free_mdstat(ent);
 }
 
-
-
 /* give the manager a chance to view the updated container state.  This
  * would naturally happen due to the manager noticing a change in
  * /proc/mdstat; however, pinging encourages this detection to happen