diff --git a/sys/geom/geom.h b/sys/geom/geom.h index 82ce8fe2690d..015baea4deb4 100644 --- a/sys/geom/geom.h +++ b/sys/geom/geom.h @@ -87,12 +87,22 @@ typedef void g_dumpconf_t (struct sbuf *, const char *indent, struct g_geom *, */ struct g_class { const char *name; + u_int version; g_taste_t *taste; g_config_t *config; g_ctl_req_t *ctlreq; g_init_t *init; g_fini_t *fini; g_ctl_destroy_geom_t *destroy_geom; + /* + * Defaults values for geom methods + */ + g_start_t *start; + g_spoiled_t *spoiled; + g_dumpconf_t *dumpconf; + g_access_t *access; + g_orphan_t *orphan; + g_ioctl_t *ioctl; /* * The remaining elements are private */ @@ -100,6 +110,9 @@ struct g_class { LIST_HEAD(,g_geom) geom; }; +#define G_VERSION_00 0x19950323 +#define G_VERSION G_VERSION_00 + /* * The g_geom is an instance of a g_class. */ diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c index 2e957699f344..c7058ea857fa 100644 --- a/sys/geom/geom_subr.c +++ b/sys/geom/geom_subr.c @@ -177,7 +177,14 @@ g_modevent(module_t mod, int type, void *data) struct g_hh00 *hh; int error; static int g_ignition; + struct g_class *mp; + mp = data; + if (mp->version != G_VERSION) { + printf("GEOM class %s has Wrong version %x\n", + mp->name, mp->version); + return (EINVAL); + } if (!g_ignition) { g_ignition++; g_init(); @@ -234,6 +241,13 @@ g_new_geomf(struct g_class *mp, const char *fmt, ...) TAILQ_INSERT_HEAD(&geoms, gp, geoms); strcpy(gp->name, sbuf_data(sb)); sbuf_delete(sb); + /* Fill in defaults from class */ + gp->start = mp->start; + gp->spoiled = mp->spoiled; + gp->dumpconf = mp->dumpconf; + gp->access = mp->access; + gp->orphan = mp->orphan; + gp->ioctl = mp->ioctl; return (gp); }