1f827ccb9SPawel Jakub Dawidek.\" 2f827ccb9SPawel Jakub Dawidek.\" Copyright (c) 2004 Pawel Jakub Dawidek <pjd@FreeBSD.org> 3f827ccb9SPawel Jakub Dawidek.\" All rights reserved. 4f827ccb9SPawel Jakub Dawidek.\" 5f827ccb9SPawel Jakub Dawidek.\" Redistribution and use in source and binary forms, with or without 6f827ccb9SPawel Jakub Dawidek.\" modification, are permitted provided that the following conditions 7f827ccb9SPawel Jakub Dawidek.\" are met: 8f827ccb9SPawel Jakub Dawidek.\" 1. Redistributions of source code must retain the above copyright 9f827ccb9SPawel Jakub Dawidek.\" notice, this list of conditions and the following disclaimer. 10f827ccb9SPawel Jakub Dawidek.\" 2. Redistributions in binary form must reproduce the above copyright 11f827ccb9SPawel Jakub Dawidek.\" notice, this list of conditions and the following disclaimer in the 12f827ccb9SPawel Jakub Dawidek.\" documentation and/or other materials provided with the distribution. 13f827ccb9SPawel Jakub Dawidek.\" 14f827ccb9SPawel Jakub Dawidek.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 15f827ccb9SPawel Jakub Dawidek.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16f827ccb9SPawel Jakub Dawidek.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17f827ccb9SPawel Jakub Dawidek.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 18f827ccb9SPawel Jakub Dawidek.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19f827ccb9SPawel Jakub Dawidek.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20f827ccb9SPawel Jakub Dawidek.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21f827ccb9SPawel Jakub Dawidek.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22f827ccb9SPawel Jakub Dawidek.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23f827ccb9SPawel Jakub Dawidek.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24f827ccb9SPawel Jakub Dawidek.\" 25376ccd5cSGabor Kovesdan.Dd August 13, 2007 26f827ccb9SPawel Jakub Dawidek.Dt DECLARE_GEOM_CLASS 9 27f827ccb9SPawel Jakub Dawidek.Os 28f827ccb9SPawel Jakub Dawidek.Sh NAME 29f827ccb9SPawel Jakub Dawidek.Nm DECLARE_GEOM_CLASS 30f827ccb9SPawel Jakub Dawidek.Nd "GEOM class declaration macro" 31f827ccb9SPawel Jakub Dawidek.Sh SYNOPSIS 32f827ccb9SPawel Jakub Dawidek.In geom/geom.h 33f827ccb9SPawel Jakub Dawidek.Fn DECLARE_GEOM_CLASS "class" "mod_name" 34f827ccb9SPawel Jakub Dawidek.Sh DESCRIPTION 35f827ccb9SPawel Jakub DawidekThe 36f827ccb9SPawel Jakub Dawidek.Fn DECLARE_GEOM_CLASS 37f827ccb9SPawel Jakub Dawidekmacro registers a GEOM class in GEOM. 38f827ccb9SPawel Jakub DawidekA GEOM class itself implements one particular kind of transformation. 396f39ea88SRuslan ErmilovTypical examples are: MBR disk partition, 406f39ea88SRuslan Ermilov.Bx 416f39ea88SRuslan Ermilovdisklabel and RAID5 classes. 42f827ccb9SPawel Jakub Dawidek.Fn DECLARE_GEOM_CLASS 43f827ccb9SPawel Jakub Dawidekcan be used both for compiled in and loaded as 44f827ccb9SPawel Jakub Dawidek.Xr kld 4 45f827ccb9SPawel Jakub Dawidekmodules GEOM classes and it is the only official way for class registration. 46f827ccb9SPawel Jakub Dawidek.Pp 47f827ccb9SPawel Jakub DawidekThe arguments to 48f827ccb9SPawel Jakub Dawidek.Fn DECLARE_GEOM_CLASS 49f827ccb9SPawel Jakub Dawidekare: 50e5254989SGlen Barber.Bl -tag -offset indent -width Fa 516f39ea88SRuslan Ermilov.It Fa class 521aaeeac1SGiorgos KeramidasThe 53f827ccb9SPawel Jakub Dawidek.Vt g_class 54f827ccb9SPawel Jakub Dawidekstructure which describes a GEOM class. 556f39ea88SRuslan Ermilov.It Fa mod_name 561aaeeac1SGiorgos KeramidasA kernel module name (not a class name!). 57f827ccb9SPawel Jakub Dawidek.El 58f827ccb9SPawel Jakub Dawidek.Pp 59f827ccb9SPawel Jakub DawidekStructure 60f827ccb9SPawel Jakub Dawidek.Vt g_class 61f827ccb9SPawel Jakub Dawidekcontains data describing the class. 62f827ccb9SPawel Jakub DawidekThey are: 636f39ea88SRuslan Ermilov.Bl -tag -offset indent -width indent 64f827ccb9SPawel Jakub Dawidek.It Vt "const char *" Va name 65f827ccb9SPawel Jakub DawidekClass name. 66f827ccb9SPawel Jakub Dawidek.It Vt "g_taste_t *" Va taste 67f827ccb9SPawel Jakub DawidekPointer to function used for taste event handling. 68f827ccb9SPawel Jakub DawidekIf it is 696f39ea88SRuslan Ermilov.Pf non- Dv NULL 70f827ccb9SPawel Jakub Dawidekit is called in three situations: 716f39ea88SRuslan Ermilov.Pp 726f39ea88SRuslan Ermilov.Bl -dash -compact 73f827ccb9SPawel Jakub Dawidek.It 74f827ccb9SPawel Jakub DawidekOn class activation, all existing providers are offered for tasting. 75f827ccb9SPawel Jakub Dawidek.It 76f827ccb9SPawel Jakub DawidekWhen new provider is created it is offered for tasting. 77f827ccb9SPawel Jakub Dawidek.It 78f827ccb9SPawel Jakub DawidekAfter last write access to a provider is closed it is offered for retasting 79f827ccb9SPawel Jakub Dawidek(on first write open event 80f827ccb9SPawel Jakub Dawidek.Dq spoil 81f827ccb9SPawel Jakub Dawidekwas sent). 82f827ccb9SPawel Jakub Dawidek.El 83f827ccb9SPawel Jakub Dawidek.It Vt "g_config_t *" Va config 84f827ccb9SPawel Jakub DawidekThis field is not used anymore, its functionality was replaced by the 85f827ccb9SPawel Jakub Dawidek.Va ctlreq 86f827ccb9SPawel Jakub Dawidekfield. 87f827ccb9SPawel Jakub Dawidek.It Vt "g_ctl_req_t *" Va ctlreq 88f827ccb9SPawel Jakub DawidekPointer to function used for handling events from userland applications. 89f827ccb9SPawel Jakub Dawidek.It Vt "g_init_t *" Va init 90f827ccb9SPawel Jakub DawidekPointer to function which is called right after class registration. 91f827ccb9SPawel Jakub Dawidek.It Vt "g_fini_t *" Va fini 92f827ccb9SPawel Jakub DawidekPointer to function which is called right before class deregistration. 93f827ccb9SPawel Jakub Dawidek.It Vt "g_ctl_destroy_geom_t *" Va destroy_geom 94f827ccb9SPawel Jakub DawidekPointer to a function which is called for every geom on class unload. 95f827ccb9SPawel Jakub DawidekIf this field is not set, the class can not be unloaded. 96f827ccb9SPawel Jakub Dawidek.El 97f827ccb9SPawel Jakub Dawidek.Pp 981aaeeac1SGiorgos KeramidasOnly a 99f827ccb9SPawel Jakub Dawidek.Fa name 1001aaeeac1SGiorgos Keramidasfield is required; the rest are optional. 101f827ccb9SPawel Jakub Dawidek.Sh RESTRICTIONS/CONDITIONS 1021aaeeac1SGiorgos KeramidasThe fields of 103f827ccb9SPawel Jakub Dawidek.Vt g_class 1041aaeeac1SGiorgos Keramidasshould always be initialized using C99-style field naming 1051aaeeac1SGiorgos Keramidas(see the initialization of 1066b13dcc0SRuslan Ermilov.Va example_class 1071aaeeac1SGiorgos Keramidasbelow). 108f827ccb9SPawel Jakub Dawidek.Sh EXAMPLES 109f827ccb9SPawel Jakub DawidekExample class declaration. 110f827ccb9SPawel Jakub Dawidek.Bd -literal -offset indent 111376ccd5cSGabor Kovesdanstatic struct g_geom * 112f827ccb9SPawel Jakub Dawidekg_example_taste(struct g_class *mp, struct g_provider *pp, 113f827ccb9SPawel Jakub Dawidek int flags __unused) 114f827ccb9SPawel Jakub Dawidek{ 115f827ccb9SPawel Jakub Dawidek g_topology_assert(); 116f827ccb9SPawel Jakub Dawidek 117f827ccb9SPawel Jakub Dawidek [...] 118f827ccb9SPawel Jakub Dawidek} 119f827ccb9SPawel Jakub Dawidek 120f827ccb9SPawel Jakub Dawidekstatic void 121f827ccb9SPawel Jakub Dawidekg_example_ctlreq(struct gctl_req *req, struct g_class *cp, 122f827ccb9SPawel Jakub Dawidek char const *verb) 123f827ccb9SPawel Jakub Dawidek{ 124f827ccb9SPawel Jakub Dawidek 125f827ccb9SPawel Jakub Dawidek [...] 126f827ccb9SPawel Jakub Dawidek} 127f827ccb9SPawel Jakub Dawidek 128f827ccb9SPawel Jakub Dawidekstatic int 129f827ccb9SPawel Jakub Dawidekg_example_destroy_geom(struct gctl_req *req, struct g_class *cp, 130f827ccb9SPawel Jakub Dawidek struct g_geom *gp) 131f827ccb9SPawel Jakub Dawidek{ 132f827ccb9SPawel Jakub Dawidek 133f827ccb9SPawel Jakub Dawidek g_topology_assert(); 134f827ccb9SPawel Jakub Dawidek 135f827ccb9SPawel Jakub Dawidek [...] 136f827ccb9SPawel Jakub Dawidek} 137f827ccb9SPawel Jakub Dawidek 138f827ccb9SPawel Jakub Dawidekstatic void 139f827ccb9SPawel Jakub Dawidekg_example_init(struct g_class *mp) 140f827ccb9SPawel Jakub Dawidek{ 141f827ccb9SPawel Jakub Dawidek 142f827ccb9SPawel Jakub Dawidek [...] 143f827ccb9SPawel Jakub Dawidek} 144f827ccb9SPawel Jakub Dawidek 145f827ccb9SPawel Jakub Dawidekstatic void 146f827ccb9SPawel Jakub Dawidekg_example_fini(struct g_class *mp) 147f827ccb9SPawel Jakub Dawidek{ 148f827ccb9SPawel Jakub Dawidek 149f827ccb9SPawel Jakub Dawidek [...] 150f827ccb9SPawel Jakub Dawidek} 151f827ccb9SPawel Jakub Dawidek 152f827ccb9SPawel Jakub Dawidekstruct g_class example_class = { 153f827ccb9SPawel Jakub Dawidek .name = "EXAMPLE", 154f827ccb9SPawel Jakub Dawidek .taste = g_example_taste, 155f827ccb9SPawel Jakub Dawidek .ctlreq = g_example_ctlreq, 156f827ccb9SPawel Jakub Dawidek .init = g_example_init, 157f827ccb9SPawel Jakub Dawidek .fini = g_example_fini, 158f827ccb9SPawel Jakub Dawidek .destroy_geom = g_example_destroy_geom 159f827ccb9SPawel Jakub Dawidek}; 160f827ccb9SPawel Jakub Dawidek 161f827ccb9SPawel Jakub DawidekDECLARE_GEOM_CLASS(example_class, g_example); 162f827ccb9SPawel Jakub Dawidek.Ed 163f827ccb9SPawel Jakub Dawidek.Sh SEE ALSO 164f827ccb9SPawel Jakub Dawidek.Xr geom 4 , 165f827ccb9SPawel Jakub Dawidek.Xr g_attach 9 , 166f827ccb9SPawel Jakub Dawidek.Xr g_bio 9 , 167f827ccb9SPawel Jakub Dawidek.Xr g_consumer 9 , 168f827ccb9SPawel Jakub Dawidek.Xr g_data 9 , 169f827ccb9SPawel Jakub Dawidek.Xr g_event 9 , 170f827ccb9SPawel Jakub Dawidek.Xr g_geom 9 , 171f827ccb9SPawel Jakub Dawidek.Xr g_provider 9 , 172f827ccb9SPawel Jakub Dawidek.Xr g_provider_by_name 9 , 173f827ccb9SPawel Jakub Dawidek.Xr g_wither_geom 9 174f827ccb9SPawel Jakub Dawidek.Sh AUTHORS 175f827ccb9SPawel Jakub Dawidek.An -nosplit 176f827ccb9SPawel Jakub DawidekThis manual page was written by 177*8a7314fcSBaptiste Daroussin.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org . 178