grub-devel
[Top][All Lists]
Advanced

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

Re: grub-probe fails to find PC partition due to Apple disklabel


From: Pavel Roskin
Subject: Re: grub-probe fails to find PC partition due to Apple disklabel
Date: Tue, 22 Jul 2008 23:48:00 -0400
User-agent: Internet Messaging Program (IMP) H3 (4.1.4)

Quoting Chris Knadle <address@hidden>:

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))

I'm not sure grub_apple_part would describe the first sector correctly. Besides, you only need two bytes. Why reuse "apart"? You can use a 16-bit variable and read those two bytes there.

   But then I want to check the first block against 0x4552, and
apart.first_phys_block is 32-bits.

Why first_phys_block?  The first field is 16 bit wide and is called "magic".

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))

That won't work on little endian systems, including ordinary PC. You are assuming big endian byte order here. Instead, the data from the disk should be converted to CPU-endian from whatever it is and compared to the magic value.

--
Regards,
Pavel Roskin




reply via email to

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