EXAMPLES
Create an example geom.
static struct geom *
g_example_start(struct bio *bp)
{
[...]
}
static void
g_example_orphan(struct g_consumer *cp)
{
g_topology_assert();
[...]
}
static void
g_example_spoiled(struct g_consumer *cp)
{
g_topology_assert();
[...]
}
static void
g_example_access(struct g_provider *pp, int dr, int dw, int de)
{
[...]
}
static struct g_geom *
create_example_geom(struct g_class *myclass)
{
struct g_geom *gp;
g_topology_lock();
gp = g_new_geomf(myclass, "example_geom");
g_topology_unlock();
gp->start = g_example_start;
gp->orphan = g_example_orphan;
gp->spoiled = g_example_spoiled;
gp->access = g_example_access;
gp->softc = NULL;
return (gp);
}
static int
destroy_example_geom(struct g_geom *gp)
{
g_topology_lock();
if (!LIST_EMPTY(&gp->provider) ||
!LIST_EMPTY(&gp->consumer)) {
g_topology_unlock();
return (EBUSY);
}
g_destroy_geom(gp);
g_topology_unlock();
return (0);
}
SEE ALSO
geom(4), DECLARE_GEOM_CLASS(9), g_access(9), g_attach(9), g_bio(9), g_consumer(9), g_data(9), g_event(9), g_provider(9), g_provider_by_name(9), g_wither_geom(9)
AUTHORS