geom_dev.c (92698) | geom_dev.c (93248) |
---|---|
1/*- 2 * Copyright (c) 2002 Poul-Henning Kamp 3 * Copyright (c) 2002 Networks Associates Technology, Inc. 4 * All rights reserved. 5 * 6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp 7 * and NAI Labs, the Security Research Division of Network Associates, Inc. 8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the --- 18 unchanged lines hidden (view full) --- 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * | 1/*- 2 * Copyright (c) 2002 Poul-Henning Kamp 3 * Copyright (c) 2002 Networks Associates Technology, Inc. 4 * All rights reserved. 5 * 6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp 7 * and NAI Labs, the Security Research Division of Network Associates, Inc. 8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the --- 18 unchanged lines hidden (view full) --- 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * |
35 * $FreeBSD: head/sys/geom/geom_dev.c 92698 2002-03-19 13:54:15Z phk $ | 35 * $FreeBSD: head/sys/geom/geom_dev.c 93248 2002-03-26 21:40:06Z phk $ |
36 */ 37 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/malloc.h> 41#include <sys/kernel.h> 42#include <sys/conf.h> 43#include <sys/bio.h> --- 27 unchanged lines hidden (view full) --- 71 /* dump */ nodump, 72 /* psize */ g_dev_psize, 73 /* flags */ D_DISK | D_CANFREE | D_TRACKCLOSE, 74}; 75 76static g_taste_t g_dev_taste; 77static g_orphan_t g_dev_orphan; 78 | 36 */ 37 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/malloc.h> 41#include <sys/kernel.h> 42#include <sys/conf.h> 43#include <sys/bio.h> --- 27 unchanged lines hidden (view full) --- 71 /* dump */ nodump, 72 /* psize */ g_dev_psize, 73 /* flags */ D_DISK | D_CANFREE | D_TRACKCLOSE, 74}; 75 76static g_taste_t g_dev_taste; 77static g_orphan_t g_dev_orphan; 78 |
79static struct g_method g_dev_method = { 80 "DEV-method", | 79static struct g_class g_dev_class = { 80 "DEV-class", |
81 g_dev_taste, 82 NULL, 83 g_dev_orphan, 84 NULL, | 81 g_dev_taste, 82 NULL, 83 g_dev_orphan, 84 NULL, |
85 G_METHOD_INITSTUFF | 85 G_CLASS_INITSTUFF |
86}; 87 88static void 89g_dev_clone(void *arg, char *name, int namelen, dev_t *dev) 90{ 91 struct g_geom *gp; 92 93 if (*dev != NODEV) 94 return; 95 96 g_trace(G_T_TOPOLOGY, "g_dev_clone(%s)", name); 97 g_rattle(); 98 99 /* XXX: can I drop Giant here ??? */ 100 /* g_topology_lock(); */ | 86}; 87 88static void 89g_dev_clone(void *arg, char *name, int namelen, dev_t *dev) 90{ 91 struct g_geom *gp; 92 93 if (*dev != NODEV) 94 return; 95 96 g_trace(G_T_TOPOLOGY, "g_dev_clone(%s)", name); 97 g_rattle(); 98 99 /* XXX: can I drop Giant here ??? */ 100 /* g_topology_lock(); */ |
101 LIST_FOREACH(gp, &g_dev_method.geom, geom) { | 101 LIST_FOREACH(gp, &g_dev_class.geom, geom) { |
102 if (strcmp(gp->name, name)) 103 continue; 104 *dev = gp->softc; 105 g_trace(G_T_TOPOLOGY, "g_dev_clone(%s) = %p", name, *dev); 106 return; 107 } 108 /* g_topology_unlock(); */ 109 return; --- 9 unchanged lines hidden (view full) --- 119 EVENTHANDLER_REGISTER(dev_clone, g_dev_clone, 0, 1000); 120 once++; 121 } 122} 123 124SYSINIT(geomdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE,g_dev_register_cloner,NULL); 125 126static struct g_geom * | 102 if (strcmp(gp->name, name)) 103 continue; 104 *dev = gp->softc; 105 g_trace(G_T_TOPOLOGY, "g_dev_clone(%s) = %p", name, *dev); 106 return; 107 } 108 /* g_topology_unlock(); */ 109 return; --- 9 unchanged lines hidden (view full) --- 119 EVENTHANDLER_REGISTER(dev_clone, g_dev_clone, 0, 1000); 120 once++; 121 } 122} 123 124SYSINIT(geomdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE,g_dev_register_cloner,NULL); 125 126static struct g_geom * |
127g_dev_taste(struct g_method *mp, struct g_provider *pp, struct thread *tp __unused, int insist __unused) | 127g_dev_taste(struct g_class *mp, struct g_provider *pp, struct thread *tp __unused, int insist __unused) |
128{ 129 struct g_geom *gp; 130 struct g_consumer *cp; 131 static int unit; 132 u_int secsize; 133 off_t mediasize; 134 int error, j; 135 dev_t dev; 136 137 g_trace(G_T_TOPOLOGY, "dev_taste(%s,%s)", mp->name, pp->name); 138 g_topology_assert(); 139 LIST_FOREACH(cp, &pp->consumers, consumers) | 128{ 129 struct g_geom *gp; 130 struct g_consumer *cp; 131 static int unit; 132 u_int secsize; 133 off_t mediasize; 134 int error, j; 135 dev_t dev; 136 137 g_trace(G_T_TOPOLOGY, "dev_taste(%s,%s)", mp->name, pp->name); 138 g_topology_assert(); 139 LIST_FOREACH(cp, &pp->consumers, consumers) |
140 if (cp->geom->method == mp) | 140 if (cp->geom->class == mp) |
141 return (NULL); 142 gp = g_new_geomf(mp, pp->name); 143 cp = g_new_consumer(gp); 144 g_attach(cp, pp); 145 error = g_access_rel(cp, 1, 0, 0); 146 g_topology_unlock(); 147 if (!error) { 148 j = sizeof secsize; --- 128 unchanged lines hidden (view full) --- 277 else 278 error = g_io_getattr("GEOM::ioctl", cp, &i, gio, td); 279 g_free(gio); 280 break; 281 } 282 283 if (error != 0 && cmd == DIOCGDVIRGIN) { 284 g_topology_lock(); | 141 return (NULL); 142 gp = g_new_geomf(mp, pp->name); 143 cp = g_new_consumer(gp); 144 g_attach(cp, pp); 145 error = g_access_rel(cp, 1, 0, 0); 146 g_topology_unlock(); 147 if (!error) { 148 j = sizeof secsize; --- 128 unchanged lines hidden (view full) --- 277 else 278 error = g_io_getattr("GEOM::ioctl", cp, &i, gio, td); 279 g_free(gio); 280 break; 281 } 282 283 if (error != 0 && cmd == DIOCGDVIRGIN) { 284 g_topology_lock(); |
285 gp = g_create_geomf("BSD-method", cp->provider, NULL); | 285 gp = g_create_geomf("BSD-class", cp->provider, NULL); |
286 g_topology_unlock(); 287 } 288 PICKUP_GIANT(); 289 g_rattle(); 290 if (error == ENOIOCTL) { 291 i = IOCGROUP(cmd); 292 printf("IOCTL(0x%lx) \"%s\"", cmd, gp->name); 293 if (i > ' ' && i <= '~') --- 87 unchanged lines hidden (view full) --- 381 destroy_dev(dev); 382 if (cp->acr > 0 || cp->acw > 0 || cp->ace > 0) 383 g_access_rel(cp, -cp->acr, -cp->acw, -cp->ace); 384 g_dettach(cp); 385 g_destroy_consumer(cp); 386 g_destroy_geom(gp); 387} 388 | 286 g_topology_unlock(); 287 } 288 PICKUP_GIANT(); 289 g_rattle(); 290 if (error == ENOIOCTL) { 291 i = IOCGROUP(cmd); 292 printf("IOCTL(0x%lx) \"%s\"", cmd, gp->name); 293 if (i > ' ' && i <= '~') --- 87 unchanged lines hidden (view full) --- 381 destroy_dev(dev); 382 if (cp->acr > 0 || cp->acw > 0 || cp->ace > 0) 383 g_access_rel(cp, -cp->acr, -cp->acw, -cp->ace); 384 g_dettach(cp); 385 g_destroy_consumer(cp); 386 g_destroy_geom(gp); 387} 388 |
389DECLARE_GEOM_METHOD(g_dev_method, g_dev) | 389DECLARE_GEOM_CLASS(g_dev_class, g_dev) |
390 | 390 |