Deleted Added
full compact
null.c (74810) null.c (93496)
1/*-
2 * Copyright (c) 2000 Mark R. V. Murray & Jeroen C. van Gelderen
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 & Jeroen C. van Gelderen
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/null/null.c 74810 2001-03-26 12:41:29Z phk $
26 * $FreeBSD: head/sys/dev/null/null.c 93496 2002-03-31 22:37:00Z phk $
27 */
28
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/conf.h>
32#include <sys/uio.h>
33#include <sys/kernel.h>
34#include <sys/malloc.h>
35#include <sys/module.h>
27 */
28
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/conf.h>
32#include <sys/uio.h>
33#include <sys/kernel.h>
34#include <sys/malloc.h>
35#include <sys/module.h>
36#include <sys/disklabel.h>
36#include <sys/bus.h>
37#include <machine/bus.h>
38#include <machine/resource.h>
39#include <sys/rman.h>
40
41/* For use with destroy_dev(9). */
42static dev_t null_dev;
43static dev_t zero_dev;
44
45static d_write_t null_write;
37#include <sys/bus.h>
38#include <machine/bus.h>
39#include <machine/resource.h>
40#include <sys/rman.h>
41
42/* For use with destroy_dev(9). */
43static dev_t null_dev;
44static dev_t zero_dev;
45
46static d_write_t null_write;
47static d_ioctl_t null_ioctl;
46static d_read_t zero_read;
47
48#define CDEV_MAJOR 2
49#define NULL_MINOR 2
50#define ZERO_MINOR 12
51
52static struct cdevsw null_cdevsw = {
53 /* open */ (d_open_t *)nullop,
54 /* close */ (d_close_t *)nullop,
55 /* read */ (d_read_t *)nullop,
56 /* write */ null_write,
48static d_read_t zero_read;
49
50#define CDEV_MAJOR 2
51#define NULL_MINOR 2
52#define ZERO_MINOR 12
53
54static struct cdevsw null_cdevsw = {
55 /* open */ (d_open_t *)nullop,
56 /* close */ (d_close_t *)nullop,
57 /* read */ (d_read_t *)nullop,
58 /* write */ null_write,
57 /* ioctl */ noioctl,
59 /* ioctl */ null_ioctl,
58 /* poll */ nopoll,
59 /* mmap */ nommap,
60 /* strategy */ nostrategy,
61 /* name */ "null",
62 /* maj */ CDEV_MAJOR,
63 /* dump */ nodump,
64 /* psize */ nopsize,
65 /* flags */ 0,

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

86static int
87null_write(dev_t dev, struct uio *uio, int flag)
88{
89 uio->uio_resid = 0;
90 return 0;
91}
92
93static int
60 /* poll */ nopoll,
61 /* mmap */ nommap,
62 /* strategy */ nostrategy,
63 /* name */ "null",
64 /* maj */ CDEV_MAJOR,
65 /* dump */ nodump,
66 /* psize */ nopsize,
67 /* flags */ 0,

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

88static int
89null_write(dev_t dev, struct uio *uio, int flag)
90{
91 uio->uio_resid = 0;
92 return 0;
93}
94
95static int
96null_ioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct thread *td)
97{
98 int error;
99
100 if (cmd != DIOCGKERNELDUMP)
101 return (noioctl(dev, cmd, data, fflag, td));
102 error = suser_td(td);
103 if (error)
104 return (error);
105 return (set_dumper(NULL));
106}
107
108
109static int
94zero_read(dev_t dev, struct uio *uio, int flag)
95{
96 u_int c;
97 int error = 0;
98
99 while (uio->uio_resid > 0 && error == 0) {
100 c = min(uio->uio_resid, PAGE_SIZE);
101 error = uiomove(zbuf, c, uio);

--- 33 unchanged lines hidden ---
110zero_read(dev_t dev, struct uio *uio, int flag)
111{
112 u_int c;
113 int error = 0;
114
115 while (uio->uio_resid > 0 && error == 0) {
116 c = min(uio->uio_resid, PAGE_SIZE);
117 error = uiomove(zbuf, c, uio);

--- 33 unchanged lines hidden ---