Page MenuHomeFreeBSD

D42245.id128886.diff
No OneTemporary

D42245.id128886.diff

diff --git a/sys/sys/disk/gpt.h b/sys/sys/disk/gpt.h
--- a/sys/sys/disk/gpt.h
+++ b/sys/sys/disk/gpt.h
@@ -82,6 +82,13 @@
CTASSERT(offsetof(struct gpt_hdr, padding) == 92);
#endif
+/*
+ * The GPT standard (section 5.3 of UEFI standard version 2.10) requires
+ * we reserved at least 16k after the PMBR and the GPT header for the gpt
+ * array entries.
+ */
+#define GPT_MIN_RESERVED 16384
+
struct gpt_ent {
gpt_uuid_t ent_type;
gpt_uuid_t ent_uuid;
diff --git a/usr.bin/mkimg/gpt.c b/usr.bin/mkimg/gpt.c
--- a/usr.bin/mkimg/gpt.c
+++ b/usr.bin/mkimg/gpt.c
@@ -129,8 +129,14 @@
{
u_int ents;
+ /*
+ * Round the number of sectors used by the existing partitions up to the
+ * sector size. The GPT standard (see section 5.3 of UEFI standard
+ * version 2.1) requires the reserved space be at last 16k (stated in an
+ * odd way), so enforce that minimum here as well.
+ */
ents = secsz / sizeof(struct gpt_ent);
- return ((nparts + ents - 1) / ents);
+ return (min(GPT_MIN_RESERVED / secsz, (nparts + ents - 1) / ents));
}
static lba_t

File Metadata

Mime Type
text/plain
Expires
Tue, Aug 4, 5:53 AM (14 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35942399
Default Alt Text
D42245.id128886.diff (1 KB)

Event Timeline