g_new_geomf g_destroy_geom - geom management
The
g_new_geomf ();
function creates a new geom, which will be an instance of the class
Fa mp .
The geom's name is created in a
printf(3)
-like way from the rest of the arguments.
The
g_destroy_geom ();
function destroys the given geom immediately and cancels all related pending
events.
The Vt g_geom structure contains fields that should be set by the caller after geom creation, but before creating any providers or consumers related to this geom (not all are required):
If you are planning to use consumers in your geom you must set fields orphan and access for it.
g_new_geomf (:);
g_destroy_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);
}
|
Закладки на сайте Проследить за страницей |
Created 1996-2025 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |