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)
This commit is contained in:
committed by
Yu Watanabe
parent
30cdcd628b
commit
22a0a36efa
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user