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

Jim Meyering jim at meyering.net
Tue Oct 1 14:43:28 UTC 2013


On Thu, Sep 26, 2013 at 6:17 PM, Jonathan Liu <net147 at gmail.com> wrote:
> Using tv_usec in struct timeval from gettimeofday() doesn't provide
> enough precision to fill an unsigned 32-bit integer and isn't really
> random. It it always less than one million when using the GNU C library
> while an unsigned 32-bit integer ranges between 0 and 4294967295.
>
> A better random generator is used for FAT filesystem creation so move
> it into a common function and use it for MS-DOS MBR signature
> generation.
>
> * libparted/fs/r/fat/fat.c (_gen_new_serial_number): Remove.
> (fat_create): Use generate_random_uint32 instead of
> _gen_new_serial_number.
> * libparted/labels/dos.c (generate_random_id): Remove.
> (msdos_write): Use generate_random_uint32 instead of
> generate_random_id.
> * libparted/labels/misc.h (generate_random_uint32): New function.
> Created from _gen_new_serial_number in libparted/fs/r/fat/fat.c with
> additional check to avoid returning zero which may be interpreted
> as no FAT serial number or no MBR signature.

Thank you for the patch.  Normally we require copyright assignment,
but this change is small enough to get by without that.  Would you
please amend your commit to do two things:
  - insert a note in NEWS that describes this change
  - move or copy the commit-log comment about the meaning of that zero
into the function's comment.

With those, it should be good to push, assuming "make syntax-check"
and "make check" still pass.



More information about the parted-devel mailing list