diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index 6fdd05e..efbedb3 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -2597,26 +2597,29 @@ int iso_write_opts_set_efi_bootp(IsoWriteOpts *opts, char *image_path, /** * Control whether the emerging GPT gets a pseudo-randomly generated disk GUID - * or * whether it gets a user supplied GUID. - * The partition GUIDs will be generated in a reproducible way by exoring a - * little-endian 32 bit counter with the disk GUID beginning at byte offset 9. + * or whether it gets a user supplied GUID. + * The partition GUIDs will be generated in a reproducible way by exoring the + * little-endian 32 bit partion number with the disk GUID beginning at byte + * offset 9. * * @param opts * The option set to be manipulated. * @param guid - * 16 bytes of user supplied GUID. - * The upper 4 bit of guid[6] and guid[7] should bear the value 4 to - * express the version 4 in both endiannesses. Bit 7 of byte[8] should - * be set to 1 and bit 6 be set to 0, in order to express the RFC 4122 - * variant of GUID, where version 4 means "random". + * 16 bytes of user supplied GUID. Readily byte-swapped as prescribed by + * UEFI specs: 4 byte, 2 byte, 2 byte as little-endian. The rest as + * big-endian. + * The upper 4 bit of guid[7] should bear the value 4 to express the + * RFC 4122 version 4. Bit 7 of byte[8] should be set to 1 and bit 6 + * be set to 0, in order to express the RFC 4122 variant of UUID, + * where version 4 means "pseudo-random uuid". * @param mode * 0 = ignore parameter guid and produce the GPT disk GUID by a * pseudo-random algorithm. This is the default setting. * 1 = use parameter guid as GPT disk GUID * 2 = ignore parameter guid and derive the GPT disk GUID from * parameter vol_uuid of iso_write_opts_set_pvd_times(). - * The 16 bytes of vol_uuid get copied and bytes 6, 7, 8 get their - * upper bits changed to comply to RFC 4122. + * The 16 bytes of vol_uuid get copied and bytes 7, 8 get their + * upper bits changed to comply to RFC 4122 and UEFI. * Error ISO_GPT_NO_VOL_UUID will occur if image production begins * before vol_uuid was set. * diff --git a/libisofs/system_area.c b/libisofs/system_area.c index 8db8cd4..5ef3e21 100644 --- a/libisofs/system_area.c +++ b/libisofs/system_area.c @@ -2362,10 +2362,9 @@ uint32_t iso_crc32_gpt(unsigned char *data, int count, int flag) void iso_mark_guid_version_4(uint8_t *u) { - /* Mark as UUID version 4. RFC 4122 says u[6], but isohybrid swapping - effectively puts the 4 into u[7]. So i mark both. 4 bits wasted. + /* Mark as UUID version 4. RFC 4122 says u[6], but UEFI prescribes + bytes 6 and 7 to be swapped. */ - u[6] = (u[6] & 0x0f) | 0x40; u[7] = (u[7] & 0x0f) | 0x40; /* Variant is "1 0 x" as described in RFC 4122. @@ -2389,7 +2388,7 @@ void iso_generate_gpt_guid(uint8_t guid[16]) #else uint8_t *u; - /* produced by uuid_generate() and byte-swapped to isohybrid.c habits */ + /* produced by uuid_generate() and byte-swapped to UEFI specs */ static uint8_t uuid_template[16] = { 0xee, 0x29, 0x9d, 0xfc, 0x65, 0xcc, 0x7c, 0x40, 0x92, 0x61, 0x5b, 0xcd, 0x6f, 0xed, 0x08, 0x34