@@ -40,6 +40,7 @@ void uuid_bin_to_str(unsigned char *uuid_bin, char *uuid_str, int str_format);
int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin);
int uuid_guid_get_str(unsigned char *guid_bin, char *guid_str);
#endif
+int uuid_guid_parse_str(const char *str, char *guid_str);
void gen_rand_uuid(unsigned char *uuid_bin);
void gen_rand_uuid_str(char *uuid_str, int str_format);
#endif
@@ -136,6 +136,41 @@ int uuid_guid_get_str(unsigned char *guid_bin, char *guid_str)
#endif
/*
+ * uuid_guid_parse_str() - this function parses string to found a valid GUID.
+ *
+ * @param guid_str - pointer to string with partition type guid [37B]
+ * or GUID shorcut defined in list_guid[]
+ * @param guid_str - pointer to allocated partition type string [37B]
+ * @return 0 if OK, else -ENODEV
+ */
+int uuid_guid_parse_str(const char *str, char *guid_str)
+{
+#ifdef CONFIG_PARTITION_TYPE_GUID
+ int i;
+#endif
+
+ if (guid_str == NULL)
+ return -ENODEV;
+
+ if (uuid_str_valid(str)) {
+ memcpy(guid_str, str, UUID_STR_LEN + 1);
+ return 0;
+ }
+
+#ifdef CONFIG_PARTITION_TYPE_GUID
+ for (i = 0; i < ARRAY_SIZE(list_guid); i++) {
+ if (!strcmp(list_guid[i].string, str)) {
+ uuid_bin_to_str((unsigned char *)list_guid[i].guid.b,
+ guid_str, UUID_STR_FORMAT_GUID);
+ return 0;
+ }
+ }
+#endif
+
+ return -ENODEV;
+}
+
+/*
* uuid_str_to_bin() - convert string UUID or GUID to big endian binary data.
*
* @param uuid_str - pointer to UUID or GUID string [37B] or GUID shorcut