[parted-devel] [PATCH v3] dos: improve MBR signature generation

Jonathan Liu net147 at gmail.com
Wed Oct 2 10:33:10 UTC 2013


On 2/10/2013 9:27 AM, Brian C. Lane wrote:
> On Wed, Oct 02, 2013 at 01:00:43AM +1000, Jonathan Liu wrote:
>> +/* hack: use the ext2 uuid library to generate a reasonably random (hopefully
>> + * with /dev/random) number.  Unfortunately, we can only use 4 bytes of it.
>> + * We make sure to avoid returning zero which may be interpreted as no FAT
>> + * serial number or no MBR signature.
>> + */
>> +static inline uint32_t
>> +generate_random_uint32 (void)
>> +{
>> +	union {
>> +		uuid_t uuid;
>> +		uint32_t i;
>> +	} uu32;
>> +
>> +	do {
>> +		uuid_generate (uu32.uuid);
>> +	} while (uu32.i == 0);
> I'd like to see a limit on this while with an error if it gets a zero
> more than 3 times in a row.
>
I will just make it return 0xffffffff if the generated UUID is 0.
V4 patch submitted.

Regards,
Jonathan



More information about the parted-devel mailing list