* grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Add missing
endian transformations. * grub-core/disk/mdraid_linux.c (grub_mdraid_detect): Likewise. Based on report by: Doug Nazar.
This commit is contained in:
parent
0ca09e6c52
commit
c0cf26da6b
3 changed files with 39 additions and 24 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2011-01-07 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Add missing
|
||||||
|
endian transformations.
|
||||||
|
* grub-core/disk/mdraid_linux.c (grub_mdraid_detect): Likewise.
|
||||||
|
Based on report by: Doug Nazar.
|
||||||
|
|
||||||
2011-01-07 Doug Nazar <nazard.michi@gmail.com>
|
2011-01-07 Doug Nazar <nazard.michi@gmail.com>
|
||||||
|
|
||||||
* grub-core/disk/raid5_recover.c (grub_raid5_recover): Add missing
|
* grub-core/disk/raid5_recover.c (grub_raid5_recover): Add missing
|
||||||
|
|
|
@ -143,24 +143,27 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array,
|
||||||
&sb))
|
&sb))
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
|
|
||||||
if (sb.magic != SB_MAGIC)
|
if (grub_le_to_cpu32 (sb.magic) != SB_MAGIC)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
{
|
{
|
||||||
grub_uint64_t sb_size;
|
grub_uint64_t sb_size;
|
||||||
struct grub_raid_super_1x *real_sb;
|
struct grub_raid_super_1x *real_sb;
|
||||||
|
grub_uint32_t level;
|
||||||
|
|
||||||
if (sb.major_version != 1)
|
if (grub_le_to_cpu32 (sb.major_version) != 1)
|
||||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||||
"Unsupported RAID version: %d",
|
"Unsupported RAID version: %d",
|
||||||
sb.major_version);
|
grub_le_to_cpu32 (sb.major_version));
|
||||||
|
|
||||||
|
level = grub_le_to_cpu32 (sb.level);
|
||||||
|
|
||||||
/* Multipath. */
|
/* Multipath. */
|
||||||
if ((int) sb.level == -4)
|
if ((int) level == -4)
|
||||||
sb.level = 1;
|
level = 1;
|
||||||
|
|
||||||
if (sb.level != 0 && sb.level != 1 && sb.level != 4 &&
|
if (level != 0 && level != 1 && level != 4 &&
|
||||||
sb.level != 5 && sb.level != 6 && sb.level != 10)
|
level != 5 && level != 6 && level != 10)
|
||||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||||
"Unsupported RAID level: %d", sb.level);
|
"Unsupported RAID level: %d", sb.level);
|
||||||
|
|
||||||
|
@ -209,7 +212,7 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array,
|
||||||
|
|
||||||
grub_memcpy (array->uuid, real_sb->set_uuid, 16);
|
grub_memcpy (array->uuid, real_sb->set_uuid, 16);
|
||||||
|
|
||||||
*start_sector = real_sb->data_offset;
|
*start_sector = grub_le_to_cpu64 (real_sb->data_offset);
|
||||||
|
|
||||||
grub_free (real_sb);
|
grub_free (real_sb);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -167,6 +167,7 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array,
|
||||||
grub_uint64_t size;
|
grub_uint64_t size;
|
||||||
struct grub_raid_super_09 sb;
|
struct grub_raid_super_09 sb;
|
||||||
grub_uint32_t *uuid;
|
grub_uint32_t *uuid;
|
||||||
|
grub_uint32_t level;
|
||||||
|
|
||||||
/* The sector where the mdraid 0.90 superblock is stored, if available. */
|
/* The sector where the mdraid 0.90 superblock is stored, if available. */
|
||||||
size = grub_disk_get_size (disk);
|
size = grub_disk_get_size (disk);
|
||||||
|
@ -178,36 +179,40 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array,
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
|
|
||||||
/* Look whether there is a mdraid 0.90 superblock. */
|
/* Look whether there is a mdraid 0.90 superblock. */
|
||||||
if (sb.md_magic != SB_MAGIC)
|
if (grub_le_to_cpu32 (sb.md_magic) != SB_MAGIC)
|
||||||
return grub_error (GRUB_ERR_OUT_OF_RANGE, "not 0.9x raid");
|
return grub_error (GRUB_ERR_OUT_OF_RANGE, "not 0.9x raid");
|
||||||
|
|
||||||
if (sb.major_version != 0 || sb.minor_version != 90)
|
if (grub_le_to_cpu32 (sb.major_version) != 0
|
||||||
|
|| grub_le_to_cpu32 (sb.minor_version) != 90)
|
||||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||||
"unsupported RAID version: %d.%d",
|
"unsupported RAID version: %d.%d",
|
||||||
sb.major_version, sb.minor_version);
|
grub_le_to_cpu32 (sb.major_version),
|
||||||
|
grub_le_to_cpu32 (sb.minor_version));
|
||||||
|
|
||||||
/* FIXME: Check the checksum. */
|
/* FIXME: Check the checksum. */
|
||||||
|
|
||||||
|
level = grub_le_to_cpu32 (sb.level);
|
||||||
/* Multipath. */
|
/* Multipath. */
|
||||||
if ((int) sb.level == -4)
|
if ((int) level == -4)
|
||||||
sb.level = 1;
|
level = 1;
|
||||||
|
|
||||||
if (sb.level != 0 && sb.level != 1 && sb.level != 4 &&
|
if (level != 0 && level != 1 && level != 4 &&
|
||||||
sb.level != 5 && sb.level != 6 && sb.level != 10)
|
level != 5 && level != 6 && level != 10)
|
||||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||||
"unsupported RAID level: %d", sb.level);
|
"unsupported RAID level: %d", level);
|
||||||
if (sb.this_disk.number == 0xffff || sb.this_disk.number == 0xfffe)
|
if (grub_le_to_cpu32 (sb.this_disk.number) == 0xffff
|
||||||
|
|| grub_le_to_cpu32 (sb.this_disk.number) == 0xfffe)
|
||||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||||
"spares aren't implemented");
|
"spares aren't implemented");
|
||||||
|
|
||||||
array->name = NULL;
|
array->name = NULL;
|
||||||
array->number = sb.md_minor;
|
array->number = grub_le_to_cpu32 (sb.md_minor);
|
||||||
array->level = sb.level;
|
array->level = level;
|
||||||
array->layout = sb.layout;
|
array->layout = grub_le_to_cpu32 (sb.layout);
|
||||||
array->total_devs = sb.raid_disks;
|
array->total_devs = grub_le_to_cpu32 (sb.raid_disks);
|
||||||
array->disk_size = (sb.size) ? sb.size * 2 : sector;
|
array->disk_size = (sb.size) ? grub_le_to_cpu32 (sb.size) * 2 : sector;
|
||||||
array->chunk_size = sb.chunk_size >> 9;
|
array->chunk_size = grub_le_to_cpu32 (sb.chunk_size) >> 9;
|
||||||
array->index = sb.this_disk.number;
|
array->index = grub_le_to_cpu32 (sb.this_disk.number);
|
||||||
array->uuid_len = 16;
|
array->uuid_len = 16;
|
||||||
array->uuid = grub_malloc (16);
|
array->uuid = grub_malloc (16);
|
||||||
if (!array->uuid)
|
if (!array->uuid)
|
||||||
|
|
Loading…
Reference in a new issue