1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
4 #include "string-util.h"
6 const GptPartitionType gpt_partition_type_table
[] = {
7 { GPT_ROOT_X86
, "root-x86" },
8 { GPT_ROOT_X86_VERITY
, "root-x86-verity" },
9 { GPT_ROOT_X86_64
, "root-x86-64" },
10 { GPT_ROOT_X86_64_VERITY
, "root-x86-64-verity" },
11 { GPT_ROOT_ARM
, "root-arm" },
12 { GPT_ROOT_ARM_VERITY
, "root-arm-verity" },
13 { GPT_ROOT_ARM_64
, "root-arm64" },
14 { GPT_ROOT_ARM_64_VERITY
, "root-arm64-verity" },
15 { GPT_ROOT_IA64
, "root-ia64" },
16 { GPT_ROOT_IA64_VERITY
, "root-ia64-verity" },
17 { GPT_ROOT_RISCV32
, "root-riscv32" },
18 { GPT_ROOT_RISCV32_VERITY
, "root-riscv32-verity" },
19 { GPT_ROOT_RISCV64
, "root-riscv64" },
20 { GPT_ROOT_RISCV64_VERITY
, "root-riscv64-verity" },
21 #ifdef GPT_ROOT_NATIVE
22 { GPT_ROOT_NATIVE
, "root" },
23 { GPT_ROOT_NATIVE_VERITY
, "root-verity" },
25 #ifdef GPT_ROOT_SECONDARY
26 { GPT_ROOT_SECONDARY
, "root-secondary" },
27 { GPT_ROOT_SECONDARY_VERITY
, "root-secondary-verity" },
29 { GPT_USR_X86
, "usr-x86" },
30 { GPT_USR_X86_VERITY
, "usr-x86-verity" },
31 { GPT_USR_X86_64
, "usr-x86-64" },
32 { GPT_USR_X86_64_VERITY
, "usr-x86-64-verity" },
33 { GPT_USR_ARM
, "usr-arm" },
34 { GPT_USR_ARM_VERITY
, "usr-arm-verity" },
35 { GPT_USR_ARM_64
, "usr-arm64" },
36 { GPT_USR_ARM_64_VERITY
, "usr-arm64-verity" },
37 { GPT_USR_IA64
, "usr-ia64" },
38 { GPT_USR_IA64_VERITY
, "usr-ia64-verity" },
39 { GPT_USR_RISCV32
, "usr-riscv32" },
40 { GPT_USR_RISCV32_VERITY
, "usr-riscv32-verity" },
41 { GPT_USR_RISCV64
, "usr-riscv64" },
42 { GPT_USR_RISCV64_VERITY
, "usr-riscv64-verity" },
44 { GPT_USR_NATIVE
, "usr" },
45 { GPT_USR_NATIVE_VERITY
, "usr-verity" },
47 #ifdef GPT_USR_SECONDARY
48 { GPT_USR_SECONDARY
, "usr-secondary" },
49 { GPT_USR_SECONDARY_VERITY
, "usr-secondary-verity" },
52 { GPT_XBOOTLDR
, "xbootldr" },
58 { GPT_USER_HOME
, "user-home" },
59 { GPT_LINUX_GENERIC
, "linux-generic" },
63 const char *gpt_partition_type_uuid_to_string(sd_id128_t id
) {
64 for (size_t i
= 0; i
< ELEMENTSOF(gpt_partition_type_table
) - 1; i
++)
65 if (sd_id128_equal(id
, gpt_partition_type_table
[i
].uuid
))
66 return gpt_partition_type_table
[i
].name
;
71 const char *gpt_partition_type_uuid_to_string_harder(
73 char buffer
[static ID128_UUID_STRING_MAX
]) {
79 s
= gpt_partition_type_uuid_to_string(id
);
83 return id128_to_uuid_string(id
, buffer
);
86 int gpt_partition_type_uuid_from_string(const char *s
, sd_id128_t
*ret
) {
90 for (size_t i
= 0; i
< ELEMENTSOF(gpt_partition_type_table
) - 1; i
++)
91 if (streq(s
, gpt_partition_type_table
[i
].name
)) {
92 *ret
= gpt_partition_type_table
[i
].uuid
;
96 return sd_id128_from_string(s
, ret
);