summaryrefslogtreecommitdiffstats
path: root/sys/geom/geom_subr.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2004-08-08 06:46:27 +0000
committerphk <phk@FreeBSD.org>2004-08-08 06:46:27 +0000
commite7ff00372839d76506b62b02f72ffca52e7cccb1 (patch)
tree9f997ef4e73821619ca02a65d59b6d284813d487 /sys/geom/geom_subr.c
parent0a68c3721e19c1768480c812da527b4cdb34e9de (diff)
downloadFreeBSD-src-e7ff00372839d76506b62b02f72ffca52e7cccb1.zip
FreeBSD-src-e7ff00372839d76506b62b02f72ffca52e7cccb1.tar.gz
Give classes a version number and refuse to touch classes which are not
understood. This makes room for additional binary compatibility in the future. Put fields in the class for the geom's methods and initialize the methods of a new geom from these fields. This saves some code in all classes.
Diffstat (limited to 'sys/geom/geom_subr.c')
-rw-r--r--sys/geom/geom_subr.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c
index 2e95769..c7058ea 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);
}
OpenPOWER on IntegriCloud