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

syslinux-bot for Thomas Schmitt scdbackup at gmx.net
Mon Jun 23 20:09:06 PDT 2014


Commit-ID:  46abb1f5a685191e0ca11dba5b8ba5e3811b6dae
Gitweb:     http://www.syslinux.org/commit/46abb1f5a685191e0ca11dba5b8ba5e3811b6dae
Author:     Thomas Schmitt <scdbackup at gmx.net>
AuthorDate: Sun, 22 Jun 2014 22:24:20 +0200
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Mon, 23 Jun 2014 19:48:57 -0700

utils/isohybrid.c: Write GPT backup to the very end of the image

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.

Signed-off-by: H. Peter Anvin <hpa at zytor.com>

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


More information about the Syslinux-commits mailing list