Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F151295364
D42245.id128890.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D42245.id128890.diff
View Options
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
@@ -26,6 +26,7 @@
#include <sys/cdefs.h>
#include <sys/errno.h>
+#include <sys/param.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
@@ -129,8 +130,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 (MAX(GPT_MIN_RESERVED / secsz, (nparts + ents - 1) / ents));
}
static lba_t
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Apr 8, 9:44 AM (6 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31092490
Default Alt Text
D42245.id128890.diff (1 KB)
Attached To
Mode
D42245: mkimg: Ensure GPT Entry Array is at least 16k
Attached
Detach File
Event Timeline
Log In to Comment