All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: "Theodore Ts'o" <tytso@mit.edu>, linux-kernel@vger.kernel.org
Subject: [PATCH] random: Add "initialized" variable to proc
Date: Mon, 28 Apr 2014 21:52:11 +0200	[thread overview]
Message-ID: <20140428195913.E0A0143994596@oldenburg.str.redhat.com> (raw)

Before this change, you had to check kernel log messages to see if the
non-blocking pool had been properly initialized.  With this change, you
can consult the file /proc/sys/kernel/random/intialized instead.

Signed-off-by: Florian Weimer <fweimer@redhat.com>
---
 drivers/char/random.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index 6b75713..81d83e2 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1592,6 +1592,19 @@ static int proc_do_entropy(ctl_table *table, int write,
 	return proc_dointvec(&fake_table, write, buffer, lenp, ppos);
 }
 
+/*
+ * Return whether the urandom pool has been initialized.
+ */
+static int proc_do_initialized(ctl_table *table, int write,
+			       void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+	ctl_table fake_table;
+	char ch = '0' + nonblocking_pool.initialized;
+	fake_table.data = &ch;
+	fake_table.maxlen = 1;
+	return proc_dostring(&fake_table, write, buffer, lenp, ppos);
+}
+
 static int sysctl_poolsize = INPUT_POOL_WORDS * 32;
 extern struct ctl_table random_table[];
 struct ctl_table random_table[] = {
@@ -1610,6 +1623,12 @@ struct ctl_table random_table[] = {
 		.data		= &input_pool.entropy_count,
 	},
 	{
+		.procname	= "initialized",
+		.maxlen		= 1,
+		.mode		= 0444,
+		.proc_handler	= proc_do_initialized,
+	},
+	{
 		.procname	= "read_wakeup_threshold",
 		.data		= &random_read_wakeup_bits,
 		.maxlen		= sizeof(int),
-- 
1.9.0


             reply	other threads:[~2014-04-28 20:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-28 19:52 Florian Weimer [this message]
2014-04-28 21:41 ` [PATCH] random: Add "initialized" variable to proc Theodore Ts'o
2014-04-29 17:51   ` Florian Weimer
2014-04-29 18:26     ` Theodore Ts'o
2014-04-30 20:52       ` Andy Lutomirski
2014-05-01  2:06         ` Theodore Ts'o
2014-05-01  4:05           ` H. Peter Anvin
2014-05-01 15:05             ` tytso
2014-05-01 15:35               ` Andy Lutomirski
2014-05-01 18:53                 ` Andy Lutomirski
2014-05-01 18:59                   ` random: Providing a seed value to VM guests H. Peter Anvin
2014-05-01  5:37           ` [PATCH] random: Add "initialized" variable to proc H. Peter Anvin
2014-05-01 14:33             ` Jason Cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140428195913.E0A0143994596@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.