Sync usage with man page.
[netbsd-mini2440.git] / sys / rump / librump / rumpvfs / devnull.c
blobcbe8b5f5e6d5cd3d8337ed40d9608206e2de0afb
1 /* $NetBSD$ */
3 /*
4 * Copyright (c) 2009 Antti Kantee. All Rights Reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
16 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
29 * /dev/null, the infamous bytesink.
31 * I can't imagine it being very different in the rump kernel than in
32 * the host kernel. But nonetheless it serves as a simple example.
35 #include <sys/cdefs.h>
36 __KERNEL_RCSID(0, "$NetBSD$");
38 #include <sys/param.h>
39 #include <sys/conf.h>
40 #include <sys/device.h>
41 #include <sys/stat.h>
43 #include "rump_vfs_private.h"
45 static devmajor_t null_bmaj, null_cmaj;
47 static dev_type_open(rump_devnullopen);
48 static dev_type_read(rump_devnullrw);
50 static struct cdevsw null_cdevsw = {
51 rump_devnullopen, nullclose, rump_devnullrw, rump_devnullrw, noioctl,
52 nostop, notty, nopoll, nommap, nokqfilter, D_OTHER | D_MPSAFE,
55 int
56 rump_devnull_init()
58 int error;
60 null_bmaj = null_cmaj = NODEVMAJOR;
61 error = devsw_attach("null", NULL, &null_bmaj, &null_cdevsw,&null_cmaj);
62 if (error != 0)
63 return error;
65 return rump_vfs_makeonedevnode(S_IFCHR, "/dev/null", null_cmaj, 0);
68 static int
69 rump_devnullopen(dev_t dev, int flag, int mode, struct lwp *l)
72 return 0;
75 static int
76 rump_devnullrw(dev_t dev, struct uio *uio, int flags)
79 if (uio->uio_rw == UIO_WRITE)
80 uio->uio_resid = 0;
81 return 0;