On Sun, 23 Jan 2005, Pete Carah wrote: > Geom doesn't feed node-creations to devd in 5.3. This would be VERY > useful for letting ordinary non-programmer users access pen drives, > among other things (floppies come to mind too...). (or mount e.g. a pen > drive as part of an authentication system where no-one is yet logged in, > so can't manually mount...) > > umass0 comes in to devd, but this isn't useful for use in "mount". One > needs the disk device nodes. I suppose one *could* parse dmesg for the > info (or maybe sysctl) but that smacks of a serious kluge. (not to > mention that the slice table isn't represented in dmesg anyhow, and > practically nothing is in sysctl...) > > Does this yet happen in any later version (RELENG_5 or HEAD)? If not, > is there anyone planning or working on it? > > It *does* work in Solaris and IRIX, (I know - we aren't them...) I > don't know about any Linux or other *BSD version either. > > Geom is modular enough that this shouldn't be difficult... I used the attached patches do announce storage device arrival on my notebook so that I can do auto-mounting of USB storage. There appears to be some disagreement regarding layering: my opinion has generally been that since there are multiple layers involved, we should announce both the layer and the device, for example: Network stack says "ifnet fxp0 arrived" separately from: /dev says "/dev/net/fxp0 arrived" Since they constitute different "things" with quite different management properties. This also provides additional contextual information: rather than devd having to guess what type of object a device node is using name matching, by learning about it through geom or the network stack, it knows what kind it is up front in a strong way. Robert N M Watson Index: geom.h =================================================================== RCS file: /home/ncvs/src/sys/geom/geom.h,v retrieving revision 1.90 diff -u -r1.90 geom.h --- geom.h 21 Dec 2004 18:32:46 -0000 1.90 +++ geom.h 22 Dec 2004 18:43:59 -0000 _at__at_ -200,6 +200,10 _at__at_ void g_dev_print(void); struct g_provider *g_dev_getprovider(struct cdev *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.87 diff -u -r1.87 geom_dev.c --- geom_dev.c 12 Dec 2004 10:09:05 -0000 1.87 +++ geom_dev.c 22 Dec 2004 18:43:59 -0000 _at__at_ -151,6 +151,7 _at__at_ 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; _at__at_ -415,6 +416,9 _at__at_ destroy_dev(dev); free_unr(unithdr, unit); + /* 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) msleep(&dev, NULL, PRIBIO, "gdevorphan", hz / 10); 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 _at__at_ -0,0 +1,66 _at__at_ +/*- + * 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 <sys/param.h> +#include <sys/bus.h> +#include <sys/malloc.h> +#include <sys/sbuf.h> +#include <sys/systm.h> + +#include <geom/geom.h> + +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); +}Received on Mon Jan 24 2005 - 08:58:21 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:26 UTC