[syslinux] [PATCH] utils/isohybrid.c: 002 Correct blocking factor in APM partition block counts

Thomas Schmitt scdbackup at gmx.net
Sun Jun 22 12:15:54 PDT 2014


The block counts in the APM partitions assumed 512 bytes per block,
whereas the start block numbers assume 2048 as announced in the APM header.

This change divides the affected block counts by 4 to correct the assumption.

--- isohybrid.c.001_gpt_name	2014-06-22 20:04:30.000000000 +0200
+++ isohybrid.c.002_apm_block_count	2014-06-22 20:05:13.000000000 +0200
@@ -842,7 +842,7 @@ initialise_apm(uint8_t *gpt, uint32_t st
     part->signature = bendian_short(0x504d);
     part->map_count = bendian_int(apm_parts);
     part->start_block = bendian_int(1);
-    part->block_count = bendian_int(0x10);
+    part->block_count = bendian_int(4);
     strcpy(part->name, "Apple");
     strcpy(part->type, "Apple_partition_map");
     part->data_start = bendian_int(0);
@@ -854,11 +854,11 @@ initialise_apm(uint8_t *gpt, uint32_t st
     part->signature = bendian_short(0x504d);
     part->map_count = bendian_int(3);
     part->start_block = bendian_int(efi_lba);
-    part->block_count = bendian_int(efi_count);
+    part->block_count = bendian_int(efi_count / 4);
     strcpy(part->name, "EFI");
     strcpy(part->type, "Apple_HFS");
     part->data_start = bendian_int(0);
-    part->data_count = bendian_int(efi_count);
+    part->data_count = bendian_int(efi_count / 4);
     part->status = bendian_int(0x33);
 
     part = (struct apple_part_header *)(gpt + 4096);
@@ -868,11 +868,11 @@ initialise_apm(uint8_t *gpt, uint32_t st
 	part->signature = bendian_short(0x504d);
 	part->map_count = bendian_int(3);
 	part->start_block = bendian_int(mac_lba);
-	part->block_count = bendian_int(mac_count);
+	part->block_count = bendian_int(mac_count / 4);
 	strcpy(part->name, "EFI");
 	strcpy(part->type, "Apple_HFS");
 	part->data_start = bendian_int(0);
-	part->data_count = bendian_int(mac_count);
+	part->data_count = bendian_int(mac_count / 4);
 	part->status = bendian_int(0x33);
     } else {
 	part->signature = bendian_short(0x504d);


More information about the Syslinux mailing list