Deleted Added
full compact
randomdev.c (67893) randomdev.c (69172)
1/*-
2 * Copyright (c) 2000 Mark R V Murray
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 2000 Mark R V Murray
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/dev/random/randomdev.c 67893 2000-10-29 16:06:56Z phk $
26 * $FreeBSD: head/sys/dev/random/randomdev.c 69172 2000-11-25 19:13:29Z markm $
27 */
28
29#include <sys/param.h>
30#include <sys/queue.h>
31#include <sys/systm.h>
32#include <sys/conf.h>
33#include <sys/fcntl.h>
34#include <sys/uio.h>

--- 11 unchanged lines hidden (view full) ---

46#include <crypto/blowfish/blowfish.h>
47
48#include <dev/random/hash.h>
49#include <dev/random/yarrow.h>
50
51#include "opt_noblockrandom.h"
52
53static d_open_t random_open;
27 */
28
29#include <sys/param.h>
30#include <sys/queue.h>
31#include <sys/systm.h>
32#include <sys/conf.h>
33#include <sys/fcntl.h>
34#include <sys/uio.h>

--- 11 unchanged lines hidden (view full) ---

46#include <crypto/blowfish/blowfish.h>
47
48#include <dev/random/hash.h>
49#include <dev/random/yarrow.h>
50
51#include "opt_noblockrandom.h"
52
53static d_open_t random_open;
54static d_close_t random_close;
54static d_read_t random_read;
55static d_write_t random_write;
56static d_ioctl_t random_ioctl;
57static d_poll_t random_poll;
58
59#define CDEV_MAJOR 2
60#define RANDOM_MINOR 3
61#define URANDOM_MINOR 4
62
63static struct cdevsw random_cdevsw = {
64 /* open */ random_open,
55static d_read_t random_read;
56static d_write_t random_write;
57static d_ioctl_t random_ioctl;
58static d_poll_t random_poll;
59
60#define CDEV_MAJOR 2
61#define RANDOM_MINOR 3
62#define URANDOM_MINOR 4
63
64static struct cdevsw random_cdevsw = {
65 /* open */ random_open,
65 /* close */ (d_close_t *)nullop,
66 /* close */ random_close,
66 /* read */ random_read,
67 /* write */ random_write,
68 /* ioctl */ random_ioctl,
69 /* poll */ random_poll,
70 /* mmap */ nommap,
71 /* strategy */ nostrategy,
72 /* name */ "random",
73 /* maj */ CDEV_MAJOR,

--- 25 unchanged lines hidden (view full) ---

99{
100 if ((flags & FWRITE) && (securelevel > 0 || suser(p)))
101 return EPERM;
102 else
103 return 0;
104}
105
106static int
67 /* read */ random_read,
68 /* write */ random_write,
69 /* ioctl */ random_ioctl,
70 /* poll */ random_poll,
71 /* mmap */ nommap,
72 /* strategy */ nostrategy,
73 /* name */ "random",
74 /* maj */ CDEV_MAJOR,

--- 25 unchanged lines hidden (view full) ---

100{
101 if ((flags & FWRITE) && (securelevel > 0 || suser(p)))
102 return EPERM;
103 else
104 return 0;
105}
106
107static int
108random_close(dev_t dev, int flags, int fmt, struct proc *p)
109{
110 if ((flags & FWRITE) && (securelevel > 0 || suser(p)))
111 random_reseed();
112 return 0;
113}
114
115static int
107random_read(dev_t dev, struct uio *uio, int flag)
108{
109 u_int c, ret;
110 int error = 0;
111 void *random_buf;
112
113/* XXX Temporary ifndef to allow users to have a nonblocking device */
114#ifndef NOBLOCKRANDOM

--- 92 unchanged lines hidden ---
116random_read(dev_t dev, struct uio *uio, int flag)
117{
118 u_int c, ret;
119 int error = 0;
120 void *random_buf;
121
122/* XXX Temporary ifndef to allow users to have a nonblocking device */
123#ifndef NOBLOCKRANDOM

--- 92 unchanged lines hidden ---