summaryrefslogtreecommitdiff
path: root/src/shared/gpt.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-01-17 11:34:13 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-01-23 23:32:13 +0100
commitdc972b0740714a9798fed0e20bc78efa0c5ad9a7 (patch)
treeb554833455f93a7f0dbbe8ffd7628d20d135bef8 /src/shared/gpt.c
parent19ce38ce620f54e71bebad1c47e186289da48afd (diff)
downloadsystemd-dc972b0740714a9798fed0e20bc78efa0c5ad9a7.tar.gz
systemd-id128: add new verb to print GPT partitions UUIDs
Diffstat (limited to 'src/shared/gpt.c')
-rw-r--r--src/shared/gpt.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/shared/gpt.c b/src/shared/gpt.c
index 024f4db515..e62f21e889 100644
--- a/src/shared/gpt.c
+++ b/src/shared/gpt.c
@@ -3,12 +3,7 @@
#include "gpt.h"
#include "string-util.h"
-typedef struct GptPartitionType {
- sd_id128_t uuid;
- const char *name;
-} GptPartitionType;
-
-static const GptPartitionType gpt_partition_type_table[] = {
+const GptPartitionType gpt_partition_type_table[] = {
{ GPT_ROOT_X86, "root-x86" },
{ GPT_ROOT_X86_VERITY, "root-x86-verity" },
{ GPT_ROOT_X86_64, "root-x86-64" },
@@ -35,10 +30,11 @@ static const GptPartitionType gpt_partition_type_table[] = {
{ GPT_VAR, "var" },
{ GPT_TMP, "tmp" },
{ GPT_LINUX_GENERIC, "linux-generic", },
+ {}
};
const char *gpt_partition_type_uuid_to_string(sd_id128_t id) {
- for (size_t i = 0; i < ELEMENTSOF(gpt_partition_type_table); i++)
+ for (size_t i = 0; i < ELEMENTSOF(gpt_partition_type_table) - 1; i++)
if (sd_id128_equal(id, gpt_partition_type_table[i].uuid))
return gpt_partition_type_table[i].name;
@@ -64,7 +60,7 @@ int gpt_partition_type_uuid_from_string(const char *s, sd_id128_t *ret) {
assert(s);
assert(ret);
- for (size_t i = 0; i < ELEMENTSOF(gpt_partition_type_table); i++)
+ for (size_t i = 0; i < ELEMENTSOF(gpt_partition_type_table) - 1; i++)
if (streq(s, gpt_partition_type_table[i].name)) {
*ret = gpt_partition_type_table[i].uuid;
return 0;