mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-05 13:51:52 +00:00
lib/uuid.c: move generate_random_uuid() to uuid.c
Let's gather the UUID related functions under one hood. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Matt Fleming <matt@codeblueprint.co.uk> Cc: Dmitry Kasatkin <dmitry.kasatkin@gmail.com> Cc: Mimi Zohar <zohar@linux.vnet.ibm.com> Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk> Cc: Arnd Bergmann <arnd@arndb.de> Cc: "Theodore Ts'o" <tytso@mit.edu> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Jens Axboe <axboe@kernel.dk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
b8b572789c
commit
8da4b8c48e
9 changed files with 28 additions and 26 deletions
20
lib/uuid.c
20
lib/uuid.c
|
@ -23,6 +23,26 @@
|
|||
#include <linux/uuid.h>
|
||||
#include <linux/random.h>
|
||||
|
||||
/***************************************************************
|
||||
* Random UUID interface
|
||||
*
|
||||
* Used here for a Boot ID, but can be useful for other kernel
|
||||
* drivers.
|
||||
***************************************************************/
|
||||
|
||||
/*
|
||||
* Generate random UUID
|
||||
*/
|
||||
void generate_random_uuid(unsigned char uuid[16])
|
||||
{
|
||||
get_random_bytes(uuid, 16);
|
||||
/* Set UUID version to 4 --- truly random generation */
|
||||
uuid[6] = (uuid[6] & 0x0F) | 0x40;
|
||||
/* Set the UUID variant to DCE */
|
||||
uuid[8] = (uuid[8] & 0x3F) | 0x80;
|
||||
}
|
||||
EXPORT_SYMBOL(generate_random_uuid);
|
||||
|
||||
static void __uuid_gen_common(__u8 b[16])
|
||||
{
|
||||
prandom_bytes(b, 16);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue