From d7fc6b258d3126c6aeb71b6a57bb1e3dc66ddcf7 Mon Sep 17 00:00:00 2001 From: phk Date: Tue, 18 Nov 2003 18:17:39 +0000 Subject: Call class->init() an class->fini() while the class is hooked up, rather than right before and right after. This allows these routines to manipulate the mesh. KASSERT that nobody creates a geom on an alien class. Assert topology in g_valid_obj(). Approved by: re@ --- sys/geom/geom_subr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'sys/geom') diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c index f2f8820..995c113 100644 --- a/sys/geom/geom_subr.c +++ b/sys/geom/geom_subr.c @@ -92,10 +92,10 @@ g_load_class(void *arg, int flag) ("A GEOM class named %s is already loaded", mp2->name)); } - if (mp->init != NULL) - mp->init(mp); LIST_INIT(&mp->geom); LIST_INSERT_HEAD(&g_classes, mp, class); + if (mp->init != NULL) + mp->init(mp); if (mp->taste == NULL) return; LIST_FOREACH(mp2, &g_classes, class) { @@ -154,9 +154,9 @@ g_unload_class(void *arg, int flag) break; } if (error == 0) { - LIST_REMOVE(mp, class); if (mp->fini != NULL) mp->fini(mp); + LIST_REMOVE(mp, class); } hh->error = error; return; @@ -206,6 +206,7 @@ g_new_geomf(struct g_class *mp, const char *fmt, ...) struct sbuf *sb; g_topology_assert(); + KASSERT(g_valid_obj(mp), ("g_new_geom_f() on alien class %p", mp)); sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND); va_start(ap, fmt); sbuf_vprintf(sb, fmt, ap); @@ -803,6 +804,7 @@ g_valid_obj(void const *ptr) struct g_consumer *cp; struct g_provider *pp; + g_topology_assert(); LIST_FOREACH(mp, &g_classes, class) { if (ptr == mp) return (1); -- cgit v1.1