Index: geom.h =================================================================== RCS file: /home/ncvs/src/sys/geom/geom.h,v retrieving revision 1.81 diff -u -r1.81 geom.h --- geom.h 10 Mar 2004 08:49:08 -0000 1.81 +++ geom.h 10 Mar 2004 18:49:33 -0000 @@ -185,6 +185,10 @@ void g_dev_print(void); struct g_provider *g_dev_getprovider(dev_t dev); +/* geom_devctl.c */ +void g_dev_added(const char *); +void g_dev_removed(const char *); + /* geom_dump.c */ void g_trace(int level, const char *, ...); # define G_T_TOPOLOGY 1 Index: geom_dev.c =================================================================== RCS file: /home/ncvs/src/sys/geom/geom_dev.c,v retrieving revision 1.73 diff -u -r1.73 geom_dev.c --- geom_dev.c 21 Feb 2004 21:10:49 -0000 1.73 +++ geom_dev.c 21 Feb 2004 23:05:48 -0000 @@ -178,6 +178,7 @@ UID_ROOT, GID_OPERATOR, 0640, gp->name); if (pp->flags & G_PF_CANDELETE) dev->si_flags |= SI_CANDELETE; + g_dev_added(gp->name); mtx_unlock(&Giant); g_topology_lock(); dev->si_iosize_max = MAXPHYS; @@ -429,6 +430,9 @@ /* Destroy the dev_t so we get no more requests */ destroy_dev(dev); + + /* Send a note to userspace for any cleanup it wants to do. */ + g_dev_removed(gp->name); /* Wait for the cows to come home */ while (cp->nstart != cp->nend) Index: geom_devctl.c =================================================================== RCS file: geom_devctl.c diff -N geom_devctl.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ geom_devctl.c 18 Feb 2004 00:26:23 -0000 @@ -0,0 +1,66 @@ +/*- + * Copyright (c) 2004 Robert N. M. Watson + * 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$ + */ + +/* + * GEOM disk event stream for userspace: notification of arrival and + * deletion of GEOM-visible /dev entries. + */ + +#include +#include +#include +#include +#include + +#include + +void +g_dev_added(const char *disk) +{ + struct sbuf sb; + + sbuf_new(&sb, NULL, 0, SBUF_AUTOEXTEND); + sbuf_printf(&sb, "+%s at on geom", disk); + sbuf_finish(&sb); + devctl_queue_data(sbuf_data(&sb)); + printf("geom: sent devctl '%s'\n", sbuf_data(&sb)); + sbuf_done(&sb); +} + +void +g_dev_removed(const char *disk) +{ + struct sbuf sb; + + sbuf_new(&sb, NULL, 0, SBUF_AUTOEXTEND); + sbuf_printf(&sb, "-%s at on geom", disk); + sbuf_finish(&sb); + devctl_queue_data(sbuf_data(&sb)); + printf("geom: sent devctl '%s'\n", sbuf_data(&sb)); + sbuf_done(&sb); +}