From: Mikhail Kshevetskiy Date: Mon, 30 Dec 2024 02:28:49 +0000 (+0300) Subject: ptgen: do not create stub partition to fill a gap if gap caused by alignment X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=f1f98b0b8456e89f6c959d8f028c5204da82365e;p=project%2Ffirmware-utils.git ptgen: do not create stub partition to fill a gap if gap caused by alignment ptgen tends to create stub partitions between the end of GPT entry table and the start of the first disk. Normally fdisk/gdisk aligns partition to 1MB boundary, so there is 2014 sectors gap before the first partition. It is absolutely normal. This patch somehow mimics fdisk/gdisk behavior and does NOT create stub partition in the gap caused by alignment. Signed-off-by: Mikhail Kshevetskiy --- diff --git a/src/ptgen.c b/src/ptgen.c index cc5e744..37eeac0 100644 --- a/src/ptgen.c +++ b/src/ptgen.c @@ -478,7 +478,8 @@ static int gen_gptable(uint32_t signature, guid_t guid, unsigned nr) printf("%" PRIu64 "\n", (sect - start) * DISK_SECTOR_SIZE); } - if (parts[0].actual_start > GPT_FIRST_ENTRY_SECTOR + GPT_SIZE) { + if ((parts[0].start != 0) && + (parts[0].actual_start > GPT_FIRST_ENTRY_SECTOR + GPT_SIZE)) { gpte[GPT_ENTRY_MAX - 1].start = cpu_to_le64(GPT_FIRST_ENTRY_SECTOR + GPT_SIZE); gpte[GPT_ENTRY_MAX - 1].end = cpu_to_le64(parts[0].actual_start - 1); gpte[GPT_ENTRY_MAX - 1].type = GUID_PARTITION_BIOS_BOOT;