Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/rump/librump/rumpvfs * implement rump_vfs_makeonedevnode...
details: https://anonhg.NetBSD.org/src/rev/1662bb4d64bd
branches: trunk
changeset: 750108:1662bb4d64bd
user: pooka <pooka%NetBSD.org@localhost>
date: Thu Dec 17 00:29:46 2009 +0000
description:
* 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)
diffstat:
sys/rump/librump/rumpvfs/devnodes.c | 14 ++++-
sys/rump/librump/rumpvfs/devnull.c | 82 +++++++++++++++++++++++++++++
sys/rump/librump/rumpvfs/rump_vfs.c | 5 +-
sys/rump/librump/rumpvfs/rump_vfs_private.h | 5 +-
4 files changed, 101 insertions(+), 5 deletions(-)
diffs (173 lines):
diff -r 782addd19938 -r 1662bb4d64bd sys/rump/librump/rumpvfs/devnodes.c
--- a/sys/rump/librump/rumpvfs/devnodes.c Wed Dec 16 23:19:06 2009 +0000
+++ b/sys/rump/librump/rumpvfs/devnodes.c Thu Dec 17 00:29:46 2009 +0000
@@ -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)
{
diff -r 782addd19938 -r 1662bb4d64bd sys/rump/librump/rumpvfs/devnull.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/rump/librump/rumpvfs/devnull.c Thu Dec 17 00:29:46 2009 +0000
@@ -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;
+}
diff -r 782addd19938 -r 1662bb4d64bd sys/rump/librump/rumpvfs/rump_vfs.c
--- a/sys/rump/librump/rumpvfs/rump_vfs.c Wed Dec 16 23:19:06 2009 +0000
+++ b/sys/rump/librump/rumpvfs/rump_vfs.c Thu Dec 17 00:29:46 2009 +0000
@@ -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;
diff -r 782addd19938 -r 1662bb4d64bd sys/rump/librump/rumpvfs/rump_vfs_private.h
--- a/sys/rump/librump/rumpvfs/rump_vfs_private.h Wed Dec 16 23:19:06 2009 +0000
+++ b/sys/rump/librump/rumpvfs/rump_vfs_private.h Thu Dec 17 00:29:46 2009 +0000
@@ -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);
Home |
Main Index |
Thread Index |
Old Index