summaryrefslogtreecommitdiff
path: root/src/shared/gpt.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-01-06 15:50:14 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-03-04 14:50:24 +0900
commit22a0a36efa030239b3324434c8ea98ae0472cc4f (patch)
tree9a9b45f7aa2b56daabd1b4f10b51e9110706584a /src/shared/gpt.c
parent30cdcd628bbb046729d3d4c301167b12efdeca19 (diff)
downloadsystemd-22a0a36efa030239b3324434c8ea98ae0472cc4f.tar.gz
gpt: generalize validator for GPT partition labels
This adds a proper validator function. No change in behaviour, just some minor refactoring (this should be useful elsewhere later on though)
Diffstat (limited to 'src/shared/gpt.c')
-rw-r--r--src/shared/gpt.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/shared/gpt.c b/src/shared/gpt.c
index 15ea2f0a1f..a96f5ee02d 100644
--- a/src/shared/gpt.c
+++ b/src/shared/gpt.c
@@ -2,6 +2,7 @@
#include "gpt.h"
#include "string-util.h"
+#include "utf8.h"
const GptPartitionType gpt_partition_type_table[] = {
{ GPT_ROOT_X86, "root-x86" },
@@ -95,3 +96,13 @@ int gpt_partition_type_uuid_from_string(const char *s, sd_id128_t *ret) {
return sd_id128_from_string(s, ret);
}
+
+int gpt_partition_label_valid(const char *s) {
+ _cleanup_free_ char16_t *recoded = NULL;
+
+ recoded = utf8_to_utf16(s, strlen(s));
+ if (!recoded)
+ return -ENOMEM;
+
+ return char16_strlen(recoded) <= 36;
+}