aboutsummaryrefslogtreecommitdiffstats
path: root/lib/uuid.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/uuid.c')
-rw-r--r--lib/uuid.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/uuid.c b/lib/uuid.c
index 398821e4dce1..6c81c0b0467e 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -23,6 +23,26 @@
23#include <linux/uuid.h> 23#include <linux/uuid.h>
24#include <linux/random.h> 24#include <linux/random.h>
25 25
26/***************************************************************
27 * Random UUID interface
28 *
29 * Used here for a Boot ID, but can be useful for other kernel
30 * drivers.
31 ***************************************************************/
32
33/*
34 * Generate random UUID
35 */
36void generate_random_uuid(unsigned char uuid[16])
37{
38 get_random_bytes(uuid, 16);
39 /* Set UUID version to 4 --- truly random generation */
40 uuid[6] = (uuid[6] & 0x0F) | 0x40;
41 /* Set the UUID variant to DCE */
42 uuid[8] = (uuid[8] & 0x3F) | 0x80;
43}
44EXPORT_SYMBOL(generate_random_uuid);
45
26static void __uuid_gen_common(__u8 b[16]) 46static void __uuid_gen_common(__u8 b[16])
27{ 47{
28 prandom_bytes(b, 16); 48 prandom_bytes(b, 16);