Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/usermode/dev close file descriptors at shutdown
details: https://anonhg.NetBSD.org/src/rev/387215fc9207
branches: trunk
changeset: 772766:387215fc9207
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sun Jan 15 10:51:12 2012 +0000
description:
close file descriptors at shutdown
diffstat:
sys/arch/usermode/dev/if_veth.c | 19 +++++++++++++++++--
sys/arch/usermode/dev/vaudio.c | 19 +++++++++++++++++--
2 files changed, 34 insertions(+), 4 deletions(-)
diffs (108 lines):
diff -r 9ab8faf3ae1d -r 387215fc9207 sys/arch/usermode/dev/if_veth.c
--- a/sys/arch/usermode/dev/if_veth.c Sun Jan 15 10:45:03 2012 +0000
+++ b/sys/arch/usermode/dev/if_veth.c Sun Jan 15 10:51:12 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_veth.c,v 1.3 2012/01/09 20:39:39 reinoud Exp $ */
+/* $NetBSD: if_veth.c,v 1.4 2012/01/15 10:51:12 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_veth.c,v 1.3 2012/01/09 20:39:39 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_veth.c,v 1.4 2012/01/15 10:51:12 jmcneill Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -48,6 +48,7 @@
static int veth_match(device_t, cfdata_t, void *);
static void veth_attach(device_t, device_t, void *);
+static bool veth_shutdown(device_t, int);
static int veth_init(struct ifnet *);
static void veth_start(struct ifnet *);
@@ -103,6 +104,9 @@
struct ifnet *ifp = &sc->sc_ec.ec_if;
sc->sc_dev = self;
+
+ pmf_device_register1(self, NULL, NULL, veth_shutdown);
+
sc->sc_tapfd = thunk_open_tap(taa->u.veth.device);
if (sc->sc_tapfd == -1) {
aprint_error(": couldn't open %s: %d\n",
@@ -156,6 +160,17 @@
panic("couldn't establish veth rx interrupt");
}
+static bool
+veth_shutdown(device_t self, int flags)
+{
+ struct veth_softc *sc = device_private(self);
+
+ if (sc->sc_tapfd != -1)
+ thunk_close(sc->sc_tapfd);
+
+ return true;
+}
+
static int
veth_init(struct ifnet *ifp)
{
diff -r 9ab8faf3ae1d -r 387215fc9207 sys/arch/usermode/dev/vaudio.c
--- a/sys/arch/usermode/dev/vaudio.c Sun Jan 15 10:45:03 2012 +0000
+++ b/sys/arch/usermode/dev/vaudio.c Sun Jan 15 10:51:12 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vaudio.c,v 1.2 2011/12/26 23:50:43 jmcneill Exp $ */
+/* $NetBSD: vaudio.c,v 1.3 2012/01/15 10:51:12 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vaudio.c,v 1.2 2011/12/26 23:50:43 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vaudio.c,v 1.3 2012/01/15 10:51:12 jmcneill Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -76,6 +76,7 @@
static int vaudio_match(device_t, cfdata_t, void *);
static void vaudio_attach(device_t, device_t, void *);
+static bool vaudio_shutdown(device_t, int);
static void vaudio_intr(void *);
static void vaudio_softintr_play(void *);
@@ -148,6 +149,9 @@
aprint_normal(": Virtual Audio (device = %s)\n", taa->u.vaudio.device);
sc->sc_dev = self;
+
+ pmf_device_register1(self, NULL, NULL, vaudio_shutdown);
+
sc->sc_audiopath = taa->u.vaudio.device;
sc->sc_audiofd = thunk_audio_open(sc->sc_audiopath);
if (sc->sc_audiofd == -1) {
@@ -181,6 +185,17 @@
sc->sc_audiodev = audio_attach_mi(&vaudio_hw_if, sc, self);
}
+static bool
+vaudio_shutdown(device_t self, int flags)
+{
+ struct vaudio_softc *sc = device_private(self);
+
+ if (sc->sc_audiofd != -1)
+ thunk_audio_close(sc->sc_audiofd);
+
+ return true;
+}
+
static void
vaudio_intr(void *opaque)
{
Home |
Main Index |
Thread Index |
Old Index