[syslinux] [PATCH 4/6] utils/isohybrid.c: Write GPT backup to the very end of the image

Thomas Schmitt scdbackup at gmx.net
Sun Jun 22 13:24:20 PDT 2014


The GPT backup header block should start 512 bytes before the end of the
image file (resp. end of the disk device). This block and the backup GPT
array were wrongly written 512 bytes too early.

This change brings the backup GPT at its correct position.
---
 utils/isohybrid.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/utils/isohybrid.c b/utils/isohybrid.c
index ff6b930..1c8f0b6 100644
--- a/utils/isohybrid.c
+++ b/utils/isohybrid.c
@@ -1084,7 +1084,7 @@ main(int argc, char *argv[])
 	 * Primary GPT starts at sector 1, secondary GPT starts at 1 sector
 	 * before the end of the image
 	 */
-	initialise_gpt(buf, 1, (isostat.st_size + padding - 1024) / 512, 1);
+	initialise_gpt(buf, 1, (isostat.st_size + padding - 512) / 512, 1);
 
 	if (fseek(fp, 512, SEEK_SET))
 	    err(1, "%s: seek error - 6", argv[0]);
@@ -1122,7 +1122,7 @@ main(int argc, char *argv[])
 
 	buf += orig_gpt_size - sizeof(struct gpt_header);
 
-	initialise_gpt(buf, (isostat.st_size + padding - 1024) / 512, 1, 0);
+	initialise_gpt(buf, (isostat.st_size + padding - 512) / 512, 1, 0);
 
 	/* Shift back far enough to write the 128 GPT entries */
 	buf -= 128 * sizeof(struct gpt_part_header);
@@ -1132,7 +1132,7 @@ main(int argc, char *argv[])
 	 * end of the image
 	 */
 
-	if (fseeko(fp, (isostat.st_size + padding) - orig_gpt_size - 512,
+	if (fseeko(fp, (isostat.st_size + padding) - orig_gpt_size,
 		  SEEK_SET))
 	    err(1, "%s: seek error - 8", argv[0]);
 
-- 
1.8.4.2



More information about the Syslinux mailing list