kern/68961: [PATCH] Implement /dev/full
| From: | Robert Millan <rmh@debian.org> |
| Date: | Mon, 12 Jul 2004 23:24:20 +0200 |
| Subject: | [PATCH] Implement /dev/full |
| Send-pr version: | 3.113 |
| Number: | 68961 |
| Category: | kern |
| Synopsis: | [PATCH] Implement /dev/full |
| Severity: | non-critical |
| Priority: | low |
| Responsible: | markm@FreeBSD.org |
| State: | closed |
| Class: | change-request |
| Arrival-Date: | Mon Jul 12 21:30:22 GMT 2004 |
| Closed-Date: | Mon Mar 28 12:59:16 GMT 2005 |
| Last-Modified: | Sat Sep 26 12:50:00 UTC 2009 |
| Originator: | Robert Millan |
| Release: | FreeBSD 5.2.1 |
| Organization: |
Debian
| Environment: |
System: GNU/Linux aragorn 2.4.26-1-k7 #1 Sat May 1 21:40:09 EST 2004 i686
Architecture: i686
Architecture: i686
| Description: |
This patch implements /dev/full, a device that returns ENOSPC when
attempting to write on it. It is commonly used on other Un*x OSes
(e.g. GNU/Linux) and some applications assume it is present.
Note: I'm the maintainer of the Debian package "kfreebsd5" (kernel
of FreeBSD 5.x). I have made some changes to the kernel for portability
and some improvements, and I'll be forwarding more patches in the
future.
attempting to write on it. It is commonly used on other Un*x OSes
(e.g. GNU/Linux) and some applications assume it is present.
Note: I'm the maintainer of the Debian package "kfreebsd5" (kernel
of FreeBSD 5.x). I have made some changes to the kernel for portability
and some improvements, and I'll be forwarding more patches in the
future.
| How-To-Repeat: |
| Fix: |
I don't know the policy for assigning minor numbers, so I just defined
FULL_MINOR as 3 which apparently is free. Let me know if I missed something.
--- src/sys/dev/null/null.c.old 2004-07-12 20:20:37.000000000 +0200
+++ src/sys/dev/null/null.c 2004-07-12 20:27:10.000000000 +0200
@@ -41,14 +41,17 @@
/* For use with destroy_dev(9). */
static dev_t null_dev;
+static dev_t full_dev;
static dev_t zero_dev;
static d_write_t null_write;
+static d_write_t full_write;
static d_ioctl_t null_ioctl;
static d_read_t zero_read;
#define CDEV_MAJOR 2
#define NULL_MINOR 2
+#define FULL_MINOR 3
#define ZERO_MINOR 12
static struct cdevsw null_cdevsw = {
@@ -60,6 +63,15 @@
.d_flags = D_NOGIANT,
};
+static struct cdevsw full_cdevsw = {
+ .d_read = (d_read_t *)nullop,
+ .d_write = full_write,
+ .d_ioctl = null_ioctl,
+ .d_name = "full",
+ .d_maj = CDEV_MAJOR,
+ .d_flags = D_NOGIANT,
+};
+
static struct cdevsw zero_cdevsw = {
.d_read = zero_read,
.d_write = null_write,
@@ -80,6 +92,14 @@
/* ARGSUSED */
static int
+full_write(dev_t dev __unused, struct uio *uio, int flags __unused)
+{
+ uio->uio_resid = 0;
+ return (ENOSPC);
+}
+
+/* ARGSUSED */
+static int
null_ioctl(dev_t dev __unused, u_long cmd, caddr_t data __unused,
int flags __unused, struct thread *td)
{
@@ -120,10 +140,13 @@
GID_WHEEL, 0666, "zero");
null_dev = make_dev(&null_cdevsw, NULL_MINOR, UID_ROOT,
GID_WHEEL, 0666, "null");
+ full_dev = make_dev(&full_cdevsw, FULL_MINOR, UID_ROOT,
+ GID_WHEEL, 0666, "full");
return 0;
case MOD_UNLOAD:
destroy_dev(null_dev);
+ destroy_dev(full_dev);
destroy_dev(zero_dev);
free(zbuf, M_TEMP);
return 0;
FULL_MINOR as 3 which apparently is free. Let me know if I missed something.
--- src/sys/dev/null/null.c.old 2004-07-12 20:20:37.000000000 +0200
+++ src/sys/dev/null/null.c 2004-07-12 20:27:10.000000000 +0200
@@ -41,14 +41,17 @@
/* For use with destroy_dev(9). */
static dev_t null_dev;
+static dev_t full_dev;
static dev_t zero_dev;
static d_write_t null_write;
+static d_write_t full_write;
static d_ioctl_t null_ioctl;
static d_read_t zero_read;
#define CDEV_MAJOR 2
#define NULL_MINOR 2
+#define FULL_MINOR 3
#define ZERO_MINOR 12
static struct cdevsw null_cdevsw = {
@@ -60,6 +63,15 @@
.d_flags = D_NOGIANT,
};
+static struct cdevsw full_cdevsw = {
+ .d_read = (d_read_t *)nullop,
+ .d_write = full_write,
+ .d_ioctl = null_ioctl,
+ .d_name = "full",
+ .d_maj = CDEV_MAJOR,
+ .d_flags = D_NOGIANT,
+};
+
static struct cdevsw zero_cdevsw = {
.d_read = zero_read,
.d_write = null_write,
@@ -80,6 +92,14 @@
/* ARGSUSED */
static int
+full_write(dev_t dev __unused, struct uio *uio, int flags __unused)
+{
+ uio->uio_resid = 0;
+ return (ENOSPC);
+}
+
+/* ARGSUSED */
+static int
null_ioctl(dev_t dev __unused, u_long cmd, caddr_t data __unused,
int flags __unused, struct thread *td)
{
@@ -120,10 +140,13 @@
GID_WHEEL, 0666, "zero");
null_dev = make_dev(&null_cdevsw, NULL_MINOR, UID_ROOT,
GID_WHEEL, 0666, "null");
+ full_dev = make_dev(&full_cdevsw, FULL_MINOR, UID_ROOT,
+ GID_WHEEL, 0666, "full");
return 0;
case MOD_UNLOAD:
destroy_dev(null_dev);
+ destroy_dev(full_dev);
destroy_dev(zero_dev);
free(zbuf, M_TEMP);
return 0;
| Release-Note: |
| Audit-Trail: |
| Reply via E-mail | |
| From: | "David O'Brien" <obrien@FreeBSD.org> |
| Date: | Sat, 17 Jul 2004 20:14:51 -0700 |
|
I just don't see the point in /dev/full. Could you please give some good examples of its use? Also what "Un*x OSes" besides Linux has this? -- -- David (obrien@FreeBSD.org) | |
| State Changed | |
| From-To: | open->feedback |
| By: | markm |
| When: | Sun Aug 1 18:19:30 GMT 2004 |
| Why: | Could I please ask you to re-implement this as part of the Linux emulator? The only OS that we seem to be able to find that uses this is Linux, so it makes most sense to add it to the Linux compatibility layer. |
| Responsible Changed | |
| From-To: | freebsd-bugs->markm |
| By: | markm |
| When: | Sun Aug 1 18:19:30 GMT 2004 |
| Why: | Could I please ask you to re-implement this as part of the Linux emulator? The only OS that we seem to be able to find that uses this is Linux, so it makes most sense to add it to the Linux compatibility layer. |
| State Changed | |
| From-To: | feedback->closed |
| By: | markm |
| When: | Mon Mar 28 12:57:11 GMT 2005 |
| Why: | It has been agreed/decided by the kernel architect gurus that this is not a good idea right now. Sorry! |
| Reply via E-mail | |||
| From: | Robert Millan <rmh@aybabtu.com> | ||
| Date: | Mon, 20 Feb 2006 10:54:22 +0100 | ||
|
Hi! I've re-implemented /dev/full as part of the Linux compatibility module as requested. Please could you consider the attached patch? -- Robert Millan --- sys/modules/linux/Makefile~ 2006-02-19 19:53:06.000000000 +0100 +++ sys/modules/linux/Makefile 2006-02-19 20:43:55.000000000 +0100 @@ -3,7 +3,7 @@ .PATH: ${.CURDIR}/../../compat/linux ${.CURDIR}/../../${MACHINE_ARCH}/linux KMOD= linux -SRCS= linux_dummy.c linux_file.c linux_getcwd.c linux_ioctl.c linux_ipc.c \ +SRCS= linux_dummy.c linux_file.c linux_full.c linux_getcwd.c linux_ioctl.c linux_ipc.c \ linux_machdep.c linux_mib.c linux_misc.c linux_signal.c linux_socket.c \ linux_stats.c linux_sysctl.c linux_sysent.c linux_sysvec.c \ linux_util.c opt_compat.h opt_inet6.h opt_mac.h \
| |||
| Reply via E-mail | |||
| From: | dfilter@FreeBSD.ORG (dfilter service) | ||
| Date: | Sat, 26 Sep 2009 12:45:38 +0000 (UTC) | ||
|
Author: bz Date: Sat Sep 26 12:45:28 2009 New Revision: 197518 URL: http://svn.freebsd.org/changeset/base/197518 Log: lindev(4) [1] is supposed to be a collection of linux-specific pseudo devices that we also support, just not by default (thus only LINT or module builds by default). While currently there is only "/dev/full" [2], we are planning to see more in the future. We may decide to change the module/dependency logic in the future should the list grow too long. This is not part of linux.ko as also non-linux binaries like kFreeBSD userland or ports can make use of this as well. Suggested by: rwatson [1] (name) Submitted by: ed [2] Discussed with: markm, ed, rwatson, kib (weeks ago) Reviewed by: rwatson, brueffer (prev. version) PR: kern/68961 MFC after: 6 weeks Added: head/share/man/man4/lindev.4 (contents, props changed) head/sys/dev/lindev/ head/sys/dev/lindev/full.c (contents, props changed) head/sys/dev/lindev/lindev.c (contents, props changed) head/sys/dev/lindev/lindev.h (contents, props changed) head/sys/modules/lindev/ head/sys/modules/lindev/Makefile (contents, props changed) Modified: head/share/man/man4/Makefile head/sys/amd64/conf/NOTES head/sys/boot/forth/loader.conf head/sys/conf/files.amd64 head/sys/conf/files.i386 head/sys/conf/files.pc98 head/sys/i386/conf/NOTES head/sys/modules/Makefile head/sys/pc98/conf/NOTES Modified: head/share/man/man4/Makefile ==============================================================================
| |||
| Unformatted: |
