summaryrefslogtreecommitdiff
path: root/sys/dev/random/randomdev.c
diff options
context:
space:
mode:
authorMark Murray <markm@FreeBSD.org>2000-11-25 19:13:29 +0000
committerMark Murray <markm@FreeBSD.org>2000-11-25 19:13:29 +0000
commit50636159236da07a17f6a05b05e3787ff1c4cd51 (patch)
treed0e5b60ed533ed7e2cc46f0ba1a6f26588ae82a3 /sys/dev/random/randomdev.c
parentcaccf5c4004d8518d62fb40b38d53133af4c4bcb (diff)
Notes
Diffstat (limited to 'sys/dev/random/randomdev.c')
-rw-r--r--sys/dev/random/randomdev.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/dev/random/randomdev.c b/sys/dev/random/randomdev.c
index 13230db56885..37aeb3da9e3f 100644
--- a/sys/dev/random/randomdev.c
+++ b/sys/dev/random/randomdev.c
@@ -51,6 +51,7 @@
#include "opt_noblockrandom.h"
static d_open_t random_open;
+static d_close_t random_close;
static d_read_t random_read;
static d_write_t random_write;
static d_ioctl_t random_ioctl;
@@ -62,7 +63,7 @@ static d_poll_t random_poll;
static struct cdevsw random_cdevsw = {
/* open */ random_open,
- /* close */ (d_close_t *)nullop,
+ /* close */ random_close,
/* read */ random_read,
/* write */ random_write,
/* ioctl */ random_ioctl,
@@ -104,6 +105,14 @@ random_open(dev_t dev, int flags, int fmt, struct proc *p)
}
static int
+random_close(dev_t dev, int flags, int fmt, struct proc *p)
+{
+ if ((flags & FWRITE) && (securelevel > 0 || suser(p)))
+ random_reseed();
+ return 0;
+}
+
+static int
random_read(dev_t dev, struct uio *uio, int flag)
{
u_int c, ret;