DECLARE_GEOM_CLASS(9)

DECLARE_GEOM_CLASS9

Geom class declaration macro

Usage

#include <geom/geom.h>

DECLARE_GEOM_CLASS(class, mod_name);

Overview

The 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. 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 DECLARE_GEOM_CLASS() are:

class

The g_class structure which describes a GEOM class.

mod_name

A kernel module name (not a class name!).

Structure g_class contains data describing the class. They are:

const char * name

Class name.

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).

g_config_t * config

This field is not used anymore, its functionality was replaced by the ctlreq field.

g_ctl_req_t * ctlreq

Pointer to function used for handling events from userland applications.

g_init_t * init

Pointer to function which is called right after class registration.

g_fini_t * fini

Pointer to function which is called right before class deregistration.

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 name field is required; the rest are optional.

Restrictions/conditions

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

Examples

Example class declaration.

static struct g_geom *
g_example_taste(struct g_class *mp, struct g_provider *pp,
    int flags __unused)
{
	g_topology_assert();
	[...]
}
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)
{
	g_topology_assert();
	[...]
}
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);

Releases

52 releases since FreeBSD 5.3-RELEASE; the text changed 35 times.

  1. 5.3
  2. 5.4–5.5
  3. 6.0–6.2
  4. 6.3
  5. 6.4
  6. 7.0
  7. 7.1
  8. 7.2
  9. 7.3
  10. 7.4
  11. 8.0
  12. 8.1
  13. 8.2
  14. 8.3
  15. 8.4
  16. 9.0
  17. 9.1
  18. 9.2
  19. 9.3
  20. 10.0
  21. 10.1
  22. 10.2
  23. 10.3
  24. 10.4
  25. 11.0
  26. 11.1
  27. 11.2
  28. 11.3
  29. 11.4
  30. 12.0
  31. 12.1
  32. 12.2
  33. 12.3
  34. 12.4
  35. 13.0–13.2
  36. 13.3–16.0

Authors

This manual page was written by Pawel Jakub Dawidek ⟨[email protected]⟩.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.