2008-02-08 Robert Millan <rmh@aybabtu.com>
* include/grub/raid.h (struct grub_raid_array): Change type of `device' to a grub_disk_t array. * disk/raid.c (grub_raid_read): Replace `device[x].disk' accesses with `device[x]'. (grub_raid_scan_device): Replace `device[x].name' accesses with `device[x]->name'. Simplify initialization of `array->device[x]'.
This commit is contained in:
parent
554f018744
commit
5626aee186
3 changed files with 20 additions and 19 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2008-02-08 Robert Millan <rmh@aybabtu.com>
|
||||||
|
|
||||||
|
* include/grub/raid.h (struct grub_raid_array): Change type of `device'
|
||||||
|
to a grub_disk_t array.
|
||||||
|
* disk/raid.c (grub_raid_read): Replace `device[x].disk' accesses with
|
||||||
|
`device[x]'.
|
||||||
|
(grub_raid_scan_device): Replace `device[x].name' accesses with
|
||||||
|
`device[x]->name'. Simplify initialization of `array->device[x]'.
|
||||||
|
|
||||||
2008-02-08 Robert Millan <rmh@aybabtu.com>
|
2008-02-08 Robert Millan <rmh@aybabtu.com>
|
||||||
|
|
||||||
* disk/raid.c (grub_raid_open, grub_raid_scan_device): Add a few
|
* disk/raid.c (grub_raid_open, grub_raid_scan_device): Add a few
|
||||||
|
|
24
disk/raid.c
24
disk/raid.c
|
@ -150,7 +150,7 @@ grub_raid_read (grub_disk_t disk, grub_disk_addr_t sector,
|
||||||
{
|
{
|
||||||
grub_uint32_t i;
|
grub_uint32_t i;
|
||||||
|
|
||||||
err = grub_disk_read (array->device[disknr].disk, read_sector, 0,
|
err = grub_disk_read (array->device[disknr], read_sector, 0,
|
||||||
read_size << GRUB_DISK_SECTOR_BITS, buf);
|
read_size << GRUB_DISK_SECTOR_BITS, buf);
|
||||||
if (err)
|
if (err)
|
||||||
break;
|
break;
|
||||||
|
@ -193,9 +193,9 @@ grub_raid_read (grub_disk_t disk, grub_disk_addr_t sector,
|
||||||
|
|
||||||
for (i = 0; i < array->total_devs; i++)
|
for (i = 0; i < array->total_devs; i++)
|
||||||
{
|
{
|
||||||
if (array->device[i].disk)
|
if (array->device[i])
|
||||||
{
|
{
|
||||||
err = grub_disk_read (array->device[i].disk, sector, 0,
|
err = grub_disk_read (array->device[i], sector, 0,
|
||||||
size << GRUB_DISK_SECTOR_BITS, buf);
|
size << GRUB_DISK_SECTOR_BITS, buf);
|
||||||
|
|
||||||
if (!err)
|
if (!err)
|
||||||
|
@ -238,8 +238,8 @@ grub_raid_read (grub_disk_t disk, grub_disk_addr_t sector,
|
||||||
{
|
{
|
||||||
grub_uint32_t i;
|
grub_uint32_t i;
|
||||||
|
|
||||||
if (array->device[disknr].disk)
|
if (array->device[disknr])
|
||||||
err = grub_disk_read (array->device[disknr].disk, read_sector, 0,
|
err = grub_disk_read (array->device[disknr], read_sector, 0,
|
||||||
read_size << GRUB_DISK_SECTOR_BITS, buf);
|
read_size << GRUB_DISK_SECTOR_BITS, buf);
|
||||||
|
|
||||||
/* If an error occurs when we already have an degraded
|
/* If an error occurs when we already have an degraded
|
||||||
|
@ -247,7 +247,7 @@ grub_raid_read (grub_disk_t disk, grub_disk_addr_t sector,
|
||||||
if (err && ((array->total_devs - 1) == array->nr_devs))
|
if (err && ((array->total_devs - 1) == array->nr_devs))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (err || ! array->device[disknr].disk)
|
if (err || ! array->device[disknr])
|
||||||
{
|
{
|
||||||
/* Either an error occured or the disk is not
|
/* Either an error occured or the disk is not
|
||||||
available. We have to compute this block from the
|
available. We have to compute this block from the
|
||||||
|
@ -264,7 +264,7 @@ grub_raid_read (grub_disk_t disk, grub_disk_addr_t sector,
|
||||||
|
|
||||||
if (j != (unsigned int) disknr)
|
if (j != (unsigned int) disknr)
|
||||||
{
|
{
|
||||||
err = grub_disk_read (array->device[j].disk, read_sector,
|
err = grub_disk_read (array->device[j], read_sector,
|
||||||
0, buf_size, buf2);
|
0, buf_size, buf2);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
@ -419,7 +419,7 @@ grub_raid_scan_device (const char *name)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array->device[sb.this_disk.number].name != 0)
|
if (array->device[sb.this_disk.number]->name != 0)
|
||||||
{
|
{
|
||||||
/* We found multiple devices with the same number. Again,
|
/* We found multiple devices with the same number. Again,
|
||||||
this shouldn't happen.*/
|
this shouldn't happen.*/
|
||||||
|
@ -502,14 +502,10 @@ grub_raid_scan_device (const char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add the device to the array. */
|
/* Add the device to the array. */
|
||||||
array->device[sb.this_disk.number].name = grub_strdup (name);
|
array->device[sb.this_disk.number] = grub_disk_open (name);
|
||||||
array->device[sb.this_disk.number].disk = grub_disk_open (name);
|
|
||||||
|
|
||||||
if (! array->device[sb.this_disk.number].name
|
if (! array->device[sb.this_disk.number])
|
||||||
|| ! array->device[sb.this_disk.number].disk)
|
|
||||||
{
|
{
|
||||||
grub_free (array->device[sb.this_disk.number].name);
|
|
||||||
|
|
||||||
/* Remove array from the list if we have just added it. */
|
/* Remove array from the list if we have just added it. */
|
||||||
if (array->nr_devs == 0)
|
if (array->nr_devs == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,11 +37,7 @@ struct grub_raid_array
|
||||||
char *name; /* That will be "md<number>". */
|
char *name; /* That will be "md<number>". */
|
||||||
grub_uint64_t disk_size; /* Size of an individual disk, in 512 byte
|
grub_uint64_t disk_size; /* Size of an individual disk, in 512 byte
|
||||||
sectors. */
|
sectors. */
|
||||||
struct
|
grub_disk_t device[32]; /* Array of total_devs devices. */
|
||||||
{
|
|
||||||
char *name; /* Name of the device */
|
|
||||||
grub_disk_t disk; /* The device itself. */
|
|
||||||
} device[32]; /* Array of total_devs devices. */
|
|
||||||
struct grub_raid_array *next;
|
struct grub_raid_array *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue