Skip site navigation (1)Skip section navigation (2)

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
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.
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;
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 \
Download patch-1.diff
diff -Nur sys/compat/linux.old/linux_full.c sys/compat/linux/linux_full.c
--- sys/compat/linux.old/linux_full.c    1970-01-01 01:00:00.000000000 +0100
+++ sys/compat/linux/linux_full.c        2006-02-20 08:00:28.000000000 +0100
@@ -0,0 +1,114 @@
+/*-
+ * Copyright (c) 2000 Mark R. V. Murray & Jeroen C. van Gelderen
+ * Copyright (c) 2001-2004 Mark R. V. Murray
+ * 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
+ *    in this position and unchanged.
+ * 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 AUTHORS ``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 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.
+ *
+ */
+
+#include <sys/cdefs.h>
+
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/uio.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/module.h>
+#include <sys/disk.h>
+#include <sys/bus.h>
+#include <machine/bus.h>
+
+/* For use with destroy_dev(9). */
+static struct cdev *full_dev;
+
+static d_write_t full_write;
+static d_ioctl_t full_ioctl;
+
+#define FULL_MINOR      3
+
+static struct cdevsw full_cdevsw = {
+        .d_version =    D_VERSION,
+        .d_read =       (d_read_t *)nullop,
+        .d_write =      full_write,
+        .d_ioctl =      full_ioctl,
+        .d_name =       "full",
+};
+
+static void *zbuf;
+
+/* ARGSUSED */
+static int
+full_write(struct cdev *dev __unused, struct uio *uio, int flags __unused)
+{
+        uio->uio_resid = 0;
+
+        return (ENOSPC);
+}
+
+/* ARGSUSED */
+static int
+full_ioctl(struct cdev *dev __unused, u_long cmd, caddr_t data __unused,
+    int flags __unused, struct thread *td)
+{
+        int error;
+
+        if (cmd != DIOCSKERNELDUMP)
+                return (ENOIOCTL);
+        error = suser(td);
+        if (error)
+                return (error);
+        return (set_dumper(NULL));
+}
+
+/* ARGSUSED */
+static int
+full_modevent(module_t mod __unused, int type, void *data __unused)
+{
+        switch(type) {
+        case MOD_LOAD:
+                if (bootverbose)
+                        printf("full: <full device>\n");
+                zbuf = (void *)malloc(PAGE_SIZE, M_TEMP, M_WAITOK | M_ZERO);
+                full_dev = make_dev(&full_cdevsw, FULL_MINOR, UID_ROOT,
+                        GID_WHEEL, 0666, "full");
+                break;
+
+        case MOD_UNLOAD:
+                destroy_dev(full_dev);
+                free(zbuf, M_TEMP);
+                break;
+
+        case MOD_SHUTDOWN:
+                break;
+
+        default:
+                return (EOPNOTSUPP);
+        }
+
+        return (0);
+}
+
+DEV_MODULE(full, full_modevent, NULL);
+MODULE_VERSION(full, 1);




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
==============================================================================
Download patch-2.diff
--- head/share/man/man4/Makefile Sat Sep 26 11:44:04 2009        (r197517)
+++ head/share/man/man4/Makefile Sat Sep 26 12:45:28 2009        (r197518)
@@ -173,6 +173,7 @@ MAN= aac.4 \
         le.4 \
         led.4 \
         lge.4 \
+        ${_lindev.4} \
         ${_linux.4} \
         lmc.4 \
         lo.4 \
@@ -625,6 +626,7 @@ _if_urtw.4=  if_urtw.4
 _if_wpi.4=      if_wpi.4
 _ipmi.4=        ipmi.4
 _io.4=          io.4
+_lindev.4=      lindev.4
 _linux.4=       linux.4
 _ndis.4=        ndis.4
 _nfe.4=         nfe.4
@@ -636,6 +638,8 @@ _speaker.4=  speaker.4
 _spkr.4=        spkr.4
 _urtw.4=        urtw.4
 _wpi.4=         wpi.4
+
+MLINKS+=lindev.4 full.4
 .endif
 
 .if exists(${.CURDIR}/man4.${MACHINE_ARCH})
Added: head/share/man/man4/lindev.4

==============================================================================
--- /dev/null    00:00:00 1970   (empty, because file is newly added)
+++ head/share/man/man4/lindev.4 Sat Sep 26 12:45:28 2009        (r197518)
@@ -0,0 +1,73 @@
+.\"-
+.\" Copyright (c) 2009 "Bjoern A. Zeeb" <bz@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 September 26, 2009
+.Dt LINDEV 4
+.Os
+.Sh NAME
+.Nm lindev
+.Nd the lindev module
+.Sh SYNOPSIS
+To compile this collection of linux-specific pseudo devices into the kernel,
+place the following line in your kernel configuration file:
+.Bd -ragged -offset indent
+.Cd "device lindev"
+.Ed
+.Pp
+Alternatively, to load the driver as a module at boot time,
+place the following line in
+.Xr loader.conf 5 :
+.Bd -literal -offset indent
+lindev_load="YES"
+.Ed
+.Sh DESCRIPTION
+The
+.Nm
+module provides a collection of linux-specific pseudo devices.
+.Sh DEVICES
+.Bl -tag -width /dev/full
+.It Pa /dev/full
+The
+.Xr full
+device always returns
+.Er ENOSPC
+on write attempts.
+For reads it emulates
+.Xr zero 4 .
+.El
+.Sh FILES
+.Bl -tag -width /dev/full
+.It Pa /dev/full
+.El
+.Sh SEE ALSO
+.Xr null 4 ,
+.Xr zero 4
+.Sh HISTORY
+The
+.Nm
+module first appeared in
+.Fx 9.0 .
Modified: head/sys/amd64/conf/NOTES

==============================================================================
--- head/sys/amd64/conf/NOTES    Sat Sep 26 11:44:04 2009        (r197517)
+++ head/sys/amd64/conf/NOTES    Sat Sep 26 12:45:28 2009        (r197518)
@@ -517,3 +517,6 @@ options      VM_KMEM_SIZE_SCALE
 # Enable NDIS binary driver support
 options         NDISAPI
 device          ndis
+
+# Linux-specific pseudo devices support
+device          lindev
Modified: head/sys/boot/forth/loader.conf

==============================================================================
--- head/sys/boot/forth/loader.conf      Sat Sep 26 11:44:04 2009        (r197517)
+++ head/sys/boot/forth/loader.conf      Sat Sep 26 12:45:28 2009        (r197518)
@@ -179,6 +179,7 @@ screensave_name="green_saver"        # Set to t
 ibcs2_load="NO"                 # IBCS2 (SCO) emulation
 ibcs2_coff_load="NO"
 linux_load="NO"                 # Linux emulation
+lindev_load="NO"                # Linux-specific pseudo devices (see lindev(4))
 svr4_load="NO"                  # SystemV R4 emulation
 streams_load="NO"               # System V streams module
 
Modified: head/sys/conf/files.amd64

==============================================================================
--- head/sys/conf/files.amd64    Sat Sep 26 11:44:04 2009        (r197517)
+++ head/sys/conf/files.amd64    Sat Sep 26 12:45:28 2009        (r197518)
@@ -208,6 +208,8 @@ dev/hwpmc/hwpmc_piv.c                optional        hwpmc
 dev/hwpmc/hwpmc_tsc.c           optional        hwpmc
 dev/hwpmc/hwpmc_x86.c           optional        hwpmc
 dev/kbd/kbd.c                   optional        atkbd | sc | ukbd | usb2_input_kbd
+dev/lindev/full.c               optional        lindev
+dev/lindev/lindev.c             optional        lindev
 dev/mem/memutil.c               optional        mem
 dev/nfe/if_nfe.c                optional        nfe pci
 dev/nve/if_nve.c                optional        nve pci
Modified: head/sys/conf/files.i386

==============================================================================
--- head/sys/conf/files.i386     Sat Sep 26 11:44:04 2009        (r197517)
+++ head/sys/conf/files.i386     Sat Sep 26 12:45:28 2009        (r197518)
@@ -201,6 +201,8 @@ dev/ipmi/ipmi_pci.c          optional ipmi pci
 dev/ipmi/ipmi_linux.c           optional ipmi compat_linux
 dev/kbd/kbd.c                   optional atkbd | sc | ukbd | usb2_input_kbd
 dev/le/if_le_isa.c              optional le isa
+dev/lindev/full.c               optional lindev
+dev/lindev/lindev.c             optional lindev
 dev/mem/memutil.c               optional mem
 dev/mse/mse.c                   optional mse
 dev/mse/mse_isa.c               optional mse isa
Modified: head/sys/conf/files.pc98

==============================================================================
--- head/sys/conf/files.pc98     Sat Sep 26 11:44:04 2009        (r197517)
+++ head/sys/conf/files.pc98     Sat Sep 26 12:45:28 2009        (r197518)
@@ -107,6 +107,8 @@ dev/hwpmc/hwpmc_x86.c                optional hwpmc
 dev/io/iodev.c                  optional io
 dev/kbd/kbd.c                   optional pckbd | sc | ukbd | usb2_input_kbd
 dev/le/if_le_cbus.c             optional le isa
+dev/lindev/full.c               optional lindev
+dev/lindev/lindev.c             optional lindev
 dev/mem/memutil.c               optional mem
 dev/mse/mse.c                   optional mse
 dev/mse/mse_cbus.c              optional mse isa
Added: head/sys/dev/lindev/full.c

==============================================================================
--- /dev/null    00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/lindev/full.c   Sat Sep 26 12:45:28 2009        (r197518)
@@ -0,0 +1,103 @@
+/*-
+ * Copyright (c) 2009 Ed Schouten <ed@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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/conf.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/module.h>
+#include <sys/systm.h>
+#include <sys/uio.h>
+
+#include <dev/lindev/lindev.h>
+
+static struct cdev *full_dev;
+
+static d_read_t full_read;
+static d_write_t full_write;
+
+static struct cdevsw full_cdevsw = {
+        .d_version =    D_VERSION,
+        .d_read =       full_read,
+        .d_write =      full_write,
+        .d_name =       "full",
+};
+
+static void *zbuf;
+
+/* ARGSUSED */
+static int
+full_read(struct cdev *dev __unused, struct uio *uio, int flags __unused)
+{
+        int error = 0;
+
+        while (uio->uio_resid > 0 && error == 0)
+                error = uiomove(zbuf, MIN(uio->uio_resid, PAGE_SIZE), uio);
+
+        return (error);
+}
+
+/* ARGSUSED */
+static int
+full_write(struct cdev *dev __unused, struct uio *uio __unused,
+    int flags __unused)
+{
+
+        return (ENOSPC);
+}
+
+/* ARGSUSED */
+int
+lindev_modevent_full(module_t mod __unused, int type, void *data __unused)
+{
+
+        switch(type) {
+        case MOD_LOAD:
+                zbuf = (void *)malloc(PAGE_SIZE, M_TEMP, M_WAITOK | M_ZERO);
+                full_dev = make_dev(&full_cdevsw, 0, UID_ROOT, GID_WHEEL,
+                    0666, "full");
+                if (bootverbose)
+                        printf("full: <full device>\n");
+                break;
+
+        case MOD_UNLOAD:
+                destroy_dev(full_dev);
+                free(zbuf, M_TEMP);
+                break;
+
+        case MOD_SHUTDOWN:
+                break;
+
+        default:
+                return (EOPNOTSUPP);
+        }
+
+        return (0);
+}
+
Added: head/sys/dev/lindev/lindev.c

==============================================================================
--- /dev/null    00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/lindev/lindev.c Sat Sep 26 12:45:28 2009        (r197518)
@@ -0,0 +1,73 @@
+/*-
+ * Copyright (c) 2009 "Bjoern A. Zeeb" <bz@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.
+ */
+
+/*
+ * "lindev" is supposed to be a collection of linux-specific devices
+ * that we also support, just not by default.
+ * While currently there is only "/dev/full", we are planning to see
+ * more in the future.
+ * This file is only the container to load/unload all supported devices;
+ * the implementation of each should go into its own file.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/conf.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+
+#include <dev/lindev/lindev.h>
+
+/* ARGSUSED */
+static int
+lindev_modevent(module_t mod, int type, void *data)
+{
+        int error;
+
+        switch(type) {
+        case MOD_LOAD:
+                error = lindev_modevent_full(mod, type, data);
+                break;
+
+        case MOD_UNLOAD:
+                error = lindev_modevent_full(mod, type, data);
+                break;
+
+        case MOD_SHUTDOWN:
+                error = lindev_modevent_full(mod, type, data);
+                break;
+
+        default:
+                return (EOPNOTSUPP);
+        }
+
+        return (error);
+}
+
+DEV_MODULE(lindev, lindev_modevent, NULL);
+MODULE_VERSION(lindev, 1);
Added: head/sys/dev/lindev/lindev.h

==============================================================================
--- /dev/null    00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/lindev/lindev.h Sat Sep 26 12:45:28 2009        (r197518)
@@ -0,0 +1,34 @@
+/*-
+ * Copyright (c) 2009 "Bjoern A. Zeeb" <bz@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$
+ */
+
+#ifndef _DEV_LINDEV_LINDEV_H
+#define _DEV_LINDEV_LINDEV_H
+
+int lindev_modevent_full(module_t, int, void *);
+
+#endif /* _DEV_LINDEV_LINDEV_H */
Modified: head/sys/i386/conf/NOTES

==============================================================================
--- head/sys/i386/conf/NOTES     Sat Sep 26 11:44:04 2009        (r197517)
+++ head/sys/i386/conf/NOTES     Sat Sep 26 12:45:28 2009        (r197518)
@@ -880,6 +880,9 @@ device               streams         # STREAMS network drive
 options         NDISAPI
 device          ndis
 
+# Linux-specific pseudo devices support
+device          lindev
+
 
 #####################################################################
 # VM OPTIONS
Modified: head/sys/modules/Makefile

==============================================================================
--- head/sys/modules/Makefile    Sat Sep 26 11:44:04 2009        (r197517)
+++ head/sys/modules/Makefile    Sat Sep 26 12:45:28 2009        (r197518)
@@ -151,6 +151,7 @@ SUBDIR=      ${_3dfx} \
         libiconv \
         libmbpool \
         libmchain \
+        ${_lindev} \
         ${_linprocfs} \
         ${_linsysfs} \
         ${_linux} \
@@ -373,6 +374,7 @@ _ie=         ie
 _if_ndis=       if_ndis
 _igb=           igb
 _io=            io
+_lindev=        lindev
 _linprocfs=     linprocfs
 _linsysfs=      linsysfs
 _linux=         linux
@@ -510,6 +512,7 @@ _ipwfw=              ipwfw
 _iwn=           iwn
 _iwnfw=         iwnfw
 _ixgb=          ixgb
+_lindev=        lindev
 _linprocfs=     linprocfs
 _linsysfs=      linsysfs
 _linux=         linux
Added: head/sys/modules/lindev/Makefile

==============================================================================
--- /dev/null    00:00:00 1970   (empty, because file is newly added)
+++ head/sys/modules/lindev/Makefile     Sat Sep 26 12:45:28 2009        (r197518)
@@ -0,0 +1,8 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../../dev/lindev
+
+KMOD=   lindev
+SRCS=   full.c lindev.c
+
+.include <bsd.kmod.mk>
Modified: head/sys/pc98/conf/NOTES

==============================================================================
--- head/sys/pc98/conf/NOTES     Sat Sep 26 11:44:04 2009        (r197517)
+++ head/sys/pc98/conf/NOTES     Sat Sep 26 12:45:28 2009        (r197518)
@@ -565,6 +565,9 @@ options      COMPAT_SVR4     # build emulator st
 options         DEBUG_SVR4      # enable verbose debugging
 device          streams         # STREAMS network driver (required for svr4).
 
+# Linux-specific pseudo devices support
+device          lindev
+
 
 #####################################################################
 # VM OPTIONS
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"




Unformatted:
 
Submit Followup | Raw PR | Find another PR