From fbdef49811c9e2b54e2064d9af68cfffa77c6e77 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Wed, 4 Apr 2012 14:00:42 +1000 Subject: [PATCH] Bitmap_offset is a signed number 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 --- mdadm.h | 2 +- super1.c | 4 ++-- sysfs.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mdadm.h b/mdadm.h index 941cffad..9f58800c 100644 --- 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; diff --git a/super1.c b/super1.c index 20f4c866..2770a7f5 100644 --- 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 cddabaee..a1007cf2 100644 --- 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; } -- 2.39.2