From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1CwxPM-0008IG-IA for mharc-grub-devel@gnu.org; Fri, 04 Feb 2005 01:57:36 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1CwxPB-0008Cf-8R for grub-devel@gnu.org; Fri, 04 Feb 2005 01:57:25 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1CwxOy-00085M-Tq for grub-devel@gnu.org; Fri, 04 Feb 2005 01:57:14 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1CwxOy-00083H-Iz for grub-devel@gnu.org; Fri, 04 Feb 2005 01:57:12 -0500 Received: from [207.217.121.253] (helo=pop-a065d19.pas.sa.earthlink.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Cwx3k-0000YQ-Cw for grub-devel@gnu.org; Fri, 04 Feb 2005 01:35:16 -0500 Received: from user-0vvde2g.cable.mindspring.com ([63.246.184.80] helo=miracle) by pop-a065d19.pas.sa.earthlink.net with esmtp (Exim 3.33 #1) id 1Cwx3i-0006z6-00 for grub-devel@gnu.org; Thu, 03 Feb 2005 22:35:15 -0800 Received: from hollis by miracle with local (Exim 3.36 #1 (Debian)) id 1CwwgV-0005Ko-00 for ; Fri, 04 Feb 2005 00:11:15 -0600 Date: Fri, 4 Feb 2005 00:11:15 -0600 To: grub-devel@gnu.org Message-ID: <20050204061115.GA20463@miracle> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.6+20040907i From: Hollis Blanchard Subject: Re: iterate return values X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Feb 2005 06:57:31 -0000 This one took waaay too long to track down. :( It is very difficult to debug when the problem is that grub_errno has a stale value. This fixes my partition map problems, and has been tested both with Apple and DOS partition maps. -Hollis Index: ChangeLog =================================================================== RCS file: /cvsroot/grub/grub2/ChangeLog,v retrieving revision 1.90 diff -u -p -r1.90 ChangeLog --- ChangeLog 1 Feb 2005 21:53:34 -0000 1.90 +++ ChangeLog 4 Feb 2005 06:34:08 -0000 @@ -1,3 +1,13 @@ +2005-02-03 Hollis Blanchard + + * kern/partition.c (grub_partition_probe): Clear `grub_errno' and + return 0 if `grub_errno' is GRUB_ERR_BAD_PART_TABLE. + (part_map_iterate): Clear `grub_errno' and return 0 if + `partmap->iterate' returns GRUB_ERR_BAD_PART_TABLE. + * partmap/amiga.c (amiga_partition_map_iterate): Return + GRUB_ERR_BAD_PART_TABLE if no partition map magic is found. + * partmap/apple.c (apple_partition_map_iterate): Likewise. + 2005-02-01 Guillem Jover * loader/i386/pc/multiboot_normal.c (GRUB_MOD_INIT): Fix module Index: kern/partition.c =================================================================== RCS file: /cvsroot/grub/grub2/kern/partition.c,v retrieving revision 1.1 diff -u -p -r1.1 partition.c --- kern/partition.c 4 Dec 2004 18:45:45 -0000 1.1 +++ kern/partition.c 4 Feb 2005 06:34:11 -0000 @@ -56,20 +56,28 @@ grub_partition_t grub_partition_probe (struct grub_disk *disk, const char *str) { grub_partition_t part; - + auto int part_map_probe (const grub_partition_map_t partmap); - + int part_map_probe (const grub_partition_map_t partmap) { part = partmap->probe (disk, str); if (part) return 1; - return 0; + + if (grub_errno == GRUB_ERR_BAD_PART_TABLE) + { + /* Continue to next partition map type. */ + grub_errno = GRUB_ERR_NONE; + return 0; + } + + return 1; } /* Use the first partition map type found. */ grub_partition_map_iterate (part_map_probe); - + return part; } @@ -78,12 +86,21 @@ grub_partition_iterate (struct grub_disk int (*hook) (const grub_partition_t partition)) { auto int part_map_iterate (const grub_partition_map_t partmap); - + int part_map_iterate (const grub_partition_map_t partmap) { - return partmap->iterate (disk, hook); + grub_err_t err = partmap->iterate (disk, hook); + + if (err == GRUB_ERR_BAD_PART_TABLE) + { + /* Continue to next partition map type. */ + grub_errno = GRUB_ERR_NONE; + return 0; + } + + return 1; } - + grub_partition_map_iterate (part_map_iterate); return grub_errno; } Index: partmap/amiga.c =================================================================== RCS file: /cvsroot/grub/grub2/partmap/amiga.c,v retrieving revision 1.1 diff -u -p -r1.1 amiga.c --- partmap/amiga.c 4 Dec 2004 18:45:45 -0000 1.1 +++ partmap/amiga.c 4 Feb 2005 06:34:11 -0000 @@ -102,6 +102,10 @@ amiga_partition_map_iterate (grub_disk_t break; } } + + if (next == -1) + return grub_error (GRUB_ERR_BAD_PART_TABLE, + "Amiga partition map not found."); /* The end of the partition list is marked using "-1". */ while (next != -1) Index: partmap/apple.c =================================================================== RCS file: /cvsroot/grub/grub2/partmap/apple.c,v retrieving revision 1.1 diff -u -p -r1.1 apple.c --- partmap/apple.c 4 Dec 2004 18:45:45 -0000 1.1 +++ partmap/apple.c 4 Feb 2005 06:34:11 -0000 @@ -108,7 +108,7 @@ apple_partition_map_iterate (grub_disk_t raw.partition = 0; part.partmap = &grub_apple_partition_map; - + for (;;) { if (grub_disk_read (&raw, pos / GRUB_DISK_SECTOR_SIZE, @@ -134,6 +134,10 @@ apple_partition_map_iterate (grub_disk_t partno++; } + if ((pos / GRUB_DISK_SECTOR_SIZE) == 0) + return grub_error (GRUB_ERR_BAD_PART_TABLE, + "Apple partition map not found."); + return 0; } @@ -178,7 +182,6 @@ apple_partition_map_probe (grub_disk_t d fail: grub_free (p); return 0; - }