Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KLUUA-0000KQ-KN for mharc-grub-devel@gnu.org; Tue, 22 Jul 2008 22:53:50 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KLUU9-0000K5-Kg for grub-devel@gnu.org; Tue, 22 Jul 2008 22:53:49 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KLUU8-0000JN-0r for grub-devel@gnu.org; Tue, 22 Jul 2008 22:53:49 -0400 Received: from [199.232.76.173] (port=59964 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KLUU7-0000JF-RF for grub-devel@gnu.org; Tue, 22 Jul 2008 22:53:47 -0400 Received: from lethe.ofobscurity.com ([64.85.165.57]:43842) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KLUU7-0003D2-FL for grub-devel@gnu.org; Tue, 22 Jul 2008 22:53:47 -0400 Received: from user-160u3tu.cable.mindspring.com ([76.15.15.190] helo=anan7.local) by lethe.ofobscurity.com with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1KLUU2-0007Vo-5T for grub-devel@gnu.org; Tue, 22 Jul 2008 22:53:42 -0400 From: Chris Knadle Organization: CoreDump.us To: The development of GRUB 2 Date: Tue, 22 Jul 2008 22:53:49 -0400 User-Agent: KMail/1.9.9 References: <200804131734.50447.Chris.Knadle@coredump.us> <200804141021.49995.Chris.Knadle@coredump.us> <1208193649.4027.19.camel@dv> In-Reply-To: <1208193649.4027.19.camel@dv> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200807222253.49161.Chris.Knadle@coredump.us> X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) Subject: Re: grub-probe fails to find PC partition due to Apple disklabel 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: Wed, 23 Jul 2008 02:53:49 -0000 Felix Zielcke asked me about the Apple/PC hybrid disk problem, so I'm trying to figure out how to fix it. Sorry for letting this fall through the cracks; this is from three months ago. On Monday 14 April 2008, Pavel Roskin wrote: > On Mon, 2008-04-14 at 10:21 -0400, Chris Knadle wrote: > > Instead of probing for partmaps in a particular order, it seems that > > solving for this might best be done by probing for all of the possible > > partmaps for the architecture and trying to figure out which one best > > fits. grub2's grub-probe is clearly already doing this; _however_, > > somehow the PC partmap probe is subtly different depending on whether > > partmap/apple.c is included in the search. > > Apple and PC partition maps can coexist. The place occupied by the > PC partition and the PC magic is not used by the Apple partition. Yeah, I see -- this includes the Apple magic of 0xAA55 that's placed in Sector 0, so searching for that won't help. > The way to differentiate them would be to check at the first sector. If > it starts with 0x45 0x52, then it's an Apple partition. A PC partition > would have an executable entry there. The Apple magic would decode to: > > inc %bp > push %dx > > It's highly unlikely to be used in the first two instructions of the PC > boot code. > > partmap/apple.c starts reading with the second sector (unsigned pos = > GRUB_DISK_SECTOR_SIZE). Perhaps it should read the first sector to > check the magic. I see where you got 0x4552 from; it's the HFS+ magic descriptor. For the moment I'm using the following #define for that: #define GRUB_APPLE_FIRST_SECTOR_MAGIC 0x4552 I'm trying to figure out how to get grub to check the first sector. Mainly I'm asking for hints. I think it involves running a new instance of grub_disk_read for the first sector (sector 0 of the partition) within the apple_partition_map_iterate function -- something like: grub_disk_read(&raw, 0, 0, sizeof (struct grub_apple_part), (char *)&apart)) But then I want to check the first block against 0x4552, and apart.first_phys_block is 32-bits. Since I want the first (high) 16 bits, I think I need to make the comparison in a way such as: if ((apart.first_phys_block & 0xFFFF0000) == (0x4552 << 16)) Is this vaguely on the right track? Thanks. -- Chris -- Chris Knadle Chris.Knadle@coredump.us