Hello :)
Here is my GSoC qualification patch for ticket #580. It makes
gpt_set_random_uuid() generate UUIDs conforming to RFC 4122 (version 4
UUID). Can you review it?
PS I know that the patch is small and trivial - will it be sufficient?
Thanks,
Agnieszka
=== modified file 'uspace/lib/gpt/libgpt.c'
--- uspace/lib/gpt/libgpt.c 2013-12-25 16:09:43 +0000
+++ uspace/lib/gpt/libgpt.c 2014-03-09 16:24:16 +0000
@@ -706,17 +706,23 @@
partition->attributes = attr;
}
-/** Generate a new pseudo-random UUID
- *
- * FIXME: This UUID generator is not compliant with RFC 4122.
- *
- */
+/** Generate a new pseudo-random UUID compliant with RFC 4122 */
void gpt_set_random_uuid(uint8_t *uuid)
{
srandom((unsigned int) (size_t) uuid);
for (size_t i = 0; i < 16; i++)
uuid[i] = random();
+
+ /*
+ * Set version (stored in bits 4-7 of seventh byte) to 4 (random
+ * UUID) and bits 6 and 7 of ninth byte to 0 and 1 respecitvely -
+ * according to RFC 4122, section 4.4.
+ */
+ uuid[6] &= 0x0f;
+ uuid[6] |= (0x4 << 4);
+ uuid[8] &= 0x3f;
+ uuid[8] |= (1 << 7);
}
/** Get next aligned address */
_______________________________________________
HelenOS-devel mailing list
[email protected]
http://lists.modry.cz/listinfo/helenos-devel