grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] show an error instead of segfaulting on grub-probe -t partma


From: Felix Zielcke
Subject: Re: [PATCH] show an error instead of segfaulting on grub-probe -t partmap on a unsynced raid
Date: Wed, 30 Jul 2008 17:11:24 +0200

Am Mittwoch, den 30.07.2008, 13:39 +0200 schrieb Felix Zielcke:

>         for (i = 0; i < array->total_devs; i++)
>           {
>             if (array->device[i])
> 
> 

Above code isn't correct either, as you can see on my mail before
in my testing case device[0] is 0x0 and device[1] is the working one.

I don't think now that on RAID 1 there's a need for a warning/error on
not fully synced mdraid

Here's a patch which fixes this, if this is ok I'll have to think about
the changelog.

Please comment.

Index: disk/raid.c
===================================================================
--- disk/raid.c (Revision 1753)
+++ disk/raid.c (Arbeitskopie)
@@ -75,8 +75,10 @@
   grub_disk_memberlist_t list = NULL, tmp;
   unsigned int i;
   
-  for (i = 0; i < array->total_devs; i++)
+  for (i = 0; i < GRUB_RAID_MAX_DEVICES; i++)
     {
+      if (! array->device[i])
+       continue;
       tmp = grub_malloc (sizeof (*tmp));
       tmp->disk = array->device[i];
       tmp->next = list;
@@ -213,7 +215,7 @@
       {
        unsigned int i = 0;
        
-       for (i = 0; i < array->total_devs; i++)
+       for (i = 0; i < GRUB_RAID_MAX_DEVICES; i++)
          {
            if (array->device[i])
              {
Index: include/grub/raid.h
===================================================================
--- include/grub/raid.h (Revision 1753)
+++ include/grub/raid.h (Arbeitskopie)
@@ -22,6 +22,8 @@
 
 #include <grub/types.h>
 
+#define GRUB_RAID_MAX_DEVICES 32
+
 struct grub_raid_array
 {
   int number;              /* The device number, taken from md_minor so
we
@@ -37,7 +39,7 @@
   char *name;              /* That will be "md<number>". */
   grub_uint64_t disk_size; /* Size of an individual disk, in 512 byte
                              sectors. */
-  grub_disk_t device[32];  /* Array of total_devs devices. */          
+  grub_disk_t device[GRUB_RAID_MAX_DEVICES];  /* Array of total_devs
devices. */          
   struct grub_raid_array *next;
 };






reply via email to

[Prev in Thread] Current Thread [Next in Thread]