]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Bitmap_offset is a signed number
authorNeilBrown <neilb@suse.de>
Wed, 4 Apr 2012 04:00:42 +0000 (14:00 +1000)
committerNeilBrown <neilb@suse.de>
Wed, 4 Apr 2012 04:03:45 +0000 (14:03 +1000)
As the bitmap can be before the superblock, bitmap_offset is signed.
But some of the code didn't honour that :-(

Signed-off-by: NeilBrown <neilb@suse.de>
mdadm.h
super1.c
sysfs.c

diff --git a/mdadm.h b/mdadm.h
index 941cffadd8aa1e8f5c1b547e3a625ef318ffaffc..9f58800c7969acf630be2c2d037a3ff62f962af3 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -211,7 +211,7 @@ struct mdinfo {
                unsigned long long recovery_start; /* per-device rebuild position */
                #define MaxSector  (~0ULL) /* resync/recovery complete position */
        };
-       unsigned long           bitmap_offset;  /* 0 == none, 1 == a file */
+       long                    bitmap_offset;  /* 0 == none, 1 == a file */
        unsigned long           safe_mode_delay; /* ms delay to mark clean */
        int                     new_level, delta_disks, new_layout, new_chunk;
        int                     errors;
index 20f4c866ee9e77309810794d7df6219fc7e2dea5..2770a7f54a53548aa1270a2aea199579ebcfaef6 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -620,7 +620,7 @@ static void getinfo_super1(struct supertype *st, struct mdinfo *info, char *map)
        info->data_offset = __le64_to_cpu(sb->data_offset);
        info->component_size = __le64_to_cpu(sb->size);
        if (sb->feature_map & __le32_to_cpu(MD_FEATURE_BITMAP_OFFSET))
-               info->bitmap_offset = __le32_to_cpu(sb->bitmap_offset);
+               info->bitmap_offset = (long)__le32_to_cpu(sb->bitmap_offset);
 
        info->disk.major = 0;
        info->disk.minor = 0;
@@ -1636,7 +1636,7 @@ add_internal_bitmap1(struct supertype *st,
                offset = -room;
        }
 
-       sb->bitmap_offset = __cpu_to_le32(offset);
+       sb->bitmap_offset = (long)__cpu_to_le32(offset);
 
        sb->feature_map = __cpu_to_le32(__le32_to_cpu(sb->feature_map)
                                        | MD_FEATURE_BITMAP_OFFSET);
diff --git a/sysfs.c b/sysfs.c
index cddabaee8b6d17dbfab3deb92fe2687edb4cb4b8..a1007cf276658f0f158a71c4e33657432f3ca07e 100644 (file)
--- a/sysfs.c
+++ b/sysfs.c
@@ -226,7 +226,7 @@ struct mdinfo *sysfs_read(int fd, int devnum, unsigned long options)
                else if (strncmp(buf, "none", 4) == 0)
                        sra->bitmap_offset = 0;
                else if (buf[0] == '+')
-                       sra->bitmap_offset = strtoul(buf+1, NULL, 10);
+                       sra->bitmap_offset = strtol(buf+1, NULL, 10);
                else
                        goto abort;
        }