]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super-intel.c
Remove race for starting container devices.
[thirdparty/mdadm.git] / super-intel.c
index af06660bd6e906daf1f7edf8bc369760fd897f73..dfa85aa1b7f6f08f953892cb6d67ecc127303b0c 100644 (file)
@@ -2864,7 +2864,7 @@ static void fd2devname(int fd, char *name)
        sprintf(path, "/sys/dev/block/%d:%d",
                major(st.st_rdev), minor(st.st_rdev));
 
-       rv = readlink(path, dname, sizeof(dname));
+       rv = readlink(path, dname, sizeof(dname)-1);
        if (rv <= 0)
                return;
        
@@ -6015,7 +6015,9 @@ static int mark_failure(struct imsm_dev *dev, struct imsm_disk *disk, int idx)
        if (is_failed(disk) && (ord & IMSM_ORD_REBUILD))
                return 0;
 
-       sprintf(buf, "%s:0", disk->serial);
+       memcpy(buf, disk->serial, MAX_RAID_SERIAL_LEN);
+       buf[MAX_RAID_SERIAL_LEN] = '\000';
+       strcat(buf, ":0");
        if ((len = strlen(buf)) >= MAX_RAID_SERIAL_LEN)
                shift = len - MAX_RAID_SERIAL_LEN + 1;
        strncpy((char *)disk->serial, &buf[shift], MAX_RAID_SERIAL_LEN);
@@ -6640,9 +6642,9 @@ static struct mdinfo *imsm_activate_spare(struct active_array *a,
         * are removed from container.
         */
        if (failed) {
-               dprintf("found failed disks in %s, check if there another"
+               dprintf("found failed disks in %.*s, check if there another"
                        "failed sub-array.\n",
-                       dev->volume);
+                       MAX_RAID_SERIAL_LEN, dev->volume);
                /* check if states of the other volumes allow for rebuild */
                for (i = 0; i <  super->anchor->num_raid_devs; i++) {
                        if (i != inst) {