Module Name: src Committed By: pooka Date: Thu Dec 17 00:29:46 UTC 2009
Modified Files: src/sys/rump/librump/rumpvfs: devnodes.c rump_vfs.c rump_vfs_private.h Added Files: src/sys/rump/librump/rumpvfs: devnull.c Log Message: * implement rump_vfs_makeonedevnode(), where the interface for creating multiple nodes doesn't make sense: e.g. /dev/null would've had to be created with ("/dev/nul", 'l', 1) * implement said /dev/null (just for show) To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/rump/librump/rumpvfs/devnodes.c cvs rdiff -u -r0 -r1.1 src/sys/rump/librump/rumpvfs/devnull.c cvs rdiff -u -r1.41 -r1.42 src/sys/rump/librump/rumpvfs/rump_vfs.c cvs rdiff -u -r1.9 -r1.10 src/sys/rump/librump/rumpvfs/rump_vfs_private.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/rump/librump/rumpvfs/devnodes.c diff -u src/sys/rump/librump/rumpvfs/devnodes.c:1.3 src/sys/rump/librump/rumpvfs/devnodes.c:1.4 --- src/sys/rump/librump/rumpvfs/devnodes.c:1.3 Thu Dec 3 15:28:49 2009 +++ src/sys/rump/librump/rumpvfs/devnodes.c Thu Dec 17 00:29:46 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: devnodes.c,v 1.3 2009/12/03 15:28:49 tron Exp $ */ +/* $NetBSD: devnodes.c,v 1.4 2009/12/17 00:29:46 pooka Exp $ */ /* * Copyright (c) 2009 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: devnodes.c,v 1.3 2009/12/03 15:28:49 tron Exp $"); +__KERNEL_RCSID(0, "$NetBSD: devnodes.c,v 1.4 2009/12/17 00:29:46 pooka Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -40,6 +40,16 @@ /* realqvik(tm) "devfs" */ int +rump_vfs_makeonedevnode(dev_t devtype, const char *devname, + devmajor_t majnum, devminor_t minnum) +{ + register_t retval; + + return do_sys_mknod(curlwp, devname, 0666 | devtype, + makedev(majnum, minnum), &retval, UIO_SYSSPACE); +} + +int rump_vfs_makedevnodes(dev_t devtype, const char *basename, char minchar, devmajor_t maj, devminor_t minnum, int nnodes) { Index: src/sys/rump/librump/rumpvfs/rump_vfs.c diff -u src/sys/rump/librump/rumpvfs/rump_vfs.c:1.41 src/sys/rump/librump/rumpvfs/rump_vfs.c:1.42 --- src/sys/rump/librump/rumpvfs/rump_vfs.c:1.41 Thu Dec 3 15:06:04 2009 +++ src/sys/rump/librump/rumpvfs/rump_vfs.c Thu Dec 17 00:29:46 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: rump_vfs.c,v 1.41 2009/12/03 15:06:04 pooka Exp $ */ +/* $NetBSD: rump_vfs.c,v 1.42 2009/12/17 00:29:46 pooka Exp $ */ /* * Copyright (c) 2008 Antti Kantee. All Rights Reserved. @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rump_vfs.c,v 1.41 2009/12/03 15:06:04 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rump_vfs.c,v 1.42 2009/12/17 00:29:46 pooka Exp $"); #include <sys/param.h> #include <sys/buf.h> @@ -121,6 +121,7 @@ /* "mtree": create /dev */ do_sys_mkdir("/dev", 0777, UIO_SYSSPACE); + rump_devnull_init(); rump_proc_vfs_init = pvfs_init; rump_proc_vfs_release = pvfs_rele; Index: src/sys/rump/librump/rumpvfs/rump_vfs_private.h diff -u src/sys/rump/librump/rumpvfs/rump_vfs_private.h:1.9 src/sys/rump/librump/rumpvfs/rump_vfs_private.h:1.10 --- src/sys/rump/librump/rumpvfs/rump_vfs_private.h:1.9 Thu Dec 3 12:35:35 2009 +++ src/sys/rump/librump/rumpvfs/rump_vfs_private.h Thu Dec 17 00:29:46 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: rump_vfs_private.h,v 1.9 2009/12/03 12:35:35 pooka Exp $ */ +/* $NetBSD: rump_vfs_private.h,v 1.10 2009/12/17 00:29:46 pooka Exp $ */ /* * Copyright (c) 2008 Antti Kantee. All Rights Reserved. @@ -35,6 +35,8 @@ void rumpfs_init(void); +int rump_devnull_init(void); + #define RUMPBLK 254 #define RUMPBLK_SIZENOTSET ((uint64_t)-1) int rumpblk_register(const char *, devminor_t *, uint64_t, uint64_t); @@ -42,6 +44,7 @@ void rump_biodone(void *, size_t, int); +int rump_vfs_makeonedevnode(dev_t, const char *, devmajor_t, devminor_t); int rump_vfs_makedevnodes(dev_t, const char *, char, devmajor_t, devminor_t, int); Added files: Index: src/sys/rump/librump/rumpvfs/devnull.c diff -u /dev/null src/sys/rump/librump/rumpvfs/devnull.c:1.1 --- /dev/null Thu Dec 17 00:29:46 2009 +++ src/sys/rump/librump/rumpvfs/devnull.c Thu Dec 17 00:29:46 2009 @@ -0,0 +1,82 @@ +/* $NetBSD: devnull.c,v 1.1 2009/12/17 00:29:46 pooka Exp $ */ + +/* + * Copyright (c) 2009 Antti Kantee. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * /dev/null, the infamous bytesink. + * + * I can't imagine it being very different in the rump kernel than in + * the host kernel. But nonetheless it serves as a simple example. + */ + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: devnull.c,v 1.1 2009/12/17 00:29:46 pooka Exp $"); + +#include <sys/param.h> +#include <sys/conf.h> +#include <sys/device.h> +#include <sys/stat.h> + +#include "rump_vfs_private.h" + +static devmajor_t null_bmaj, null_cmaj; + +static dev_type_open(rump_devnullopen); +static dev_type_read(rump_devnullrw); + +static struct cdevsw null_cdevsw = { + rump_devnullopen, nullclose, rump_devnullrw, rump_devnullrw, noioctl, + nostop, notty, nopoll, nommap, nokqfilter, D_OTHER | D_MPSAFE, +}; + +int +rump_devnull_init() +{ + int error; + + null_bmaj = null_cmaj = NODEVMAJOR; + error = devsw_attach("null", NULL, &null_bmaj, &null_cdevsw,&null_cmaj); + if (error != 0) + return error; + + return rump_vfs_makeonedevnode(S_IFCHR, "/dev/null", null_cmaj, 0); +} + +static int +rump_devnullopen(dev_t dev, int flag, int mode, struct lwp *l) +{ + + return 0; +} + +static int +rump_devnullrw(dev_t dev, struct uio *uio, int flags) +{ + + if (uio->uio_rw == UIO_WRITE) + uio->uio_resid = 0; + return 0; +}