bootc_lib/
discoverable_partition_specification.rs

1#![allow(dead_code)]
2
3//! Partition type GUIDs from the Discoverable Partitions Specification (DPS)
4//!
5//! This module contains constants for partition type GUIDs as defined by the
6//! UAPI Group's Discoverable Partitions Specification.
7//!
8//! Reference: <https://uapi-group.org/specifications/specs/discoverable_partitions_specification/>
9//!
10//! # Overview
11//!
12//! The Discoverable Partitions Specification (DPS) defines standardized partition
13//! type GUIDs that enable automatic discovery and mounting of partitions without
14//! explicit configuration. This is a key enabler for bootc's installation process
15//! and for modern systemd-based initramfs implementations.
16//!
17//! # How bootc uses DPS
18//!
19//! When `bootc install to-disk` creates partitions, it sets the appropriate DPS
20//! partition type GUID based on the target CPU architecture. This enables several
21//! important capabilities:
22//!
23//! ## Automatic root discovery
24//!
25//! With a DPS-aware bootloader and initramfs (containing `systemd-gpt-auto-generator`),
26//! the root filesystem can be discovered and mounted automatically without requiring
27//! a `root=` kernel argument. The initramfs:
28//!
29//! 1. Reads the EFI `LoaderDevicePartUUID` variable to identify the boot disk
30//! 2. Scans the GPT for a partition with the architecture-specific root type GUID
31//! 3. Mounts that partition as the root filesystem
32//!
33//! ## Architecture-specific partition types
34//!
35//! Each CPU architecture has its own root partition type GUID. This prevents
36//! accidentally booting a system on incompatible hardware. bootc uses
37//! [`this_arch_root`] to select the correct GUID at compile time.
38//!
39//! ## Composefs and sealed boot
40//!
41//! When using the composefs backend with UKIs (Unified Kernel Images), bootc can
42//! omit the `root=` kernel argument entirely. This enables:
43//!
44//! - Measured boot: The kernel command line is part of the UKI signature
45//! - Simplified image building: No machine-specific kernel arguments needed
46//! - systemd-repart integration: Future support for declarative partition management
47//!
48//! # Partition types included
49//!
50//! This module defines constants for:
51//!
52//! - **Root partitions**: Architecture-specific root filesystem partitions
53//! - **USR partitions**: Separate `/usr` partitions (included for spec completeness; not currently used by bootc)
54//! - **Verity partitions**: dm-verity hash partitions for integrity verification
55//! - **Verity signature partitions**: Signed verity root hashes
56//! - **Special partitions**: ESP, XBOOTLDR, swap, home, var, etc.
57//!
58//! # Usage (internal)
59//!
60//! This is an internal module. Within bootc, it is used like:
61//!
62//! ```ignore
63//! use crate::discoverable_partition_specification::{this_arch_root, ESP};
64//!
65//! // Get the root partition type GUID for the current architecture
66//! let root_type: &str = this_arch_root();
67//!
68//! // ESP GUID is architecture-independent
69//! let esp_type: &str = ESP;
70//! ```
71
72// ============================================================================
73// ROOT PARTITIONS
74// ============================================================================
75
76/// Root partition for Alpha architecture
77pub const ROOT_ALPHA: &str = "6523f8ae-3eb1-4e2a-a05a-18b695ae656f";
78
79/// Root partition for ARC architecture
80pub const ROOT_ARC: &str = "d27f46ed-2919-4cb8-bd25-9531f3c16534";
81
82/// Root partition for 32-bit ARM architecture
83pub const ROOT_ARM: &str = "69dad710-2ce4-4e3c-b16c-21a1d49abed3";
84
85/// Root partition for 64-bit ARM/AArch64 architecture
86pub const ROOT_ARM64: &str = "b921b045-1df0-41c3-af44-4c6f280d3fae";
87
88/// Root partition for Itanium/IA-64 architecture
89pub const ROOT_IA64: &str = "993d8d3d-f80e-4225-855a-9daf8ed7ea97";
90
91/// Root partition for 64-bit LoongArch architecture
92pub const ROOT_LOONGARCH64: &str = "77055800-792c-4f94-b39a-98c91b762bb6";
93
94/// Root partition for 32-bit MIPS Little Endian
95pub const ROOT_MIPS_LE: &str = "37c58c8a-d913-4156-a25f-48b1b64e07f0";
96
97/// Root partition for 64-bit MIPS Little Endian
98pub const ROOT_MIPS64_LE: &str = "700bda43-7a34-4507-b179-eeb93d7a7ca3";
99
100/// Root partition for 32-bit MIPS Big Endian
101pub const ROOT_MIPS: &str = "e9434544-6e2c-47cc-bae2-12d6deafb44c";
102
103/// Root partition for 64-bit MIPS Big Endian
104pub const ROOT_MIPS64: &str = "d113af76-80ef-41b4-bdb6-0cff4d3d4a25";
105
106/// Root partition for PA-RISC/HPPA architecture
107pub const ROOT_PARISC: &str = "1aacdb3b-5444-4138-bd9e-e5c2239b2346";
108
109/// Root partition for 32-bit PowerPC
110pub const ROOT_PPC: &str = "1de3f1ef-fa98-47b5-8dcd-4a860a654d78";
111
112/// Root partition for 64-bit PowerPC Big Endian
113pub const ROOT_PPC64: &str = "912ade1d-a839-4913-8964-a10eee08fbd2";
114
115/// Root partition for 64-bit PowerPC Little Endian
116pub const ROOT_PPC64_LE: &str = "c31c45e6-3f39-412e-80fb-4809c4980599";
117
118/// Root partition for 32-bit RISC-V
119pub const ROOT_RISCV32: &str = "60d5a7fe-8e7d-435c-b714-3dd8162144e1";
120
121/// Root partition for 64-bit RISC-V
122pub const ROOT_RISCV64: &str = "72ec70a6-cf74-40e6-bd49-4bda08e8f224";
123
124/// Root partition for s390 architecture
125pub const ROOT_S390: &str = "08a7acea-624c-4a20-91e8-6e0fa67d23f9";
126
127/// Root partition for s390x architecture
128pub const ROOT_S390X: &str = "5eead9a9-fe09-4a1e-a1d7-520d00531306";
129
130/// Root partition for TILE-Gx architecture
131pub const ROOT_TILEGX: &str = "c50cdd70-3862-4cc3-90e1-809a8c93ee2c";
132
133/// Root partition for 32-bit x86
134pub const ROOT_X86: &str = "44479540-f297-41b2-9af7-d131d5f0458a";
135
136/// Root partition for 64-bit x86/AMD64
137pub const ROOT_X86_64: &str = "4f68bce3-e8cd-4db1-96e7-fbcaf984b709";
138
139// ============================================================================
140// USR PARTITIONS
141// ============================================================================
142
143/// /usr partition for Alpha architecture
144pub const USR_ALPHA: &str = "e18cf08c-33ec-4c0d-8246-c6c6fb3da024";
145
146/// /usr partition for ARC architecture
147pub const USR_ARC: &str = "7978a683-6316-4922-bbee-38bff5a2fecc";
148
149/// /usr partition for 32-bit ARM
150pub const USR_ARM: &str = "7d0359a3-02b3-4f0a-865c-654403e70625";
151
152/// /usr partition for 64-bit ARM/AArch64
153pub const USR_ARM64: &str = "b0e01050-ee5f-4390-949a-9101b17104e9";
154
155/// /usr partition for Itanium/IA-64
156pub const USR_IA64: &str = "4301d2a6-4e3b-4b2a-bb94-9e0b2c4225ea";
157
158/// /usr partition for 64-bit LoongArch
159pub const USR_LOONGARCH64: &str = "e611c702-575c-4cbe-9a46-434fa0bf7e3f";
160
161/// /usr partition for 32-bit MIPS Big Endian
162pub const USR_MIPS: &str = "773b2abc-2a99-4398-8bf5-03baac40d02b";
163
164/// /usr partition for 64-bit MIPS Big Endian
165pub const USR_MIPS64: &str = "57e13958-7331-4365-8e6e-35eeee17c61b";
166
167/// /usr partition for 32-bit MIPS Little Endian
168pub const USR_MIPS_LE: &str = "0f4868e9-9952-4706-979f-3ed3a473e947";
169
170/// /usr partition for 64-bit MIPS Little Endian
171pub const USR_MIPS64_LE: &str = "c97c1f32-ba06-40b4-9f22-236061b08aa8";
172
173/// /usr partition for PA-RISC
174pub const USR_PARISC: &str = "dc4a4480-6917-4262-a4ec-db9384949f25";
175
176/// /usr partition for 32-bit PowerPC
177pub const USR_PPC: &str = "7d14fec5-cc71-415d-9d6c-06bf0b3c3eaf";
178
179/// /usr partition for 64-bit PowerPC Big Endian
180pub const USR_PPC64: &str = "2c9739e2-f068-46b3-9fd0-01c5a9afbcca";
181
182/// /usr partition for 64-bit PowerPC Little Endian
183pub const USR_PPC64_LE: &str = "15bb03af-77e7-4d4a-b12b-c0d084f7491c";
184
185/// /usr partition for 32-bit RISC-V
186pub const USR_RISCV32: &str = "b933fb22-5c3f-4f91-af90-e2bb0fa50702";
187
188/// /usr partition for 64-bit RISC-V
189pub const USR_RISCV64: &str = "beaec34b-8442-439b-a40b-984381ed097d";
190
191/// /usr partition for s390
192pub const USR_S390: &str = "cd0f869b-d0fb-4ca0-b141-9ea87cc78d66";
193
194/// /usr partition for s390x
195pub const USR_S390X: &str = "8a4f5770-50aa-4ed3-874a-99b710db6fea";
196
197/// /usr partition for TILE-Gx
198pub const USR_TILEGX: &str = "55497029-c7c1-44cc-aa39-815ed1558630";
199
200/// /usr partition for 32-bit x86
201pub const USR_X86: &str = "75250d76-8cc6-458e-bd66-bd47cc81a812";
202
203/// /usr partition for 64-bit x86/AMD64
204pub const USR_X86_64: &str = "8484680c-9521-48c6-9c11-b0720656f69e";
205
206// ============================================================================
207// ROOT VERITY PARTITIONS
208// ============================================================================
209
210/// Root verity partition for Alpha
211pub const ROOT_VERITY_ALPHA: &str = "fc56d9e9-e6e5-4c06-be32-e74407ce09a5";
212
213/// Root verity partition for ARC
214pub const ROOT_VERITY_ARC: &str = "24b2d975-0f97-4521-afa1-cd531e421b8d";
215
216/// Root verity partition for 32-bit ARM
217pub const ROOT_VERITY_ARM: &str = "7386cdf2-203c-47a9-a498-f2ecce45a2d6";
218
219/// Root verity partition for 64-bit ARM/AArch64
220pub const ROOT_VERITY_ARM64: &str = "df3300ce-d69f-4c92-978c-9bfb0f38d820";
221
222/// Root verity partition for Itanium/IA-64
223pub const ROOT_VERITY_IA64: &str = "86ed10d5-b607-45bb-8957-d350f23d0571";
224
225/// Root verity partition for 64-bit LoongArch
226pub const ROOT_VERITY_LOONGARCH64: &str = "f3393b22-e9af-4613-a948-9d3bfbd0c535";
227
228/// Root verity partition for 32-bit MIPS Big Endian
229pub const ROOT_VERITY_MIPS: &str = "7a430799-f711-4c7e-8e5b-1d685bd48607";
230
231/// Root verity partition for 64-bit MIPS Big Endian
232pub const ROOT_VERITY_MIPS64: &str = "579536f8-6a33-4055-a95a-df2d5e2c42a8";
233
234/// Root verity partition for 32-bit MIPS Little Endian
235pub const ROOT_VERITY_MIPS_LE: &str = "d7d150d2-2a04-4a33-8f12-16651205ff7b";
236
237/// Root verity partition for 64-bit MIPS Little Endian
238pub const ROOT_VERITY_MIPS64_LE: &str = "16b417f8-3e06-4f57-8dd2-9b5232f41aa6";
239
240/// Root verity partition for PA-RISC
241pub const ROOT_VERITY_PARISC: &str = "d212a430-fbc5-49f9-a983-a7feef2b8d0e";
242
243/// Root verity partition for 32-bit PowerPC
244pub const ROOT_VERITY_PPC: &str = "98cfe649-1588-46dc-b2f0-add147424925";
245
246/// Root verity partition for 64-bit PowerPC Big Endian
247pub const ROOT_VERITY_PPC64: &str = "9225a9a3-3c19-4d89-b4f6-eeff88f17631";
248
249/// Root verity partition for 64-bit PowerPC Little Endian
250pub const ROOT_VERITY_PPC64_LE: &str = "906bd944-4589-4aae-a4e4-dd983917446a";
251
252/// Root verity partition for 32-bit RISC-V
253pub const ROOT_VERITY_RISCV32: &str = "ae0253be-1167-4007-ac68-43926c14c5de";
254
255/// Root verity partition for 64-bit RISC-V
256pub const ROOT_VERITY_RISCV64: &str = "b6ed5582-440b-4209-b8da-5ff7c419ea3d";
257
258/// Root verity partition for s390
259pub const ROOT_VERITY_S390: &str = "7ac63b47-b25c-463b-8df8-b4a94e6c90e1";
260
261/// Root verity partition for s390x
262pub const ROOT_VERITY_S390X: &str = "b325bfbe-c7be-4ab8-8357-139e652d2f6b";
263
264/// Root verity partition for TILE-Gx
265pub const ROOT_VERITY_TILEGX: &str = "966061ec-28e4-4b2e-b4a5-1f0a825a1d84";
266
267/// Root verity partition for 32-bit x86
268pub const ROOT_VERITY_X86: &str = "d13c5d3b-b5d1-422a-b29f-9454fdc89d76";
269
270/// Root verity partition for 64-bit x86/AMD64
271pub const ROOT_VERITY_X86_64: &str = "2c7357ed-ebd2-46d9-aec1-23d437ec2bf5";
272
273// ============================================================================
274// USR VERITY PARTITIONS
275// ============================================================================
276
277/// /usr verity partition for Alpha
278pub const USR_VERITY_ALPHA: &str = "8cce0d25-c0d0-4a44-bd87-46331bf1df67";
279
280/// /usr verity partition for ARC
281pub const USR_VERITY_ARC: &str = "fca0598c-d880-4591-8c16-4eda05c7347c";
282
283/// /usr verity partition for 32-bit ARM
284pub const USR_VERITY_ARM: &str = "c215d751-7bcd-4649-be90-6627490a4c05";
285
286/// /usr verity partition for 64-bit ARM/AArch64
287pub const USR_VERITY_ARM64: &str = "6e11a4e7-fbca-4ded-b9e9-e1a512bb664e";
288
289/// /usr verity partition for Itanium/IA-64
290pub const USR_VERITY_IA64: &str = "6a491e03-3be7-4545-8e38-83320e0ea880";
291
292/// /usr verity partition for 64-bit LoongArch
293pub const USR_VERITY_LOONGARCH64: &str = "f46b2c26-59ae-48f0-9106-c50ed47f673d";
294
295/// /usr verity partition for 32-bit MIPS Big Endian
296pub const USR_VERITY_MIPS: &str = "6e5a1bc8-d223-49b7-bca8-37a5fcceb996";
297
298/// /usr verity partition for 64-bit MIPS Big Endian
299pub const USR_VERITY_MIPS64: &str = "81cf9d90-7458-4df4-8dcf-c8a3a404f09b";
300
301/// /usr verity partition for 32-bit MIPS Little Endian
302pub const USR_VERITY_MIPS_LE: &str = "46b98d8d-b55c-4e8f-aab3-37fca7f80752";
303
304/// /usr verity partition for 64-bit MIPS Little Endian
305pub const USR_VERITY_MIPS64_LE: &str = "3c3d61fe-b5f3-414d-bb71-8739a694a4ef";
306
307/// /usr verity partition for PA-RISC
308pub const USR_VERITY_PARISC: &str = "5843d618-ec37-48d7-9f12-cea8e08768b2";
309
310/// /usr verity partition for 32-bit PowerPC
311pub const USR_VERITY_PPC: &str = "df765d00-270e-49e5-bc75-f47bb2118b09";
312
313/// /usr verity partition for 64-bit PowerPC Big Endian
314pub const USR_VERITY_PPC64: &str = "bdb528a5-a259-475f-a87d-da53fa736a07";
315
316/// /usr verity partition for 64-bit PowerPC Little Endian
317pub const USR_VERITY_PPC64_LE: &str = "ee2b9983-21e8-4153-86d9-b6901a54d1ce";
318
319/// /usr verity partition for 32-bit RISC-V
320pub const USR_VERITY_RISCV32: &str = "cb1ee4e3-8cd0-4136-a0a4-aa61a32e8730";
321
322/// /usr verity partition for 64-bit RISC-V
323pub const USR_VERITY_RISCV64: &str = "8f1056be-9b05-47c4-81d6-be53128e5b54";
324
325/// /usr verity partition for s390
326pub const USR_VERITY_S390: &str = "b663c618-e7bc-4d6d-90aa-11b756bb1797";
327
328/// /usr verity partition for s390x
329pub const USR_VERITY_S390X: &str = "31741cc4-1a2a-4111-a581-e00b447d2d06";
330
331/// /usr verity partition for TILE-Gx
332pub const USR_VERITY_TILEGX: &str = "2fb4bf56-07fa-42da-8132-6b139f2026ae";
333
334/// /usr verity partition for 32-bit x86
335pub const USR_VERITY_X86: &str = "8f461b0d-14ee-4e81-9aa9-049b6fb97abd";
336
337/// /usr verity partition for 64-bit x86/AMD64
338pub const USR_VERITY_X86_64: &str = "77ff5f63-e7b6-4633-acf4-1565b864c0e6";
339
340// ============================================================================
341// ROOT VERITY SIGNATURE PARTITIONS
342// ============================================================================
343
344/// Root verity signature partition for Alpha
345pub const ROOT_VERITY_SIG_ALPHA: &str = "d46495b7-a053-414f-80f7-700c99921ef8";
346
347/// Root verity signature partition for ARC
348pub const ROOT_VERITY_SIG_ARC: &str = "143a70ba-cbd3-4f06-919f-6c05683a78bc";
349
350/// Root verity signature partition for 32-bit ARM
351pub const ROOT_VERITY_SIG_ARM: &str = "42b0455f-eb11-491d-98d3-56145ba9d037";
352
353/// Root verity signature partition for 64-bit ARM/AArch64
354pub const ROOT_VERITY_SIG_ARM64: &str = "6db69de6-29f4-4758-a7a5-962190f00ce3";
355
356/// Root verity signature partition for Itanium/IA-64
357pub const ROOT_VERITY_SIG_IA64: &str = "e98b36ee-32ba-4882-9b12-0ce14655f46a";
358
359/// Root verity signature partition for 64-bit LoongArch
360pub const ROOT_VERITY_SIG_LOONGARCH64: &str = "5afb67eb-ecc8-4f85-ae8e-ac1e7c50e7d0";
361
362/// Root verity signature partition for 32-bit MIPS Big Endian
363pub const ROOT_VERITY_SIG_MIPS: &str = "bba210a2-9c5d-45ee-9e87-ff2ccbd002d0";
364
365/// Root verity signature partition for 64-bit MIPS Big Endian
366pub const ROOT_VERITY_SIG_MIPS64: &str = "43ce94d4-0f3d-4999-8250-b9deafd98e6e";
367
368/// Root verity signature partition for 32-bit MIPS Little Endian
369pub const ROOT_VERITY_SIG_MIPS_LE: &str = "c919cc1f-4456-4eff-918c-f75e94525ca5";
370
371/// Root verity signature partition for 64-bit MIPS Little Endian
372pub const ROOT_VERITY_SIG_MIPS64_LE: &str = "904e58ef-5c65-4a31-9c57-6af5fc7c5de7";
373
374/// Root verity signature partition for PA-RISC
375pub const ROOT_VERITY_SIG_PARISC: &str = "15de6170-65d3-431c-916e-b0dcd8393f25";
376
377/// Root verity signature partition for 32-bit PowerPC
378pub const ROOT_VERITY_SIG_PPC: &str = "1b31b5aa-add9-463a-b2ed-bd467fc857e7";
379
380/// Root verity signature partition for 64-bit PowerPC Big Endian
381pub const ROOT_VERITY_SIG_PPC64: &str = "f5e2c20c-45b2-4ffa-bce9-2a60737e1aaf";
382
383/// Root verity signature partition for 64-bit PowerPC Little Endian
384pub const ROOT_VERITY_SIG_PPC64_LE: &str = "d4a236e7-e873-4c07-bf1d-bf6cf7f1c3c6";
385
386/// Root verity signature partition for 32-bit RISC-V
387pub const ROOT_VERITY_SIG_RISCV32: &str = "3a112a75-8729-4380-b4cf-764d79934448";
388
389/// Root verity signature partition for 64-bit RISC-V
390pub const ROOT_VERITY_SIG_RISCV64: &str = "efe0f087-ea8d-4469-821a-4c2a96a8386a";
391
392/// Root verity signature partition for s390
393pub const ROOT_VERITY_SIG_S390: &str = "3482388e-4254-435a-a241-766a065f9960";
394
395/// Root verity signature partition for s390x
396pub const ROOT_VERITY_SIG_S390X: &str = "c80187a5-73a3-491a-901a-017c3fa953e9";
397
398/// Root verity signature partition for TILE-Gx
399pub const ROOT_VERITY_SIG_TILEGX: &str = "b3671439-97b0-4a53-90f7-2d5a8f3ad47b";
400
401/// Root verity signature partition for 32-bit x86
402pub const ROOT_VERITY_SIG_X86: &str = "5996fc05-109c-48de-808b-23fa0830b676";
403
404/// Root verity signature partition for 64-bit x86/AMD64
405pub const ROOT_VERITY_SIG_X86_64: &str = "41092b05-9fc8-4523-994f-2def0408b176";
406
407// ============================================================================
408// USR VERITY SIGNATURE PARTITIONS
409// ============================================================================
410
411/// /usr verity signature partition for Alpha
412pub const USR_VERITY_SIG_ALPHA: &str = "5c6e1c76-076a-457a-a0fe-f3b4cd21ce6e";
413
414/// /usr verity signature partition for ARC
415pub const USR_VERITY_SIG_ARC: &str = "94f9a9a1-9971-427a-a400-50cb297f0f35";
416
417/// /usr verity signature partition for 32-bit ARM
418pub const USR_VERITY_SIG_ARM: &str = "d7ff812f-37d1-4902-a810-d76ba57b975a";
419
420/// /usr verity signature partition for 64-bit ARM/AArch64
421pub const USR_VERITY_SIG_ARM64: &str = "c23ce4ff-44bd-4b00-b2d4-b41b3419e02a";
422
423/// /usr verity signature partition for Itanium/IA-64
424pub const USR_VERITY_SIG_IA64: &str = "8de58bc2-2a43-460d-b14e-a76e4a17b47f";
425
426/// /usr verity signature partition for 64-bit LoongArch
427pub const USR_VERITY_SIG_LOONGARCH64: &str = "b024f315-d330-444c-8461-44bbde524e99";
428
429/// /usr verity signature partition for 32-bit MIPS Big Endian
430pub const USR_VERITY_SIG_MIPS: &str = "97ae158d-f216-497b-8057-f7f905770f54";
431
432/// /usr verity signature partition for 64-bit MIPS Big Endian
433pub const USR_VERITY_SIG_MIPS64: &str = "05816ce2-dd40-4ac6-a61d-37d32dc1ba7d";
434
435/// /usr verity signature partition for 32-bit MIPS Little Endian
436pub const USR_VERITY_SIG_MIPS_LE: &str = "3e23ca0b-a4bc-4b4e-8087-5ab6a26aa8a9";
437
438/// /usr verity signature partition for 64-bit MIPS Little Endian
439pub const USR_VERITY_SIG_MIPS64_LE: &str = "f2c2c7ee-adcc-4351-b5c6-ee9816b66e16";
440
441/// /usr verity signature partition for PA-RISC
442pub const USR_VERITY_SIG_PARISC: &str = "450dd7d1-3224-45ec-9cf2-a43a346d71ee";
443
444/// /usr verity signature partition for 32-bit PowerPC
445pub const USR_VERITY_SIG_PPC: &str = "7007891d-d371-4a80-86a4-5cb875b9302e";
446
447/// /usr verity signature partition for 64-bit PowerPC Big Endian
448pub const USR_VERITY_SIG_PPC64: &str = "0b888863-d7f8-4d9e-9766-239fce4d58af";
449
450/// /usr verity signature partition for 64-bit PowerPC Little Endian
451pub const USR_VERITY_SIG_PPC64_LE: &str = "c8bfbd1e-268e-4521-8bba-bf314c399557";
452
453/// /usr verity signature partition for 32-bit RISC-V
454pub const USR_VERITY_SIG_RISCV32: &str = "c3836a13-3137-45ba-b583-b16c50fe5eb4";
455
456/// /usr verity signature partition for 64-bit RISC-V
457pub const USR_VERITY_SIG_RISCV64: &str = "d2f9000a-7a18-453f-b5cd-4d32f77a7b32";
458
459/// /usr verity signature partition for s390
460pub const USR_VERITY_SIG_S390: &str = "17440e4f-a8d0-467f-a46e-3912ae6ef2c5";
461
462/// /usr verity signature partition for s390x
463pub const USR_VERITY_SIG_S390X: &str = "3f324816-667b-46ae-86ee-9b0c0c6c11b4";
464
465/// /usr verity signature partition for TILE-Gx
466pub const USR_VERITY_SIG_TILEGX: &str = "4ede75e2-6ccc-4cc8-b9c7-70334b087510";
467
468/// /usr verity signature partition for 32-bit x86
469pub const USR_VERITY_SIG_X86: &str = "974a71c0-de41-43c3-be5d-5c5ccd1ad2c0";
470
471/// /usr verity signature partition for 64-bit x86/AMD64
472pub const USR_VERITY_SIG_X86_64: &str = "e7bb33fb-06cf-4e81-8273-e543b413e2e2";
473
474// ============================================================================
475// OTHER SPECIAL PARTITION TYPES
476// ============================================================================
477
478/// EFI System Partition (ESP) for UEFI boot
479pub const ESP: &str = "c12a7328-f81f-11d2-ba4b-00a0c93ec93b";
480
481/// Extended Boot Loader Partition
482pub const XBOOTLDR: &str = "bc13c2ff-59e6-4262-a352-b275fd6f7172";
483
484/// Swap partition
485pub const SWAP: &str = "0657fd6d-a4ab-43c4-84e5-0933c84b4f4f";
486
487/// Home partition (/home)
488pub const HOME: &str = "933ac7e1-2eb4-4f13-b844-0e14e2aef915";
489
490/// Server data partition (/srv)
491pub const SRV: &str = "3b8f8425-20e0-4f3b-907f-1a25a76f98e8";
492
493/// Variable data partition (/var)
494pub const VAR: &str = "4d21b016-b534-45c2-a9fb-5c16e091fd2d";
495
496/// Temporary data partition (/var/tmp)
497pub const TMP: &str = "7ec6f557-3bc5-4aca-b293-16ef5df639d1";
498
499/// Generic Linux filesystem data partition
500pub const LINUX_DATA: &str = "0fc63daf-8483-4772-8e79-3d69d8477de4";
501
502// ============================================================================
503// ARCHITECTURE-SPECIFIC HELPERS
504// ============================================================================
505
506/// Returns the root partition GUID for the current architecture.
507///
508/// This is a compile-time constant function that selects the appropriate
509/// root partition type GUID based on the target architecture and endianness.
510pub const fn this_arch_root() -> &'static str {
511    cfg_if::cfg_if! {
512        if #[cfg(target_arch = "x86_64")] {
513            ROOT_X86_64
514        } else if #[cfg(target_arch = "arm")] {
515            ROOT_ARM
516        } else if #[cfg(target_arch = "aarch64")] {
517            ROOT_ARM64
518        } else if #[cfg(target_arch = "s390x")] {
519            ROOT_S390X
520        } else if #[cfg(all(target_arch = "powerpc64", target_endian = "big"))] {
521            ROOT_PPC64
522        } else if #[cfg(all(target_arch = "powerpc64", target_endian = "little"))] {
523            ROOT_PPC64_LE
524        } else {
525            compile_error!("Unsupported architecture")
526        }
527    }
528}
529
530#[cfg(test)]
531mod test {
532    use super::*;
533
534    #[test]
535    #[ignore = "Only run manually to validate against upstream spec"]
536    fn test_uuids_against_spec() {
537        // This test validates our partition type UUIDs against the upstream
538        // Discoverable Partitions Specification. The spec is committed to the
539        // repo at fixtures/discoverable_partitions_specification.md
540        //
541        // Spec source: https://github.com/uapi-group/specifications/blob/6f3a5dd31009456561eaa9f6fcfe7769ab97eb50/specs/discoverable_partitions_specification.md
542
543        let spec_content = include_str!("fixtures/discoverable_partitions_specification.md");
544
545        // Parse the markdown tables and extract partition name -> UUID mappings
546        let mut spec_uuids: std::collections::HashMap<&str, &str> =
547            std::collections::HashMap::new();
548
549        // Regex to match table rows with partition type UUIDs
550        // Format: | _Name_ | `uuid` ... | ... | ... |
551        let re = regex::Regex::new(
552            r"(?m)^\|\s*_(.+?)_\s*\|\s*`([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})`"
553        )
554        .unwrap();
555
556        for cap in re.captures_iter(&spec_content) {
557            let name = cap.get(1).unwrap().as_str();
558            let uuid = cap.get(2).unwrap().as_str();
559            spec_uuids.insert(name, uuid);
560        }
561
562        // Verify we parsed a reasonable number of entries
563        assert!(
564            spec_uuids.len() > 100,
565            "Expected to parse over 100 UUIDs, got {}",
566            spec_uuids.len()
567        );
568
569        // Now cross-reference our constants against the spec
570        macro_rules! check_uuid {
571            ($name:expr, $const_val:expr) => {
572                if let Some(&spec_uuid) = spec_uuids.get($name) {
573                    assert_eq!(
574                        $const_val, spec_uuid,
575                        "UUID mismatch for {}: our value '{}' != spec value '{}'",
576                        $name, $const_val, spec_uuid
577                    );
578                } else {
579                    panic!("No spec entry found for {}", $name);
580                }
581            };
582        }
583
584        // Root Partitions
585        check_uuid!("Root Partition (Alpha)", ROOT_ALPHA);
586        check_uuid!("Root Partition (ARC)", ROOT_ARC);
587        check_uuid!("Root Partition (32-bit ARM)", ROOT_ARM);
588        check_uuid!("Root Partition (64-bit ARM/AArch64)", ROOT_ARM64);
589        check_uuid!("Root Partition (Itanium/IA-64)", ROOT_IA64);
590        check_uuid!("Root Partition (LoongArch 64-bit)", ROOT_LOONGARCH64);
591        check_uuid!(
592            "Root Partition (32-bit MIPS LittleEndian (mipsel))",
593            ROOT_MIPS_LE
594        );
595        check_uuid!(
596            "Root Partition (64-bit MIPS LittleEndian (mips64el))",
597            ROOT_MIPS64_LE
598        );
599        check_uuid!("Root Partition (32-bit MIPS BigEndian (mips))", ROOT_MIPS);
600        check_uuid!(
601            "Root Partition (64-bit MIPS BigEndian (mips64))",
602            ROOT_MIPS64
603        );
604        check_uuid!("Root Partition (HPPA/PARISC)", ROOT_PARISC);
605        check_uuid!("Root Partition (32-bit PowerPC)", ROOT_PPC);
606        check_uuid!("Root Partition (64-bit PowerPC BigEndian)", ROOT_PPC64);
607        check_uuid!(
608            "Root Partition (64-bit PowerPC LittleEndian)",
609            ROOT_PPC64_LE
610        );
611        check_uuid!("Root Partition (RISC-V 32-bit)", ROOT_RISCV32);
612        check_uuid!("Root Partition (RISC-V 64-bit)", ROOT_RISCV64);
613        check_uuid!("Root Partition (s390)", ROOT_S390);
614        check_uuid!("Root Partition (s390x)", ROOT_S390X);
615        check_uuid!("Root Partition (TILE-Gx)", ROOT_TILEGX);
616        check_uuid!("Root Partition (x86)", ROOT_X86);
617        check_uuid!("Root Partition (amd64/x86_64)", ROOT_X86_64);
618
619        // USR Partitions
620        check_uuid!("`/usr/` Partition (Alpha)", USR_ALPHA);
621        check_uuid!("`/usr/` Partition (ARC)", USR_ARC);
622        check_uuid!("`/usr/` Partition (32-bit ARM)", USR_ARM);
623        check_uuid!("`/usr/` Partition (64-bit ARM/AArch64)", USR_ARM64);
624        check_uuid!("`/usr/` Partition (Itanium/IA-64)", USR_IA64);
625        check_uuid!("`/usr/` Partition (LoongArch 64-bit)", USR_LOONGARCH64);
626        check_uuid!("`/usr/` Partition (32-bit MIPS BigEndian (mips))", USR_MIPS);
627        check_uuid!(
628            "`/usr/` Partition (64-bit MIPS BigEndian (mips64))",
629            USR_MIPS64
630        );
631        check_uuid!(
632            "`/usr/` Partition (32-bit MIPS LittleEndian (mipsel))",
633            USR_MIPS_LE
634        );
635        check_uuid!(
636            "`/usr/` Partition (64-bit MIPS LittleEndian (mips64el))",
637            USR_MIPS64_LE
638        );
639        check_uuid!("`/usr/` Partition (HPPA/PARISC)", USR_PARISC);
640        check_uuid!("`/usr/` Partition (32-bit PowerPC)", USR_PPC);
641        check_uuid!("`/usr/` Partition (64-bit PowerPC BigEndian)", USR_PPC64);
642        check_uuid!(
643            "`/usr/` Partition (64-bit PowerPC LittleEndian)",
644            USR_PPC64_LE
645        );
646        check_uuid!("`/usr/` Partition (RISC-V 32-bit)", USR_RISCV32);
647        check_uuid!("`/usr/` Partition (RISC-V 64-bit)", USR_RISCV64);
648        check_uuid!("`/usr/` Partition (s390)", USR_S390);
649        check_uuid!("`/usr/` Partition (s390x)", USR_S390X);
650        check_uuid!("`/usr/` Partition (TILE-Gx)", USR_TILEGX);
651        check_uuid!("`/usr/` Partition (x86)", USR_X86);
652        check_uuid!("`/usr/` Partition (amd64/x86_64)", USR_X86_64);
653
654        // Root Verity Partitions
655        check_uuid!("Root Verity Partition (Alpha)", ROOT_VERITY_ALPHA);
656        check_uuid!("Root Verity Partition (ARC)", ROOT_VERITY_ARC);
657        check_uuid!("Root Verity Partition (32-bit ARM)", ROOT_VERITY_ARM);
658        check_uuid!(
659            "Root Verity Partition (64-bit ARM/AArch64)",
660            ROOT_VERITY_ARM64
661        );
662        check_uuid!("Root Verity Partition (Itanium/IA-64)", ROOT_VERITY_IA64);
663        check_uuid!(
664            "Root Verity Partition (LoongArch 64-bit)",
665            ROOT_VERITY_LOONGARCH64
666        );
667        check_uuid!(
668            "Root Verity Partition (32-bit MIPS BigEndian (mips))",
669            ROOT_VERITY_MIPS
670        );
671        check_uuid!(
672            "Root Verity Partition (64-bit MIPS BigEndian (mips64))",
673            ROOT_VERITY_MIPS64
674        );
675        check_uuid!(
676            "Root Verity Partition (32-bit MIPS LittleEndian (mipsel))",
677            ROOT_VERITY_MIPS_LE
678        );
679        check_uuid!(
680            "Root Verity Partition (64-bit MIPS LittleEndian (mips64el))",
681            ROOT_VERITY_MIPS64_LE
682        );
683        check_uuid!("Root Verity Partition (HPPA/PARISC)", ROOT_VERITY_PARISC);
684        check_uuid!("Root Verity Partition (32-bit PowerPC)", ROOT_VERITY_PPC);
685        check_uuid!(
686            "Root Verity Partition (64-bit PowerPC BigEndian)",
687            ROOT_VERITY_PPC64
688        );
689        check_uuid!(
690            "Root Verity Partition (64-bit PowerPC LittleEndian)",
691            ROOT_VERITY_PPC64_LE
692        );
693        check_uuid!("Root Verity Partition (RISC-V 32-bit)", ROOT_VERITY_RISCV32);
694        check_uuid!("Root Verity Partition (RISC-V 64-bit)", ROOT_VERITY_RISCV64);
695        check_uuid!("Root Verity Partition (s390)", ROOT_VERITY_S390);
696        check_uuid!("Root Verity Partition (s390x)", ROOT_VERITY_S390X);
697        check_uuid!("Root Verity Partition (TILE-Gx)", ROOT_VERITY_TILEGX);
698        check_uuid!("Root Verity Partition (x86)", ROOT_VERITY_X86);
699        check_uuid!("Root Verity Partition (amd64/x86_64)", ROOT_VERITY_X86_64);
700
701        // USR Verity Partitions
702        check_uuid!("`/usr/` Verity Partition (Alpha)", USR_VERITY_ALPHA);
703        check_uuid!("`/usr/` Verity Partition (ARC)", USR_VERITY_ARC);
704        check_uuid!("`/usr/` Verity Partition (32-bit ARM)", USR_VERITY_ARM);
705        check_uuid!(
706            "`/usr/` Verity Partition (64-bit ARM/AArch64)",
707            USR_VERITY_ARM64
708        );
709        check_uuid!("`/usr/` Verity Partition (Itanium/IA-64)", USR_VERITY_IA64);
710        check_uuid!(
711            "`/usr/` Verity Partition (LoongArch 64-bit)",
712            USR_VERITY_LOONGARCH64
713        );
714        check_uuid!(
715            "`/usr/` Verity Partition (32-bit MIPS BigEndian (mips))",
716            USR_VERITY_MIPS
717        );
718        check_uuid!(
719            "`/usr/` Verity Partition (64-bit MIPS BigEndian (mips64))",
720            USR_VERITY_MIPS64
721        );
722        check_uuid!(
723            "`/usr/` Verity Partition (32-bit MIPS LittleEndian (mipsel))",
724            USR_VERITY_MIPS_LE
725        );
726        check_uuid!(
727            "`/usr/` Verity Partition (64-bit MIPS LittleEndian (mips64el))",
728            USR_VERITY_MIPS64_LE
729        );
730        check_uuid!("`/usr/` Verity Partition (HPPA/PARISC)", USR_VERITY_PARISC);
731        check_uuid!("`/usr/` Verity Partition (32-bit PowerPC)", USR_VERITY_PPC);
732        check_uuid!(
733            "`/usr/` Verity Partition (64-bit PowerPC BigEndian)",
734            USR_VERITY_PPC64
735        );
736        check_uuid!(
737            "`/usr/` Verity Partition (64-bit PowerPC LittleEndian)",
738            USR_VERITY_PPC64_LE
739        );
740        check_uuid!(
741            "`/usr/` Verity Partition (RISC-V 32-bit)",
742            USR_VERITY_RISCV32
743        );
744        check_uuid!(
745            "`/usr/` Verity Partition (RISC-V 64-bit)",
746            USR_VERITY_RISCV64
747        );
748        check_uuid!("`/usr/` Verity Partition (s390)", USR_VERITY_S390);
749        check_uuid!("`/usr/` Verity Partition (s390x)", USR_VERITY_S390X);
750        check_uuid!("`/usr/` Verity Partition (TILE-Gx)", USR_VERITY_TILEGX);
751        check_uuid!("`/usr/` Verity Partition (x86)", USR_VERITY_X86);
752        check_uuid!("`/usr/` Verity Partition (amd64/x86_64)", USR_VERITY_X86_64);
753
754        // Root Verity Signature Partitions
755        check_uuid!(
756            "Root Verity Signature Partition (Alpha)",
757            ROOT_VERITY_SIG_ALPHA
758        );
759        check_uuid!("Root Verity Signature Partition (ARC)", ROOT_VERITY_SIG_ARC);
760        check_uuid!(
761            "Root Verity Signature Partition (32-bit ARM)",
762            ROOT_VERITY_SIG_ARM
763        );
764        check_uuid!(
765            "Root Verity Signature Partition (64-bit ARM/AArch64)",
766            ROOT_VERITY_SIG_ARM64
767        );
768        check_uuid!(
769            "Root Verity Signature Partition (Itanium/IA-64)",
770            ROOT_VERITY_SIG_IA64
771        );
772        check_uuid!(
773            "Root Verity Signature Partition (LoongArch 64-bit)",
774            ROOT_VERITY_SIG_LOONGARCH64
775        );
776        check_uuid!(
777            "Root Verity Signature Partition (32-bit MIPS BigEndian (mips))",
778            ROOT_VERITY_SIG_MIPS
779        );
780        check_uuid!(
781            "Root Verity Signature Partition (64-bit MIPS BigEndian (mips64))",
782            ROOT_VERITY_SIG_MIPS64
783        );
784        check_uuid!(
785            "Root Verity Signature Partition (32-bit MIPS LittleEndian (mipsel))",
786            ROOT_VERITY_SIG_MIPS_LE
787        );
788        check_uuid!(
789            "Root Verity Signature Partition (64-bit MIPS LittleEndian (mips64el))",
790            ROOT_VERITY_SIG_MIPS64_LE
791        );
792        check_uuid!(
793            "Root Verity Signature Partition (HPPA/PARISC)",
794            ROOT_VERITY_SIG_PARISC
795        );
796        check_uuid!(
797            "Root Verity Signature Partition (32-bit PowerPC)",
798            ROOT_VERITY_SIG_PPC
799        );
800        check_uuid!(
801            "Root Verity Signature Partition (64-bit PowerPC BigEndian)",
802            ROOT_VERITY_SIG_PPC64
803        );
804        check_uuid!(
805            "Root Verity Signature Partition (64-bit PowerPC LittleEndian)",
806            ROOT_VERITY_SIG_PPC64_LE
807        );
808        check_uuid!(
809            "Root Verity Signature Partition (RISC-V 32-bit)",
810            ROOT_VERITY_SIG_RISCV32
811        );
812        check_uuid!(
813            "Root Verity Signature Partition (RISC-V 64-bit)",
814            ROOT_VERITY_SIG_RISCV64
815        );
816        check_uuid!(
817            "Root Verity Signature Partition (s390)",
818            ROOT_VERITY_SIG_S390
819        );
820        check_uuid!(
821            "Root Verity Signature Partition (s390x)",
822            ROOT_VERITY_SIG_S390X
823        );
824        check_uuid!(
825            "Root Verity Signature Partition (TILE-Gx)",
826            ROOT_VERITY_SIG_TILEGX
827        );
828        check_uuid!("Root Verity Signature Partition (x86)", ROOT_VERITY_SIG_X86);
829        check_uuid!(
830            "Root Verity Signature Partition (amd64/x86_64)",
831            ROOT_VERITY_SIG_X86_64
832        );
833
834        // USR Verity Signature Partitions
835        check_uuid!(
836            "`/usr/` Verity Signature Partition (Alpha)",
837            USR_VERITY_SIG_ALPHA
838        );
839        check_uuid!(
840            "`/usr/` Verity Signature Partition (ARC)",
841            USR_VERITY_SIG_ARC
842        );
843        check_uuid!(
844            "`/usr/` Verity Signature Partition (32-bit ARM)",
845            USR_VERITY_SIG_ARM
846        );
847        check_uuid!(
848            "`/usr/` Verity Signature Partition (64-bit ARM/AArch64)",
849            USR_VERITY_SIG_ARM64
850        );
851        check_uuid!(
852            "`/usr/` Verity Signature Partition (Itanium/IA-64)",
853            USR_VERITY_SIG_IA64
854        );
855        check_uuid!(
856            "`/usr/` Verity Signature Partition (LoongArch 64-bit)",
857            USR_VERITY_SIG_LOONGARCH64
858        );
859        check_uuid!(
860            "`/usr/` Verity Signature Partition (32-bit MIPS BigEndian (mips))",
861            USR_VERITY_SIG_MIPS
862        );
863        check_uuid!(
864            "`/usr/` Verity Signature Partition (64-bit MIPS BigEndian (mips64))",
865            USR_VERITY_SIG_MIPS64
866        );
867        check_uuid!(
868            "`/usr/` Verity Signature Partition (32-bit MIPS LittleEndian (mipsel))",
869            USR_VERITY_SIG_MIPS_LE
870        );
871        check_uuid!(
872            "`/usr/` Verity Signature Partition (64-bit MIPS LittleEndian (mips64el))",
873            USR_VERITY_SIG_MIPS64_LE
874        );
875        check_uuid!(
876            "`/usr/` Verity Signature Partition (HPPA/PARISC)",
877            USR_VERITY_SIG_PARISC
878        );
879        check_uuid!(
880            "`/usr/` Verity Signature Partition (32-bit PowerPC)",
881            USR_VERITY_SIG_PPC
882        );
883        check_uuid!(
884            "`/usr/` Verity Signature Partition (64-bit PowerPC BigEndian)",
885            USR_VERITY_SIG_PPC64
886        );
887        check_uuid!(
888            "`/usr/` Verity Signature Partition (64-bit PowerPC LittleEndian)",
889            USR_VERITY_SIG_PPC64_LE
890        );
891        check_uuid!(
892            "`/usr/` Verity Signature Partition (RISC-V 32-bit)",
893            USR_VERITY_SIG_RISCV32
894        );
895        check_uuid!(
896            "`/usr/` Verity Signature Partition (RISC-V 64-bit)",
897            USR_VERITY_SIG_RISCV64
898        );
899        check_uuid!(
900            "`/usr/` Verity Signature Partition (s390)",
901            USR_VERITY_SIG_S390
902        );
903        check_uuid!(
904            "`/usr/` Verity Signature Partition (s390x)",
905            USR_VERITY_SIG_S390X
906        );
907        check_uuid!(
908            "`/usr/` Verity Signature Partition (TILE-Gx)",
909            USR_VERITY_SIG_TILEGX
910        );
911        check_uuid!(
912            "`/usr/` Verity Signature Partition (x86)",
913            USR_VERITY_SIG_X86
914        );
915        check_uuid!(
916            "`/usr/` Verity Signature Partition (amd64/x86_64)",
917            USR_VERITY_SIG_X86_64
918        );
919
920        // Other special partition types
921        check_uuid!("EFI System Partition", ESP);
922        check_uuid!("Extended Boot Loader Partition", XBOOTLDR);
923        check_uuid!("Swap", SWAP);
924        check_uuid!("Home Partition", HOME);
925        check_uuid!("Server Data Partition", SRV);
926        check_uuid!("Variable Data Partition", VAR);
927        check_uuid!("Temporary Data Partition", TMP);
928        check_uuid!("Generic Linux Data Partition", LINUX_DATA);
929    }
930}