summaryrefslogtreecommitdiffstats
path: root/target/linux/generic-2.4/patches/901-ocf-20100325.patch
blob: 6d0f522f745d403737655bce67e86f46d203bcfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -901,6 +901,65 @@ void add_blkdev_randomness(int major)
 #define subRound(a, b, c, d, e, f, k, data) \
     ( e += ROTL( 5, a ) + f( b, c, d ) + k + data, b = ROTL( 30, b ) )
 
+/*
+ * random_input_words - add bulk entropy to pool
+ *
+ * @buf: buffer to add
+ * @wordcount: number of __u32 words to add
+ * @ent_count: total amount of entropy (in bits) to credit
+ *
+ * this provides bulk input of entropy to the input pool
+ *
+ */
+void random_input_words(__u32 *buf, size_t wordcount, int ent_count)
+{
+	if (!random_state)
+		return;
+	add_entropy_words(random_state, buf, wordcount);
+
+	credit_entropy_store(random_state, ent_count);
+
+	DEBUG_ENT("credited %d bits => %d\n",
+		  ent_count, random_state->entropy_count);
+	/*
+	 * Wake up waiting processes if we have enough
+	 * entropy.
+	 */
+	if (random_state->entropy_count >= random_read_wakeup_thresh)
+		wake_up_interruptible(&random_read_wait);
+}
+EXPORT_SYMBOL(random_input_words);
+
+/*
+ * random_input_wait - wait until random needs entropy
+ *
+ * this function sleeps until the /dev/random subsystem actually
+ * needs more entropy, and then return the amount of entropy
+ * that it would be nice to have added to the system.
+ */
+int random_input_wait(void)
+{
+	int count;
+
+	if (!random_state)
+		return -1;
+
+	wait_event_interruptible(random_write_wait, 
+			 random_state->entropy_count < random_write_wakeup_thresh);
+
+	count = random_write_wakeup_thresh - random_state->entropy_count;
+
+	/* likely we got woken up due to a signal */
+	if (count <= 0) count = random_read_wakeup_thresh; 
+
+	DEBUG_ENT("requesting %d bits from input_wait()er %d<%d\n",
+		  count,
+		  random_state->entropy_count, random_write_wakeup_thresh);
+
+	return count;
+}
+EXPORT_SYMBOL(random_input_wait);
+
 
 static void SHATransform(__u32 digest[85], __u32 const data[16])
 {
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -10,6 +10,8 @@ O_TARGET := fs.o
 export-objs :=	filesystems.o open.o dcache.o buffer.o dquot.o
 mod-subdirs :=	nls
 
+export-objs +=	fcntl.o
+
 obj-y :=	open.o read_write.o devices.o file_table.o buffer.o \
 		super.o block_dev.o char_dev.o stat.o exec.o pipe.o namei.o \
 		fcntl.o ioctl.o readdir.o select.o fifo.o locks.o \
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -12,6 +12,7 @@
 #include <linux/slab.h>
 #include <linux/iobuf.h>
 #include <linux/ptrace.h>
+#include <linux/module.h>
 
 #include <asm/poll.h>
 #include <asm/siginfo.h>
@@ -199,6 +200,7 @@ asmlinkage long sys_dup(unsigned int fil
 		ret = dupfd(file, 0);
 	return ret;
 }
+EXPORT_SYMBOL(sys_dup);
 
 #define SETFL_MASK (O_APPEND | O_NONBLOCK | O_NDELAY | FASYNC | O_DIRECT)
 
--- a/include/linux/miscdevice.h
+++ b/include/linux/miscdevice.h
@@ -15,6 +15,7 @@
 #define ADB_MOUSE_MINOR		10
 #define MK712_MINOR 		15	/* MK712 touch screen */
 #define SYNTH_MINOR    		25
+#define	CRYPTODEV_MINOR		70	/* OpenBSD cryptographic framework */
 #define WATCHDOG_MINOR		130	/* Watchdog timer     */
 #define TEMP_MINOR		131	/* Temperature Sensor */
 #define RTC_MINOR		135
--- a/include/linux/random.h
+++ b/include/linux/random.h
@@ -53,6 +53,10 @@ extern void add_mouse_randomness(__u32 m
 extern void add_interrupt_randomness(int irq);
 extern void add_blkdev_randomness(int major);
 
+extern void random_input_words(__u32 *buf, size_t wordcount, int ent_count);
+extern int random_input_wait(void);
+#define HAS_RANDOM_INPUT_WAIT 1
+
 extern void get_random_bytes(void *buf, int nbytes);
 void generate_random_uuid(unsigned char uuid_out[16]);