Date: Wed, 30 Apr 2014 06:20:48 +0000 (UTC) From: Eitan Adler <eadler@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r265132 - in head: share/man/man4 sys/dev/null Message-ID: <201404300620.s3U6Kmn6074492@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: eadler Date: Wed Apr 30 06:20:48 2014 New Revision: 265132 URL: http://svnweb.freebsd.org/changeset/base/265132 Log: Add a /dev/full device. /dev/full is similar to /dev/zero except it always returns ENOSPC when you attempt to write to it. Reviewed by: jhibbits Discussed with: rpaulo Added: head/share/man/man4/full.4 (contents, props changed) Modified: head/share/man/man4/null.4 head/share/man/man4/zero.4 head/sys/dev/null/null.c Added: head/share/man/man4/full.4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/man/man4/full.4 Wed Apr 30 06:20:48 2014 (r265132) @@ -0,0 +1,47 @@ +.\" Copyright (c) 2014 +.\" Eitan Adler <eadler@FreeBSD.org>. 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 AND CONTRIBUTORS ``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. +.\" +.\" $FreeBSD$ +.\" +.Dd March 29, 2014 +.Dt FULL 4 +.Os +.Sh NAME +.Nm full +.Nd the full device +.Sh DESCRIPTION +The +.Nm +device supplies an endless stream of zeros when read. +However, it will always be full when writing to it. +.Sh FILES +.Bl -tag -width /dev/full +.It Pa /dev/full +.El +.Sh SEE ALSO +.Xr null 4 +.Xr zero 4 +.Sh Author +This device and man page was written by +.An Eitan Adler Aq eadler@FreeBSD.org . Modified: head/share/man/man4/null.4 ============================================================================== --- head/share/man/man4/null.4 Wed Apr 30 06:03:01 2014 (r265131) +++ head/share/man/man4/null.4 Wed Apr 30 06:20:48 2014 (r265132) @@ -48,6 +48,7 @@ device is always zero. .It Pa /dev/null .El .Sh SEE ALSO +.Xr full 4 .Xr zero 4 .Sh HISTORY A Modified: head/share/man/man4/zero.4 ============================================================================== --- head/share/man/man4/zero.4 Wed Apr 30 06:03:01 2014 (r265131) +++ head/share/man/man4/zero.4 Wed Apr 30 06:20:48 2014 (r265132) @@ -49,6 +49,7 @@ supply of null bytes when read. .It Pa /dev/zero .El .Sh SEE ALSO +.Xr full 4 .Xr null 4 .Sh HISTORY A Modified: head/sys/dev/null/null.c ============================================================================== --- head/sys/dev/null/null.c Wed Apr 30 06:03:01 2014 (r265131) +++ head/sys/dev/null/null.c Wed Apr 30 06:20:48 2014 (r265132) @@ -1,6 +1,7 @@ /*- * Copyright (c) 2000 Mark R. V. Murray & Jeroen C. van Gelderen * Copyright (c) 2001-2004 Mark R. V. Murray + * Copyright (c) 2014 Eitan Adler * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -47,7 +48,9 @@ __FBSDID("$FreeBSD$"); /* For use with destroy_dev(9). */ static struct cdev *null_dev; static struct cdev *zero_dev; +static struct cdev *full_dev; +static d_write_t full_write; static d_write_t null_write; static d_ioctl_t null_ioctl; static d_ioctl_t zero_ioctl; @@ -70,6 +73,23 @@ static struct cdevsw zero_cdevsw = { .d_flags = D_MMAP_ANON, }; +static struct cdevsw full_cdevsw = { + .d_version = D_VERSION, + .d_read = zero_read, + .d_write = full_write, + .d_ioctl = zero_ioctl, + .d_name = "full", +}; + + +/* ARGSUSED */ +static int +full_write(struct cdev *dev __unused, struct uio *uio, int flags __unused) +{ + + return (ENOSPC); +} + /* ARGSUSED */ static int null_write(struct cdev *dev __unused, struct uio *uio, int flags __unused) @@ -155,7 +175,9 @@ null_modevent(module_t mod __unused, int switch(type) { case MOD_LOAD: if (bootverbose) - printf("null: <null device, zero device>\n"); + printf("null: <full device, null device, zero device>\n"); + full_dev = make_dev_credf(MAKEDEV_ETERNAL_KLD, &full_cdevsw, 0, + NULL, UID_ROOT, GID_WHEEL, 0666, "full"); null_dev = make_dev_credf(MAKEDEV_ETERNAL_KLD, &null_cdevsw, 0, NULL, UID_ROOT, GID_WHEEL, 0666, "null"); zero_dev = make_dev_credf(MAKEDEV_ETERNAL_KLD, &zero_cdevsw, 0, @@ -163,6 +185,7 @@ null_modevent(module_t mod __unused, int break; case MOD_UNLOAD: + destroy_dev(full_dev); destroy_dev(null_dev); destroy_dev(zero_dev); break;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201404300620.s3U6Kmn6074492>