Langue: en

Version: 308305 (debian - 07/07/09)

Section: 9 (Appels noyau Linux)

BSD mandoc


DECLARE_GEOM_CLASS - GEOM class declaration macro


In geom/geom.h Fn DECLARE_GEOM_CLASS class mod_name


The Fn DECLARE_GEOM_CLASS macro registers a GEOM class in GEOM. A GEOM class itself implements one particular kind of transformation. Typical examples are: MBR disk partition, BSD disklabel and RAID5 classes. Fn DECLARE_GEOM_CLASS can be used both for compiled in and loaded as kld(4) modules GEOM classes and it is the only official way for class registration.

The arguments to Fn DECLARE_GEOM_CLASS are:

Fa class
The Vt g_class structure which describes a GEOM class.
Fa mod_name
A kernel module name (not a class name!).

Structure Vt g_class contains data describing the class. They are:

Vt const char * name
Class name.
Vt g_taste_t * taste
Pointer to function used for taste event handling. If it is non- NULL it is called in three situations:
On class activation, all existing providers are offered for tasting.
When new provider is created it is offered for tasting.
After last write access to a provider is closed it is offered for retasting
(on first write open event ``spoil'' was sent).
Vt g_config_t * config
This field is not used anymore, its functionality was replaced by the ctlreq field.
Vt g_ctl_req_t * ctlreq
Pointer to function used for handling events from userland applications.
Vt g_init_t * init
Pointer to function which is called right after class registration.
Vt g_fini_t * fini
Pointer to function which is called right before class deregistration.
Vt g_ctl_destroy_geom_t * destroy_geom
Pointer to a function which is called for every geom on class unload. If this field is not set, the class can not be unloaded.

Only a Fa name field is required; the rest are optional.


The fields of Vt g_class should always be initialized using C99-style field naming (see the initialization of example_class below).


Example class declaration.
 static struct g_geom *
 g_example_taste(struct g_class *mp, struct g_provider *pp,
     int flags __unused)
 static void
 g_example_ctlreq(struct gctl_req *req, struct g_class *cp,
     char const *verb)
 static int
 g_example_destroy_geom(struct gctl_req *req, struct g_class *cp,
     struct g_geom *gp)
 static void
 g_example_init(struct g_class *mp)
 static void
 g_example_fini(struct g_class *mp)
 struct g_class example_class = {
         .name = "EXAMPLE",
         .taste = g_example_taste,
         .ctlreq = g_example_ctlreq,
         .init = g_example_init,
         .fini = g_example_fini,
         .destroy_geom = g_example_destroy_geom
 DECLARE_GEOM_CLASS(example_class, g_example);


geom(4), g_attach9, g_bio9, g_consumer9, g_data9, g_event9, g_geom9, g_provider9, g_provider_by_name9, g_wither_geom9


An -nosplit This manual page was written by An Pawel Jakub Dawidek Aq .