diff options
-rw-r--r-- | drivers/char/random.c | 21 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 2 | ||||
-rw-r--r-- | fs/ext4/ioctl.c | 2 | ||||
-rw-r--r-- | fs/f2fs/file.c | 2 | ||||
-rw-r--r-- | fs/reiserfs/objectid.c | 2 | ||||
-rw-r--r-- | fs/ubifs/sb.c | 2 | ||||
-rw-r--r-- | include/linux/random.h | 1 | ||||
-rw-r--r-- | include/linux/uuid.h | 2 | ||||
-rw-r--r-- | lib/uuid.c | 20 |
9 files changed, 28 insertions, 26 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index b583e5336630..0158d3bff7e5 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
@@ -260,6 +260,7 @@ | |||
260 | #include <linux/irq.h> | 260 | #include <linux/irq.h> |
261 | #include <linux/syscalls.h> | 261 | #include <linux/syscalls.h> |
262 | #include <linux/completion.h> | 262 | #include <linux/completion.h> |
263 | #include <linux/uuid.h> | ||
263 | 264 | ||
264 | #include <asm/processor.h> | 265 | #include <asm/processor.h> |
265 | #include <asm/uaccess.h> | 266 | #include <asm/uaccess.h> |
@@ -1621,26 +1622,6 @@ SYSCALL_DEFINE3(getrandom, char __user *, buf, size_t, count, | |||
1621 | return urandom_read(NULL, buf, count, NULL); | 1622 | return urandom_read(NULL, buf, count, NULL); |
1622 | } | 1623 | } |
1623 | 1624 | ||
1624 | /*************************************************************** | ||
1625 | * Random UUID interface | ||
1626 | * | ||
1627 | * Used here for a Boot ID, but can be useful for other kernel | ||
1628 | * drivers. | ||
1629 | ***************************************************************/ | ||
1630 | |||
1631 | /* | ||
1632 | * Generate random UUID | ||
1633 | */ | ||
1634 | void generate_random_uuid(unsigned char uuid_out[16]) | ||
1635 | { | ||
1636 | get_random_bytes(uuid_out, 16); | ||
1637 | /* Set UUID version to 4 --- truly random generation */ | ||
1638 | uuid_out[6] = (uuid_out[6] & 0x0F) | 0x40; | ||
1639 | /* Set the UUID variant to DCE */ | ||
1640 | uuid_out[8] = (uuid_out[8] & 0x3F) | 0x80; | ||
1641 | } | ||
1642 | EXPORT_SYMBOL(generate_random_uuid); | ||
1643 | |||
1644 | /******************************************************************** | 1625 | /******************************************************************** |
1645 | * | 1626 | * |
1646 | * Sysctl interface | 1627 | * Sysctl interface |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index bd0f45fb38c4..bfb80da3e6eb 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -20,13 +20,13 @@ | |||
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | #include <linux/buffer_head.h> | 21 | #include <linux/buffer_head.h> |
22 | #include <linux/blkdev.h> | 22 | #include <linux/blkdev.h> |
23 | #include <linux/random.h> | ||
24 | #include <linux/iocontext.h> | 23 | #include <linux/iocontext.h> |
25 | #include <linux/capability.h> | 24 | #include <linux/capability.h> |
26 | #include <linux/ratelimit.h> | 25 | #include <linux/ratelimit.h> |
27 | #include <linux/kthread.h> | 26 | #include <linux/kthread.h> |
28 | #include <linux/raid/pq.h> | 27 | #include <linux/raid/pq.h> |
29 | #include <linux/semaphore.h> | 28 | #include <linux/semaphore.h> |
29 | #include <linux/uuid.h> | ||
30 | #include <asm/div64.h> | 30 | #include <asm/div64.h> |
31 | #include "ctree.h" | 31 | #include "ctree.h" |
32 | #include "extent_map.h" | 32 | #include "extent_map.h" |
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index eae5917c534e..7497f50cb293 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c | |||
@@ -13,8 +13,8 @@ | |||
13 | #include <linux/compat.h> | 13 | #include <linux/compat.h> |
14 | #include <linux/mount.h> | 14 | #include <linux/mount.h> |
15 | #include <linux/file.h> | 15 | #include <linux/file.h> |
16 | #include <linux/random.h> | ||
17 | #include <linux/quotaops.h> | 16 | #include <linux/quotaops.h> |
17 | #include <linux/uuid.h> | ||
18 | #include <asm/uaccess.h> | 18 | #include <asm/uaccess.h> |
19 | #include "ext4_jbd2.h" | 19 | #include "ext4_jbd2.h" |
20 | #include "ext4.h" | 20 | #include "ext4.h" |
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index eb9d027e5981..c6b14951bef3 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/uaccess.h> | 20 | #include <linux/uaccess.h> |
21 | #include <linux/mount.h> | 21 | #include <linux/mount.h> |
22 | #include <linux/pagevec.h> | 22 | #include <linux/pagevec.h> |
23 | #include <linux/random.h> | 23 | #include <linux/uuid.h> |
24 | 24 | ||
25 | #include "f2fs.h" | 25 | #include "f2fs.h" |
26 | #include "node.h" | 26 | #include "node.h" |
diff --git a/fs/reiserfs/objectid.c b/fs/reiserfs/objectid.c index 99a5d5dae46a..415d66ca87d1 100644 --- a/fs/reiserfs/objectid.c +++ b/fs/reiserfs/objectid.c | |||
@@ -3,8 +3,8 @@ | |||
3 | */ | 3 | */ |
4 | 4 | ||
5 | #include <linux/string.h> | 5 | #include <linux/string.h> |
6 | #include <linux/random.h> | ||
7 | #include <linux/time.h> | 6 | #include <linux/time.h> |
7 | #include <linux/uuid.h> | ||
8 | #include "reiserfs.h" | 8 | #include "reiserfs.h" |
9 | 9 | ||
10 | /* find where objectid map starts */ | 10 | /* find where objectid map starts */ |
diff --git a/fs/ubifs/sb.c b/fs/ubifs/sb.c index f4fbc7b6b794..3cbb904a6d7d 100644 --- a/fs/ubifs/sb.c +++ b/fs/ubifs/sb.c | |||
@@ -28,8 +28,8 @@ | |||
28 | 28 | ||
29 | #include "ubifs.h" | 29 | #include "ubifs.h" |
30 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
31 | #include <linux/random.h> | ||
32 | #include <linux/math64.h> | 31 | #include <linux/math64.h> |
32 | #include <linux/uuid.h> | ||
33 | 33 | ||
34 | /* | 34 | /* |
35 | * Default journal size in logical eraseblocks as a percent of total | 35 | * Default journal size in logical eraseblocks as a percent of total |
diff --git a/include/linux/random.h b/include/linux/random.h index 9c29122037f9..e47e533742b5 100644 --- a/include/linux/random.h +++ b/include/linux/random.h | |||
@@ -26,7 +26,6 @@ extern void get_random_bytes(void *buf, int nbytes); | |||
26 | extern int add_random_ready_callback(struct random_ready_callback *rdy); | 26 | extern int add_random_ready_callback(struct random_ready_callback *rdy); |
27 | extern void del_random_ready_callback(struct random_ready_callback *rdy); | 27 | extern void del_random_ready_callback(struct random_ready_callback *rdy); |
28 | extern void get_random_bytes_arch(void *buf, int nbytes); | 28 | extern void get_random_bytes_arch(void *buf, int nbytes); |
29 | void generate_random_uuid(unsigned char uuid_out[16]); | ||
30 | extern int random_int_secret_init(void); | 29 | extern int random_int_secret_init(void); |
31 | 30 | ||
32 | #ifndef MODULE | 31 | #ifndef MODULE |
diff --git a/include/linux/uuid.h b/include/linux/uuid.h index 6df2509033d7..91c2b6d9cbb7 100644 --- a/include/linux/uuid.h +++ b/include/linux/uuid.h | |||
@@ -33,6 +33,8 @@ static inline int uuid_be_cmp(const uuid_be u1, const uuid_be u2) | |||
33 | return memcmp(&u1, &u2, sizeof(uuid_be)); | 33 | return memcmp(&u1, &u2, sizeof(uuid_be)); |
34 | } | 34 | } |
35 | 35 | ||
36 | void generate_random_uuid(unsigned char uuid[16]); | ||
37 | |||
36 | extern void uuid_le_gen(uuid_le *u); | 38 | extern void uuid_le_gen(uuid_le *u); |
37 | extern void uuid_be_gen(uuid_be *u); | 39 | extern void uuid_be_gen(uuid_be *u); |
38 | 40 | ||
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 | */ | ||
36 | void 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 | } | ||
44 | EXPORT_SYMBOL(generate_random_uuid); | ||
45 | |||
26 | static void __uuid_gen_common(__u8 b[16]) | 46 | static void __uuid_gen_common(__u8 b[16]) |
27 | { | 47 | { |
28 | prandom_bytes(b, 16); | 48 | prandom_bytes(b, 16); |