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.\" 25*f6c64174SChristian Brueffer.Dd April 24, 2016 266f39ea88SRuslan Ermilov.Dt G_GEOM 9 27f827ccb9SPawel Jakub Dawidek.Os 28f827ccb9SPawel Jakub Dawidek.Sh NAME 29f827ccb9SPawel Jakub Dawidek.Nm g_new_geomf , 30f827ccb9SPawel Jakub Dawidek.Nm g_destroy_geom 31f827ccb9SPawel Jakub Dawidek.Nd "geom management" 32f827ccb9SPawel Jakub Dawidek.Sh SYNOPSIS 33f827ccb9SPawel Jakub Dawidek.In geom/geom.h 34f827ccb9SPawel Jakub Dawidek.Ft "struct g_geom *" 35f827ccb9SPawel Jakub Dawidek.Fn g_new_geomf "struct g_class *mp" "const char *fmt" ... 36f827ccb9SPawel Jakub Dawidek.Ft void 37f827ccb9SPawel Jakub Dawidek.Fn g_destroy_geom "struct g_geom *gp" 38f827ccb9SPawel Jakub Dawidek.Sh DESCRIPTION 39f827ccb9SPawel Jakub DawidekThe geom (do not confuse 40f827ccb9SPawel Jakub Dawidek.Dq geom 41f827ccb9SPawel Jakub Dawidekwith 42f827ccb9SPawel Jakub Dawidek.Dq GEOM ) 43f827ccb9SPawel Jakub Dawidekis an instance of a GEOM class. 446f39ea88SRuslan ErmilovFor example: in a typical i386 456f39ea88SRuslan Ermilov.Fx 466f39ea88SRuslan Ermilovsystem, there will be one geom 47f827ccb9SPawel Jakub Dawidekof class MBR for each disk. 48f827ccb9SPawel Jakub DawidekThe geom's name is not really important, it is only used in the XML 49f827ccb9SPawel Jakub Dawidekdump and for debugging purposes. 50f827ccb9SPawel Jakub DawidekThere can be many geoms with the same name. 51f827ccb9SPawel Jakub Dawidek.Pp 52f827ccb9SPawel Jakub DawidekThe 53f827ccb9SPawel Jakub Dawidek.Fn g_new_geomf 54f827ccb9SPawel Jakub Dawidekfunction creates a new geom, which will be an instance of the class 55f827ccb9SPawel Jakub Dawidek.Fa mp . 566f39ea88SRuslan ErmilovThe geom's name is created in a 576f39ea88SRuslan Ermilov.Xr printf 3 Ns 586f39ea88SRuslan Ermilov-like way from the rest of the arguments. 59f827ccb9SPawel Jakub Dawidek.Pp 60f827ccb9SPawel Jakub DawidekThe 61f827ccb9SPawel Jakub Dawidek.Fn g_destroy_geom 62797bac4bSLukas Ertlfunction destroys the given geom immediately and cancels all related pending 63f827ccb9SPawel Jakub Dawidekevents. 64f827ccb9SPawel Jakub Dawidek.Pp 65797bac4bSLukas ErtlThe 66f827ccb9SPawel Jakub Dawidek.Vt g_geom 67797bac4bSLukas Ertlstructure 68797bac4bSLukas Ertlcontains fields that should be set by the caller after geom creation, but before 69f827ccb9SPawel Jakub Dawidekcreating any providers or consumers related to this geom (not all are required): 706f39ea88SRuslan Ermilov.Bl -tag -offset indent -width indent 71f827ccb9SPawel Jakub Dawidek.It Vt "g_start_t *" Va start 72f827ccb9SPawel Jakub DawidekPointer to a function used for I/O processing. 73f827ccb9SPawel Jakub Dawidek.It Vt "g_spoiled_t *" Va spoiled 74f827ccb9SPawel Jakub DawidekPointer to a function used for consumers spoiling. 75f827ccb9SPawel Jakub Dawidek.It Vt "g_dumpconf_t *" Va dumpconf 76f827ccb9SPawel Jakub DawidekPointer to a function used for configuration in XML format dumping. 77f827ccb9SPawel Jakub Dawidek.It Vt "g_access_t *" Va access 78f827ccb9SPawel Jakub DawidekPointer to a function used for access control. 79f827ccb9SPawel Jakub Dawidek.It Vt "g_orphan_t *" Va orphan 80f827ccb9SPawel Jakub DawidekPointer to a function used to inform about orphaned consumer. 81f827ccb9SPawel Jakub Dawidek.It Vt "g_ioctl_t *" Va ioctl 82f827ccb9SPawel Jakub DawidekPointer to a function used for handling ioctl requests. 83f827ccb9SPawel Jakub Dawidek.It Vt "void *" Va softc 84f827ccb9SPawel Jakub DawidekField for private use. 85f827ccb9SPawel Jakub Dawidek.El 86f827ccb9SPawel Jakub Dawidek.Sh RESTRICTIONS/CONDITIONS 87f827ccb9SPawel Jakub DawidekIf you intend to use providers in this geom you must set field 88f827ccb9SPawel Jakub Dawidek.Va start 89f827ccb9SPawel Jakub Dawidekof your geom. 90f827ccb9SPawel Jakub Dawidek.Pp 91f827ccb9SPawel Jakub DawidekIf you are planning to use consumers in your geom you must set fields 92f827ccb9SPawel Jakub Dawidek.Va orphan 93f827ccb9SPawel Jakub Dawidekand 94f827ccb9SPawel Jakub Dawidek.Va access 95f827ccb9SPawel Jakub Dawidekfor it. 96f827ccb9SPawel Jakub Dawidek.Pp 97f827ccb9SPawel Jakub Dawidek.Fn g_new_geomf : 98f827ccb9SPawel Jakub Dawidek.Bl -item -offset indent 99f827ccb9SPawel Jakub Dawidek.It 100f827ccb9SPawel Jakub DawidekClass 101f827ccb9SPawel Jakub Dawidek.Fa mp 102f827ccb9SPawel Jakub Dawidekmust be valid (registered in GEOM). 103f827ccb9SPawel Jakub Dawidek.It 104f827ccb9SPawel Jakub DawidekThe topology lock has to be held. 105f827ccb9SPawel Jakub Dawidek.El 106f827ccb9SPawel Jakub Dawidek.Pp 107f827ccb9SPawel Jakub Dawidek.Fn g_destroy_geom : 108f827ccb9SPawel Jakub Dawidek.Bl -item -offset indent 109f827ccb9SPawel Jakub Dawidek.It 110c2025a76SJoel DahlThe geom cannot possess any providers. 111f827ccb9SPawel Jakub Dawidek.It 112c2025a76SJoel DahlThe geom cannot possess any consumers. 113f827ccb9SPawel Jakub Dawidek.It 114f827ccb9SPawel Jakub DawidekThe topology lock has to be held. 115f827ccb9SPawel Jakub Dawidek.El 116f827ccb9SPawel Jakub Dawidek.Sh RETURN VALUES 1176f39ea88SRuslan ErmilovThe 118f827ccb9SPawel Jakub Dawidek.Fn g_new_geomf 1196f39ea88SRuslan Ermilovfunction 12006bb88dcSPawel Jakub Dawidekreturns a pointer to the newly created geom. 121f827ccb9SPawel Jakub Dawidek.Sh EXAMPLES 122f827ccb9SPawel Jakub DawidekCreate an example geom. 123f827ccb9SPawel Jakub Dawidek.Bd -literal -offset indent 124*f6c64174SChristian Bruefferstatic void 125f827ccb9SPawel Jakub Dawidekg_example_start(struct bio *bp) 126f827ccb9SPawel Jakub Dawidek{ 127f827ccb9SPawel Jakub Dawidek 128f827ccb9SPawel Jakub Dawidek [...] 129f827ccb9SPawel Jakub Dawidek} 130f827ccb9SPawel Jakub Dawidek 131f827ccb9SPawel Jakub Dawidekstatic void 132f827ccb9SPawel Jakub Dawidekg_example_orphan(struct g_consumer *cp) 133f827ccb9SPawel Jakub Dawidek{ 134f827ccb9SPawel Jakub Dawidek 135f827ccb9SPawel Jakub Dawidek g_topology_assert(); 136f827ccb9SPawel Jakub Dawidek 137f827ccb9SPawel Jakub Dawidek [...] 138f827ccb9SPawel Jakub Dawidek} 139f827ccb9SPawel Jakub Dawidek 140f827ccb9SPawel Jakub Dawidekstatic void 141f827ccb9SPawel Jakub Dawidekg_example_spoiled(struct g_consumer *cp) 142f827ccb9SPawel Jakub Dawidek{ 143f827ccb9SPawel Jakub Dawidek 144f827ccb9SPawel Jakub Dawidek g_topology_assert(); 145f827ccb9SPawel Jakub Dawidek 146f827ccb9SPawel Jakub Dawidek [...] 147f827ccb9SPawel Jakub Dawidek} 148f827ccb9SPawel Jakub Dawidek 149*f6c64174SChristian Bruefferstatic int 150f827ccb9SPawel Jakub Dawidekg_example_access(struct g_provider *pp, int dr, int dw, int de) 151f827ccb9SPawel Jakub Dawidek{ 152f827ccb9SPawel Jakub Dawidek 153f827ccb9SPawel Jakub Dawidek [...] 154f827ccb9SPawel Jakub Dawidek} 155f827ccb9SPawel Jakub Dawidek 156f827ccb9SPawel Jakub Dawidekstatic struct g_geom * 157f827ccb9SPawel Jakub Dawidekcreate_example_geom(struct g_class *myclass) 158f827ccb9SPawel Jakub Dawidek{ 159f827ccb9SPawel Jakub Dawidek struct g_geom *gp; 160f827ccb9SPawel Jakub Dawidek 161f827ccb9SPawel Jakub Dawidek g_topology_lock(); 162f827ccb9SPawel Jakub Dawidek gp = g_new_geomf(myclass, "example_geom"); 163f827ccb9SPawel Jakub Dawidek g_topology_unlock(); 164f827ccb9SPawel Jakub Dawidek gp->start = g_example_start; 165f827ccb9SPawel Jakub Dawidek gp->orphan = g_example_orphan; 166f827ccb9SPawel Jakub Dawidek gp->spoiled = g_example_spoiled; 167f827ccb9SPawel Jakub Dawidek gp->access = g_example_access; 168f827ccb9SPawel Jakub Dawidek gp->softc = NULL; 169f827ccb9SPawel Jakub Dawidek 170f827ccb9SPawel Jakub Dawidek return (gp); 171f827ccb9SPawel Jakub Dawidek} 172f827ccb9SPawel Jakub Dawidek 173f827ccb9SPawel Jakub Dawidekstatic int 174f827ccb9SPawel Jakub Dawidekdestroy_example_geom(struct g_geom *gp) 175f827ccb9SPawel Jakub Dawidek{ 176f827ccb9SPawel Jakub Dawidek 177f827ccb9SPawel Jakub Dawidek g_topology_lock(); 178f827ccb9SPawel Jakub Dawidek if (!LIST_EMPTY(&gp->provider) || 179f827ccb9SPawel Jakub Dawidek !LIST_EMPTY(&gp->consumer)) { 180f827ccb9SPawel Jakub Dawidek g_topology_unlock(); 181f827ccb9SPawel Jakub Dawidek return (EBUSY); 182f827ccb9SPawel Jakub Dawidek } 183f827ccb9SPawel Jakub Dawidek g_destroy_geom(gp); 184f827ccb9SPawel Jakub Dawidek g_topology_unlock(); 185f827ccb9SPawel Jakub Dawidek 186f827ccb9SPawel Jakub Dawidek return (0); 187f827ccb9SPawel Jakub Dawidek} 188f827ccb9SPawel Jakub Dawidek.Ed 189f827ccb9SPawel Jakub Dawidek.Sh SEE ALSO 190f827ccb9SPawel Jakub Dawidek.Xr geom 4 , 1911c85060aSRuslan Ermilov.Xr DECLARE_GEOM_CLASS 9 , 1928217df6dSPawel Jakub Dawidek.Xr g_access 9 , 193f827ccb9SPawel Jakub Dawidek.Xr g_attach 9 , 194f827ccb9SPawel Jakub Dawidek.Xr g_bio 9 , 195f827ccb9SPawel Jakub Dawidek.Xr g_consumer 9 , 196f827ccb9SPawel Jakub Dawidek.Xr g_data 9 , 197f827ccb9SPawel Jakub Dawidek.Xr g_event 9 , 198f827ccb9SPawel Jakub Dawidek.Xr g_provider 9 , 199f827ccb9SPawel Jakub Dawidek.Xr g_provider_by_name 9 , 200f827ccb9SPawel Jakub Dawidek.Xr g_wither_geom 9 201f827ccb9SPawel Jakub Dawidek.Sh AUTHORS 202f827ccb9SPawel Jakub Dawidek.An -nosplit 203f827ccb9SPawel Jakub DawidekThis manual page was written by 2048a7314fcSBaptiste Daroussin.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org . 205