* grub-core/fs/udf.c: Add support for UUID
authorPali Rohár <pali.rohar@gmail.com>
Thu, 22 Jun 2017 12:42:16 +0000 (14:42 +0200)
committerVladimir Serbinenko <phcoder@gmail.com>
Mon, 7 Aug 2017 15:51:50 +0000 (17:51 +0200)
commit435fa75e01ef40917239c7f775e505e86f70d202
treefe1d62b26fe8b59624016f03f2e4c079795bc7bb
parent76188809d5ca40c5285b0ab202b5edea7be3f04d
* grub-core/fs/udf.c: Add support for UUID

Use same algorithm as in libblkid from util-linux v2.30.

1. Take first 16 bytes from UTF-8 encoded string of VolumeSetIdentifier
2. If all bytes are hexadecimal digits, convert to lowercase and use as UUID
3. If first 8 bytes are not all hexadecimal digits, convert those 8 bytes
   to their hexadecimal representation, resulting in 16 bytes for UUID
4. Otherwise, compose UUID from two parts:
   1. part: converted first 8 bytes (which are hexadecimal digits) to lowercase
   2. part: encoded following 4 bytes to their hexadecimal representation (16 bytes)

So UUID would always have 16 hexadecimal digits in lowercase variant.

According to UDF specification, first 16 Unicode characters of
VolumeSetIdentifier should be unique value and first 8 should be
hexadecimal characters.

In most cases all 16 characters are hexadecimal, but e.g. MS Windows
format.exe set only first 8 as hexadecimal and remaining as fixed
(non-unique) which violates specification.
grub-core/fs/udf.c