Main index | Section 9 | Options |
#include <geom/geom.h>
The g_new_geomf() function creates a new geom, which will be an instance of the class 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 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):
g_start_t * start | Pointer to a function used for I/O processing. |
g_spoiled_t * spoiled | Pointer to a function used for consumers spoiling. |
g_dumpconf_t * dumpconf | Pointer to a function used for configuration in XML format dumping. |
g_access_t * access | Pointer to a function used for access control. |
g_orphan_t * orphan | Pointer to a function used to inform about orphaned consumer. |
g_ioctl_t * ioctl | Pointer to a function used for handling ioctl requests. |
void * softc | Field for private use. |
If you are planning to use consumers in your geom you must set fields orphan and access for it.
g_new_geomf():
Class mp must be valid (registered in GEOM). | |
The topology lock has to be held. | |
g_destroy_geom():
The geom cannot possess any providers. | |
The geom cannot possess any consumers. | |
The topology lock has to be held. | |
static void 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 int 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); }
G_GEOM (9) | April 24, 2016 |
Main index | Section 9 | Options |
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.
“ | C isn't that hard: void (*(*f[])())() defines f as an array of unspecified size, of pointers to functions that return pointers to functions that return void | ” |