1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
9 #include "architecture.h"
10 #include "id128-util.h"
11 #include "sparse-endian.h"
13 /* maximum length of gpt label */
14 #define GPT_LABEL_MAX 36
16 typedef enum PartitionDesignator
{
17 PARTITION_ROOT
, /* Primary architecture */
24 PARTITION_ROOT_VERITY
, /* verity data for the PARTITION_ROOT partition */
26 PARTITION_ROOT_VERITY_SIG
, /* PKCS#7 signature for root hash for the PARTITION_ROOT partition */
27 PARTITION_USR_VERITY_SIG
,
30 _PARTITION_DESIGNATOR_MAX
,
31 _PARTITION_DESIGNATOR_INVALID
= -EINVAL
,
32 } PartitionDesignator
;
34 bool partition_designator_is_versioned(PartitionDesignator d
);
36 PartitionDesignator
partition_verity_of(PartitionDesignator p
);
37 PartitionDesignator
partition_verity_sig_of(PartitionDesignator p
);
38 PartitionDesignator
partition_verity_to_data(PartitionDesignator d
);
39 PartitionDesignator
partition_verity_sig_to_data(PartitionDesignator d
);
41 const char* partition_designator_to_string(PartitionDesignator d
) _const_
;
42 PartitionDesignator
partition_designator_from_string(const char *name
) _pure_
;
44 const char *gpt_partition_type_uuid_to_string(sd_id128_t id
);
45 const char *gpt_partition_type_uuid_to_string_harder(
47 char buffer
[static SD_ID128_UUID_STRING_MAX
]);
49 #define GPT_PARTITION_TYPE_UUID_TO_STRING_HARDER(id) \
50 gpt_partition_type_uuid_to_string_harder((id), (char[SD_ID128_UUID_STRING_MAX]) {})
52 Architecture
gpt_partition_type_uuid_to_arch(sd_id128_t id
);
54 typedef struct GptPartitionType
{
58 PartitionDesignator designator
;
61 extern const GptPartitionType gpt_partition_type_table
[];
63 int gpt_partition_label_valid(const char *s
);
65 GptPartitionType
gpt_partition_type_from_uuid(sd_id128_t id
);
66 int gpt_partition_type_from_string(const char *s
, GptPartitionType
*ret
);
68 GptPartitionType
gpt_partition_type_override_architecture(GptPartitionType type
, Architecture arch
);
70 const char *gpt_partition_type_mountpoint_nulstr(GptPartitionType type
);
72 bool gpt_partition_type_knows_read_only(GptPartitionType type
);
73 bool gpt_partition_type_knows_growfs(GptPartitionType type
);
74 bool gpt_partition_type_knows_no_auto(GptPartitionType type
);
77 uint8_t partition_type_guid
[16];
78 uint8_t unique_partition_guid
[16];
82 char16_t partition_name
[36];
83 } _packed_ GptPartitionEntry
;
93 le64_t first_usable_lba
;
94 le64_t last_usable_lba
;
95 uint8_t disk_guid
[16];
96 le64_t partition_entry_lba
;
97 le32_t number_of_partition_entries
;
98 le32_t size_of_partition_entry
;
99 le32_t partition_entry_array_crc32
;
100 } _packed_ GptHeader
;
102 bool gpt_header_has_signature(const GptHeader
*p
);