DECLARE_GEOM_CLASS(9)
okay bestie, welcome to DECLARE_GEOM_CLASS(9), and yes itβs from the Kernel Developer's Manual β weβre doing kernel macro lore today π
β¨
πΈ NAME πΈ
DECLARE_GEOM_CLASS β the GEOM class declaration macro, aka the official little doorway for registering your GEOM class π«Ά
β¨ SYNOPSIS β¨
#include <geom/geom.h>
DECLARE_GEOM_CLASS(class, mod_name);
π DESCRIPTION π
okay so the DECLARE_GEOM_CLASS() macro registers a GEOM class in GEOM. A GEOM class itself implements one particular kind of transformation β think of it as a class with main character energy that does exactly one transformation job. 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. periodt π₯
The arguments to DECLARE_GEOM_CLASS() are:
classβ Theg_classstructure 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 thectlreqfield. π«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. slay, minimal setup π
π§ RESTRICTIONS/CONDITIONS π§
The fields of g_class should always be initialized using C99-style field naming (see the initialization of example_class below). no chaotic free-for-all field assignment, bestie π
π¦ 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);
π SEE ALSO π
geom(4), g_attach(9), g_bio(9), g_consumer(9), g_data(9), g_event(9), g_geom(9), g_provider(9), g_provider_by_name(9), g_wither_geom(9)
π AUTHORS π
This manual page was written by Pawel Jakub Dawidek <pjd@FreeBSD.org>. iconic behavior, fr fr π«Ά
xoxo, this page came from Debian, dated August 13, 2007 β DECLARE_GEOM_CLASS(9) signing off with sparkles πβ¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2004 Pawel Jakub Dawidek <pjd@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms