diff options
author | phk <phk@FreeBSD.org> | 2002-05-21 20:33:49 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2002-05-21 20:33:49 +0000 |
commit | 476ca0197fe439db32412d254212efdcc10bd9cf (patch) | |
tree | fec49ff015cfe691229ddfbcf6205b4f482aec1e /sys/geom/geom_subr.c | |
parent | 4c8f46cf75901f6eeca741030d0075e8789c0566 (diff) | |
download | FreeBSD-src-476ca0197fe439db32412d254212efdcc10bd9cf.zip FreeBSD-src-476ca0197fe439db32412d254212efdcc10bd9cf.tar.gz |
Introduce the concept of "magic spaces", and implement them in most of
the relevant classes.
Some methods may implement various "magic spaces", this is reserved
or magic areas on the disk, set a side for various and sundry purposes.
A good example is the BSD disklabel and boot code on i386 which occupies
a total of four magic spaces: boot1, the disklabel, the padding behind
the disklabel and boot2. The reason we don't simply tell people to
write the appropriate stuff on the underlying device is that (some of)
the magic spaces might be real-time modifiable. It is for instance
possible to change a disklabel while partitions are open, provided
the open partitions do not get trampled in the process.
Sponsored by: DARPA & NAI Labs.
Diffstat (limited to 'sys/geom/geom_subr.c')
-rw-r--r-- | sys/geom/geom_subr.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c index d672c3d..1b2dc2e 100644 --- a/sys/geom/geom_subr.c +++ b/sys/geom/geom_subr.c @@ -114,6 +114,35 @@ g_new_geomf(struct g_class *mp, char *fmt, ...) return (gp); } +int +g_new_magicspaces(struct g_geom *gp, int nspaces) +{ + gp->magicspaces = g_malloc(sizeof *gp->magicspaces, M_WAITOK | M_ZERO); + gp->magicspaces->magicspace = + g_malloc(sizeof *gp->magicspaces->magicspace * nspaces, + M_WAITOK | M_ZERO); + gp->magicspaces->geom_id = (uintptr_t)gp; + strncpy(gp->magicspaces->class, gp->class->name, + sizeof gp->magicspaces->class); + gp->magicspaces->nmagic = nspaces; + return (0); +} + +int +g_add_magicspace(struct g_geom *gp, u_int index, const char *name, off_t start, u_int len, u_int flags) +{ + struct g_magicspace *msp; + + /* KASSERT gp->magicspaces != NULL */ + /* KASSERT index < gp->magicspaces->nmagic */ + msp = &gp->magicspaces->magicspace[index]; + strncpy(msp->name, name, sizeof msp->name); + msp->offset = start; + msp->len = len; + msp->flags = flags; + return (0); +} + void g_destroy_geom(struct g_geom *gp) { @@ -129,6 +158,10 @@ g_destroy_geom(struct g_geom *gp) gp->name, LIST_FIRST(&gp->consumer))); LIST_REMOVE(gp, geom); TAILQ_REMOVE(&geoms, gp, geoms); + if (gp->magicspaces) { + g_free(gp->magicspaces->magicspace); + g_free(gp->magicspaces); + } g_free(gp->name); g_free(gp); } |