diff options
Diffstat (limited to 'sys/dev/random/randomdev.c')
-rw-r--r-- | sys/dev/random/randomdev.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/dev/random/randomdev.c b/sys/dev/random/randomdev.c index 13230db..37aeb3d 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; |