From: Daan De Meyer Date: Tue, 27 Sep 2022 10:30:55 +0000 (+0200) Subject: gpt: Add gpt_partition_type_mountpoint_nulstr() X-Git-Tag: v253-rc1~551^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=58b4ad76ca91309a570ae4811e90b8d7b8a09777;p=thirdparty%2Fsystemd.git gpt: Add gpt_partition_type_mountpoint_nulstr() --- diff --git a/src/shared/gpt.c b/src/shared/gpt.c index 1670b90ad4e..af969ff9d57 100644 --- a/src/shared/gpt.c +++ b/src/shared/gpt.c @@ -158,6 +158,23 @@ static const char *const partition_designator_table[] = { DEFINE_STRING_TABLE_LOOKUP(partition_designator, PartitionDesignator); +static const char *const partition_mountpoint_table[] = { + [PARTITION_ROOT] = "/\0", + [PARTITION_ROOT_SECONDARY] = "/\0", + [PARTITION_ROOT_OTHER] = "/\0", + [PARTITION_USR] = "/usr\0", + [PARTITION_USR_SECONDARY] = "/usr\0", + [PARTITION_USR_OTHER] = "/usr\0", + [PARTITION_HOME] = "/home\0", + [PARTITION_SRV] = "/srv\0", + [PARTITION_ESP] = "/efi\0/boot\0", + [PARTITION_XBOOTLDR] = "/boot\0", + [PARTITION_TMP] = "/var/tmp\0", + [PARTITION_VAR] = "/var\0", +}; + +DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(partition_mountpoint, PartitionDesignator); + #define _GPT_ARCH_SEXTET(arch, name) \ { SD_GPT_ROOT_##arch, "root-" name, ARCHITECTURE_##arch, .designator = PARTITION_ROOT_OTHER }, \ { SD_GPT_ROOT_##arch##_VERITY, "root-" name "-verity", ARCHITECTURE_##arch, .designator = PARTITION_ROOT_OTHER_VERITY }, \ @@ -338,6 +355,14 @@ bool gpt_partition_type_is_usr_verity_sig(sd_id128_t id) { PARTITION_USR_OTHER_VERITY_SIG); } +const char *gpt_partition_type_mountpoint_nulstr(sd_id128_t id) { + PartitionDesignator d = gpt_partition_type_from_uuid(id).designator; + if (d < 0) + return NULL; + + return partition_mountpoint_to_string(d); +} + bool gpt_partition_type_knows_read_only(sd_id128_t id) { return gpt_partition_type_is_root(id) || gpt_partition_type_is_usr(id) || diff --git a/src/shared/gpt.h b/src/shared/gpt.h index 70e79550db3..e0ab44a6427 100644 --- a/src/shared/gpt.h +++ b/src/shared/gpt.h @@ -81,6 +81,8 @@ bool gpt_partition_type_is_usr(sd_id128_t id); bool gpt_partition_type_is_usr_verity(sd_id128_t id); bool gpt_partition_type_is_usr_verity_sig(sd_id128_t id); +const char *gpt_partition_type_mountpoint_nulstr(sd_id128_t id); + bool gpt_partition_type_knows_read_only(sd_id128_t id); bool gpt_partition_type_knows_growfs(sd_id128_t id); bool gpt_partition_type_knows_no_auto(sd_id128_t id);