* [PATCH] Support Apple partition map with sector size different from 512 bytes.
@ 2009-07-28 10:40 Vladimir 'phcoder' Serbinenko
2009-07-28 11:28 ` Vladimir 'phcoder' Serbinenko
2009-07-28 18:16 ` Robert Millan
0 siblings, 2 replies; 5+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2009-07-28 10:40 UTC (permalink / raw)
To: The development of GRUB 2
[-- Attachment #1: Type: text/plain, Size: 106 bytes --]
--
Regards
Vladimir 'phcoder' Serbinenko
Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
[-- Attachment #2: applemap.diff --]
[-- Type: text/plain, Size: 2106 bytes --]
diff --git a/ChangeLog b/ChangeLog
index 752bde8..1502765 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-07-28 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Support Apple partition map with sector size different from 512 bytes.
+
+ * partmap/apple.c (grub_apple_header): New field 'blocksize'.
+ (apple_partition_map_iterate): Respect 'aheader.blocksize'
+
2009-07-25 Felix Zielcke <fzielcke@z-51.de>
* kern/file.c (grub_file_open): Revert to previous check with
diff --git a/partmap/apple.c b/partmap/apple.c
index fce2f2c..c317908 100644
--- a/partmap/apple.c
+++ b/partmap/apple.c
@@ -30,6 +30,7 @@ struct grub_apple_header
/* The magic number to identify the partition map, it should have
the value `0x4552'. */
grub_uint16_t magic;
+ grub_uint16_t blocksize;
};
struct grub_apple_part
@@ -106,7 +107,7 @@ apple_partition_map_iterate (grub_disk_t disk,
struct grub_apple_part apart;
struct grub_disk raw;
int partno = 0;
- unsigned pos = GRUB_DISK_SECTOR_SIZE;
+ unsigned pos;
/* Enforce raw disk access. */
raw = *disk;
@@ -126,6 +127,8 @@ apple_partition_map_iterate (grub_disk_t disk,
goto fail;
}
+ pos = grub_be_to_cpu16 (aheader.blocksize);
+
for (;;)
{
if (grub_disk_read (&raw, pos / GRUB_DISK_SECTOR_SIZE,
@@ -142,8 +145,12 @@ apple_partition_map_iterate (grub_disk_t disk,
break;
}
- part.start = grub_be_to_cpu32 (apart.first_phys_block);
- part.len = grub_be_to_cpu32 (apart.blockcnt);
+ part.start = ((grub_disk_addr_t) grub_be_to_cpu32 (apart.first_phys_block)
+ * grub_be_to_cpu16 (aheader.blocksize))
+ / GRUB_DISK_SECTOR_SIZE;
+ part.len = ((grub_disk_addr_t) grub_be_to_cpu32 (apart.blockcnt)
+ * grub_be_to_cpu16 (aheader.blocksize))
+ / GRUB_DISK_SECTOR_SIZE;
part.offset = pos;
part.index = partno;
@@ -160,7 +167,7 @@ apple_partition_map_iterate (grub_disk_t disk,
== GRUB_DISK_SECTOR_SIZE * 2)
return 0;
- pos += sizeof (struct grub_apple_part);
+ pos += grub_be_to_cpu16 (aheader.blocksize);
partno++;
}
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] Support Apple partition map with sector size different from 512 bytes.
2009-07-28 10:40 [PATCH] Support Apple partition map with sector size different from 512 bytes Vladimir 'phcoder' Serbinenko
@ 2009-07-28 11:28 ` Vladimir 'phcoder' Serbinenko
2009-07-28 18:16 ` Robert Millan
1 sibling, 0 replies; 5+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2009-07-28 11:28 UTC (permalink / raw)
To: The development of GRUB 2
[-- Attachment #1: Type: text/plain, Size: 163 bytes --]
Reading specs revealed further problems. Here is a fix
--
Regards
Vladimir 'phcoder' Serbinenko
Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
[-- Attachment #2: applemap.diff --]
[-- Type: text/plain, Size: 2542 bytes --]
diff --git a/ChangeLog b/ChangeLog
index 752bde8..2c46f76 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-07-28 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Support Apple partition map with sector size different from 512 bytes.
+
+ * partmap/apple.c (grub_apple_header): New field 'blocksize'.
+ (apple_partition_map_iterate): Respect 'aheader.blocksize'
+ and 'apart.partmap_size'.
+
2009-07-25 Felix Zielcke <fzielcke@z-51.de>
* kern/file.c (grub_file_open): Revert to previous check with
diff --git a/partmap/apple.c b/partmap/apple.c
index fce2f2c..04ccff1 100644
--- a/partmap/apple.c
+++ b/partmap/apple.c
@@ -30,6 +30,7 @@ struct grub_apple_header
/* The magic number to identify the partition map, it should have
the value `0x4552'. */
grub_uint16_t magic;
+ grub_uint16_t blocksize;
};
struct grub_apple_part
@@ -105,8 +106,8 @@ apple_partition_map_iterate (grub_disk_t disk,
struct grub_apple_header aheader;
struct grub_apple_part apart;
struct grub_disk raw;
- int partno = 0;
- unsigned pos = GRUB_DISK_SECTOR_SIZE;
+ int partno = 0, partnum = 0;
+ unsigned pos;
/* Enforce raw disk access. */
raw = *disk;
@@ -126,7 +127,9 @@ apple_partition_map_iterate (grub_disk_t disk,
goto fail;
}
- for (;;)
+ pos = grub_be_to_cpu16 (aheader.blocksize);
+
+ do
{
if (grub_disk_read (&raw, pos / GRUB_DISK_SECTOR_SIZE,
pos % GRUB_DISK_SECTOR_SIZE,
@@ -142,8 +145,15 @@ apple_partition_map_iterate (grub_disk_t disk,
break;
}
- part.start = grub_be_to_cpu32 (apart.first_phys_block);
- part.len = grub_be_to_cpu32 (apart.blockcnt);
+ if (partnum == 0)
+ partnum = grub_be_to_cpu32 (apart.partmap_size);
+
+ part.start = ((grub_disk_addr_t) grub_be_to_cpu32 (apart.first_phys_block)
+ * grub_be_to_cpu16 (aheader.blocksize))
+ / GRUB_DISK_SECTOR_SIZE;
+ part.len = ((grub_disk_addr_t) grub_be_to_cpu32 (apart.blockcnt)
+ * grub_be_to_cpu16 (aheader.blocksize))
+ / GRUB_DISK_SECTOR_SIZE;
part.offset = pos;
part.index = partno;
@@ -156,15 +166,12 @@ apple_partition_map_iterate (grub_disk_t disk,
if (hook (disk, &part))
return grub_errno;
- if (grub_be_to_cpu32 (apart.first_phys_block)
- == GRUB_DISK_SECTOR_SIZE * 2)
- return 0;
-
- pos += sizeof (struct grub_apple_part);
+ pos += grub_be_to_cpu16 (aheader.blocksize);
partno++;
}
+ while (partno < partnum);
- if (pos != GRUB_DISK_SECTOR_SIZE)
+ if (partno != 0)
return 0;
fail:
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] Support Apple partition map with sector size different from 512 bytes.
2009-07-28 10:40 [PATCH] Support Apple partition map with sector size different from 512 bytes Vladimir 'phcoder' Serbinenko
2009-07-28 11:28 ` Vladimir 'phcoder' Serbinenko
@ 2009-07-28 18:16 ` Robert Millan
2009-07-28 21:10 ` Vladimir 'phcoder' Serbinenko
1 sibling, 1 reply; 5+ messages in thread
From: Robert Millan @ 2009-07-28 18:16 UTC (permalink / raw)
To: The development of GRUB 2
On Tue, Jul 28, 2009 at 12:40:32PM +0200, Vladimir 'phcoder' Serbinenko wrote:
> --- a/partmap/apple.c
> +++ b/partmap/apple.c
> @@ -30,6 +30,7 @@ struct grub_apple_header
> /* The magic number to identify the partition map, it should have
> the value `0x4552'. */
> grub_uint16_t magic;
> + grub_uint16_t blocksize;
> };
Did you confirm that the presence of this member is not version-dependant?
--
Robert Millan
The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
how) you may access your data; but nobody's threatening your freedom: we
still allow you to remove your data and not access it at all."
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Support Apple partition map with sector size different from 512 bytes.
2009-07-28 18:16 ` Robert Millan
@ 2009-07-28 21:10 ` Vladimir 'phcoder' Serbinenko
2009-07-29 18:15 ` Vladimir 'phcoder' Serbinenko
0 siblings, 1 reply; 5+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2009-07-28 21:10 UTC (permalink / raw)
To: The development of GRUB 2
On Tue, Jul 28, 2009 at 8:16 PM, Robert Millan<rmh@aybabtu.com> wrote:
> On Tue, Jul 28, 2009 at 12:40:32PM +0200, Vladimir 'phcoder' Serbinenko wrote:
>> --- a/partmap/apple.c
>> +++ b/partmap/apple.c
>> @@ -30,6 +30,7 @@ struct grub_apple_header
>> /* The magic number to identify the partition map, it should have
>> the value `0x4552'. */
>> grub_uint16_t magic;
>> + grub_uint16_t blocksize;
>> };
>
> Did you confirm that the presence of this member is not version-dependant?
>
I read about it in a pretty old document
http://developer.apple.com/documentation/mac/Devices/Devices-121.html.
I will do further research as time permits
> --
> Robert Millan
>
> The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
> how) you may access your data; but nobody's threatening your freedom: we
> still allow you to remove your data and not access it at all."
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>
--
Regards
Vladimir 'phcoder' Serbinenko
Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Support Apple partition map with sector size different from 512 bytes.
2009-07-28 21:10 ` Vladimir 'phcoder' Serbinenko
@ 2009-07-29 18:15 ` Vladimir 'phcoder' Serbinenko
0 siblings, 0 replies; 5+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2009-07-29 18:15 UTC (permalink / raw)
To: The development of GRUB 2
On Tue, Jul 28, 2009 at 11:10 PM, Vladimir 'phcoder'
Serbinenko<phcoder@gmail.com> wrote:
> On Tue, Jul 28, 2009 at 8:16 PM, Robert Millan<rmh@aybabtu.com> wrote:
>> On Tue, Jul 28, 2009 at 12:40:32PM +0200, Vladimir 'phcoder' Serbinenko wrote:
>>> --- a/partmap/apple.c
>>> +++ b/partmap/apple.c
>>> @@ -30,6 +30,7 @@ struct grub_apple_header
>>> /* The magic number to identify the partition map, it should have
>>> the value `0x4552'. */
>>> grub_uint16_t magic;
>>> + grub_uint16_t blocksize;
>>> };
>>
>> Did you confirm that the presence of this member is not version-dependant?
>>
> I read about it in a pretty old document
> http://developer.apple.com/documentation/mac/Devices/Devices-121.html.
This document is from 3 JUL 1996. When I tried create anything older
in emulator I invariantly got an unpartioned image. This may however
be an emulator artifact. Additionally we don't support Old World ROM
and New World ROM was introduced around 1998
> I will do further research as time permits
>> --
>> Robert Millan
>>
>> The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
>> how) you may access your data; but nobody's threatening your freedom: we
>> still allow you to remove your data and not access it at all."
>>
>>
>> _______________________________________________
>> Grub-devel mailing list
>> Grub-devel@gnu.org
>> http://lists.gnu.org/mailman/listinfo/grub-devel
>>
>
>
>
> --
> Regards
> Vladimir 'phcoder' Serbinenko
>
> Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
>
--
Regards
Vladimir 'phcoder' Serbinenko
Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-07-29 18:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-28 10:40 [PATCH] Support Apple partition map with sector size different from 512 bytes Vladimir 'phcoder' Serbinenko
2009-07-28 11:28 ` Vladimir 'phcoder' Serbinenko
2009-07-28 18:16 ` Robert Millan
2009-07-28 21:10 ` Vladimir 'phcoder' Serbinenko
2009-07-29 18:15 ` Vladimir 'phcoder' Serbinenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.