summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Kshevetskiy2024-12-30 01:48:47 +0000
committerDaniel Golle2025-09-23 22:15:33 +0000
commit6ea8b6dd44d023312a0e4dfc3a2133df014e401b (patch)
treed6eb35da69796cd2180891092542de8043a2bd42
parentfebfef7a09b15ac3c145ec9093fcc1cfb5e12873 (diff)
downloadfirmware-utils-6ea8b6dd44d023312a0e4dfc3a2133df014e401b.tar.gz
ptgen: fix protective MBR partition size
Creating gpt partition with ptgen results in invalid PMBR. Steps to reproduce: 1) compile ptgen with WANT_ALTERNATE_PTABLE gcc -Wall -DWANT_ALTERNATE_PTABLE -o ptgen ptgen.c cyg_crc32.c 2) Create an image with ptgen ./ptgen -g -o s.img -p 509m 3) Investigate an image with /sbin/fdisk /sbin/fdisk s.img 4) fdisk reports GPT PMBR size mismatch Welcome to fdisk (util-linux 2.40.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. GPT PMBR size mismatch (1042497 != 1042498) will be corrected by write. Command (m for help): Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
-rw-r--r--src/ptgen.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/ptgen.c b/src/ptgen.c
index 24861a0..cc5e744 100644
--- a/src/ptgen.c
+++ b/src/ptgen.c
@@ -490,7 +490,7 @@ static int gen_gptable(uint32_t signature, guid_t guid, unsigned nr)
pte[0].type = 0xEE;
pte[0].start = cpu_to_le32(GPT_HEADER_SECTOR);
- pte[0].length = cpu_to_le32(end - GPT_HEADER_SECTOR);
+ pte[0].length = cpu_to_le32(end + 1 - GPT_HEADER_SECTOR);
to_chs(GPT_HEADER_SECTOR, pte[0].chs_start);
to_chs(end, pte[0].chs_end);