summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2016-06-05 10:09:17 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2016-06-05 10:09:17 +0200
commit90c2feebe3d4aab7b8aa4170f020c2872ddfcc23 (patch)
tree38653a866f87c946337e0f43675633a06f5d8d87
parent365499b706413fe4edde53ac383e25770924f98d (diff)
Fix Linux Raid md size detection to use 512-bytes sector size
-rw-r--r--src/md.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/md.c b/src/md.c
index 8377401..5d25331 100644
--- a/src/md.c
+++ b/src/md.c
@@ -206,14 +206,14 @@ int recover_MD(disk_t *disk_car, const struct mdp_superblock_s *sb, partition_t
partition->part_type_gpt=GPT_ENT_TYPE_LINUX_RAID;
if(le32(sb->major_version)==0)
{
- partition->part_size=(uint64_t)(le32(sb->size)<<1)*disk_car->sector_size+MD_RESERVED_BYTES;
+ partition->part_size=(uint64_t)(le32(sb->size)<<1)*512+MD_RESERVED_BYTES; /* 512-byte sectors */
memcpy(&partition->part_uuid, &sb->set_uuid0, 4);
memcpy((char*)(&partition->part_uuid)+4, &sb->set_uuid1, 3*4);
}
else
{
const struct mdp_superblock_1 *sb1=(const struct mdp_superblock_1 *)sb;
- partition->part_size=(uint64_t)le64(sb1->size) * (uint64_t)disk_car->sector_size+4096;
+ partition->part_size=(uint64_t)le64(sb1->size) * 512 + 4096; /* 512-byte sectors */
memcpy(&partition->part_uuid, &sb1->set_uuid, 16);
}
return 0;
@@ -226,14 +226,14 @@ int recover_MD(disk_t *disk_car, const struct mdp_superblock_s *sb, partition_t
partition->part_type_gpt=GPT_ENT_TYPE_LINUX_RAID;
if(be32(sb->major_version)==0)
{
- partition->part_size=(uint64_t)(be32(sb->size)<<1)*disk_car->sector_size+MD_RESERVED_BYTES;
+ partition->part_size=(uint64_t)(be32(sb->size)<<1)*512+MD_RESERVED_BYTES; /* 512-byte sectors */
memcpy(&partition->part_uuid, &sb->set_uuid0, 4);
memcpy((char*)(&partition->part_uuid)+4, &sb->set_uuid1, 3*4);
}
else
{
const struct mdp_superblock_1 *sb1=(const struct mdp_superblock_1 *)sb;
- partition->part_size=(uint64_t)be64(sb1->size) * (uint64_t)disk_car->sector_size+4096;
+ partition->part_size=(uint64_t)be64(sb1->size) * 512 + 4096; /* 512-byte sectors */
memcpy(&partition->part_uuid, &sb1->set_uuid, 16);
}
return 0;