]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - restripe.c
Add gpt pseudo-metadata
[thirdparty/mdadm.git] / restripe.c
index f673206102f0aea0c2b449d6ceb067a4230f1e5d..3074693bd2c3f8f36faa4f63ed76a01cacaf07d1 100644 (file)
@@ -565,7 +565,8 @@ int restore_stripes(int *dest, unsigned long long *offsets,
 
        int data_disks = raid_disks - (level == 0 ? 0 : level <= 5 ? 1 : 2);
 
-       posix_memalign((void**)&stripe_buf, 4096, raid_disks * chunk_size);
+       if (posix_memalign((void**)&stripe_buf, 4096, raid_disks * chunk_size))
+               stripe_buf = NULL;
        if (zero == NULL) {
                zero = malloc(chunk_size);
                if (zero)
@@ -582,7 +583,7 @@ int restore_stripes(int *dest, unsigned long long *offsets,
        for (i=0; i<raid_disks; i++)
                stripes[i] = stripe_buf + i * chunk_size;
        while (length > 0) {
-               int len = data_disks * chunk_size;
+               unsigned int len = data_disks * chunk_size;
                unsigned long long offset;
                int disk, qdisk;
                int syndrome_disks;
@@ -591,9 +592,11 @@ int restore_stripes(int *dest, unsigned long long *offsets,
                for (i=0; i < data_disks; i++) {
                        int disk = geo_map(i, start/chunk_size/data_disks,
                                           raid_disks, level, layout);
-                       if (lseek64(source, read_offset, 0) != read_offset)
+                       if ((unsigned long long)lseek64(source, read_offset, 0)
+                           != read_offset)
                                return -1;
-                       if (read(source, stripes[disk], chunk_size) != chunk_size)
+                       if (read(source, stripes[disk],
+                                                    chunk_size) != chunk_size)
                                return -1;
                        read_offset += chunk_size;
                }