Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/rump/librump support /dev/zero
details: https://anonhg.NetBSD.org/src/rev/3a21a637ea2b
branches: trunk
changeset: 761889:3a21a637ea2b
user: pooka <pooka%NetBSD.org@localhost>
date: Thu Feb 10 11:01:31 2011 +0000
description:
support /dev/zero
diffstat:
sys/rump/librump/rumpkern/devsw.c | 3 ++-
sys/rump/librump/rumpvfs/devnull.c | 34 +++++++++++++++++++++++++++++-----
2 files changed, 31 insertions(+), 6 deletions(-)
diffs (73 lines):
diff -r 2f27fbcd3c54 -r 3a21a637ea2b sys/rump/librump/rumpkern/devsw.c
--- a/sys/rump/librump/rumpkern/devsw.c Thu Feb 10 11:00:45 2011 +0000
+++ b/sys/rump/librump/rumpkern/devsw.c Thu Feb 10 11:01:31 2011 +0000
@@ -43,7 +43,8 @@
{ "rumpblk", 197, 197, DEVNODE_DONTBOTHER, 0, { 0, 0 }},
{ "cons", -1, 0, DEVNODE_DONTBOTHER, 0, { 0, 0 }},
{ "ctty", -1, 1, DEVNODE_DONTBOTHER, 0, { 0, 0 }},
- { "null", -1, 2, DEVNODE_SINGLE, 0, { 0, 0 }},
+ { "null", -1, 2, DEVNODE_SINGLE, DEVNODE_FLAG_ISMINOR0, { DEV_NULL,0 }},
+ { "zero", -1, 2, DEVNODE_SINGLE, DEVNODE_FLAG_ISMINOR0, { DEV_ZERO,0 }},
{ "wd", 0, 3, DEVNODE_VECTOR, 0, { 8, 8 }},
{ "swap", 1, 4, DEVNODE_DONTBOTHER, 0, { 0, 0 }},
{ "pts", -1, 5, DEVNODE_DONTBOTHER, 0, { 0, 0 }},
diff -r 2f27fbcd3c54 -r 3a21a637ea2b sys/rump/librump/rumpvfs/devnull.c
--- a/sys/rump/librump/rumpvfs/devnull.c Thu Feb 10 11:00:45 2011 +0000
+++ b/sys/rump/librump/rumpvfs/devnull.c Thu Feb 10 11:01:31 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: devnull.c,v 1.2 2010/07/07 10:47:39 pooka Exp $ */
+/* $NetBSD: devnull.c,v 1.3 2011/02/10 11:01:31 pooka Exp $ */
/*
* Copyright (c) 2009 Antti Kantee. All Rights Reserved.
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: devnull.c,v 1.2 2010/07/07 10:47:39 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: devnull.c,v 1.3 2011/02/10 11:01:31 pooka Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@@ -67,14 +67,38 @@
rump_devnullopen(dev_t dev, int flag, int mode, struct lwp *l)
{
- return 0;
+ if (minor(dev) == DEV_ZERO || minor(dev) == DEV_NULL)
+ return 0;
+ return ENXIO;
}
static int
rump_devnullrw(dev_t dev, struct uio *uio, int flags)
{
+ char zeros[512];
+ int error;
- if (uio->uio_rw == UIO_WRITE)
- uio->uio_resid = 0;
+ switch (minor(dev)) {
+ case DEV_NULL:
+ if (uio->uio_rw == UIO_WRITE)
+ uio->uio_resid = 0;
+ break;
+ case DEV_ZERO:
+ if (uio->uio_rw == UIO_WRITE) {
+ uio->uio_resid = 0;
+ break;
+ }
+ memset(zeros, 0, sizeof(zeros));
+ while (uio->uio_resid > 0) {
+ error = uiomove(zeros,
+ min(sizeof(zeros), uio->uio_resid), uio);
+ if (error)
+ return error;
+ }
+ break;
+ default:
+ return ENXIO; /* how? */
+ }
+
return 0;
}
Home |
Main Index |
Thread Index |
Old Index