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.\" 25f827ccb9SPawel Jakub Dawidek.\" $FreeBSD$ 26f827ccb9SPawel Jakub Dawidek.\" 27f827ccb9SPawel Jakub Dawidek.Dd January 16, 2004 28f827ccb9SPawel Jakub Dawidek.Dt g_geom 9 29f827ccb9SPawel Jakub Dawidek.Os 30f827ccb9SPawel Jakub Dawidek.Sh NAME 31f827ccb9SPawel Jakub Dawidek.Nm g_new_geomf , 32f827ccb9SPawel Jakub Dawidek.Nm g_destroy_geom 33f827ccb9SPawel Jakub Dawidek.Nd "geom management" 34f827ccb9SPawel Jakub Dawidek.Sh SYNOPSIS 35f827ccb9SPawel Jakub Dawidek.In geom/geom.h 36f827ccb9SPawel Jakub Dawidek.Ft "struct g_geom *" 37f827ccb9SPawel Jakub Dawidek.Fn g_new_geomf "struct g_class *mp" "const char *fmt" ... 38f827ccb9SPawel Jakub Dawidek.Ft void 39f827ccb9SPawel Jakub Dawidek.Fn g_destroy_geom "struct g_geom *gp" 40f827ccb9SPawel Jakub Dawidek.Sh DESCRIPTION 41f827ccb9SPawel Jakub DawidekThe geom (do not confuse 42f827ccb9SPawel Jakub Dawidek.Dq geom 43f827ccb9SPawel Jakub Dawidekwith 44f827ccb9SPawel Jakub Dawidek.Dq GEOM ) 45f827ccb9SPawel Jakub Dawidekis an instance of a GEOM class. 46f827ccb9SPawel Jakub DawidekFor example: in a typical i386 FreeBSD system, 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 . 56a2d7d4d7SLukas ErtlThe geom's name is created in a printf-like way from the rest of the arguments. 57f827ccb9SPawel Jakub Dawidek.Pp 58f827ccb9SPawel Jakub DawidekThe 59f827ccb9SPawel Jakub Dawidek.Fn g_destroy_geom 60797bac4bSLukas Ertlfunction destroys the given geom immediately and cancels all related pending 61f827ccb9SPawel Jakub Dawidekevents. 62f827ccb9SPawel Jakub Dawidek.Pp 63797bac4bSLukas ErtlThe 64f827ccb9SPawel Jakub Dawidek.Vt g_geom 65797bac4bSLukas Ertlstructure 66797bac4bSLukas Ertlcontains fields that should be set by the caller after geom creation, but before 67f827ccb9SPawel Jakub Dawidekcreating any providers or consumers related to this geom (not all are required): 68f827ccb9SPawel Jakub Dawidek.Bl -inset -offset indent 69f827ccb9SPawel Jakub Dawidek.It Vt "g_start_t *" Va start 70f827ccb9SPawel Jakub DawidekPointer to a function used for I/O processing. 71f827ccb9SPawel Jakub Dawidek.It Vt "g_spoiled_t *" Va spoiled 72f827ccb9SPawel Jakub DawidekPointer to a function used for consumers spoiling. 73f827ccb9SPawel Jakub Dawidek.It Vt "g_dumpconf_t *" Va dumpconf 74f827ccb9SPawel Jakub DawidekPointer to a function used for configuration in XML format dumping. 75f827ccb9SPawel Jakub Dawidek.It Vt "g_access_t *" Va access 76f827ccb9SPawel Jakub DawidekPointer to a function used for access control. 77f827ccb9SPawel Jakub Dawidek.It Vt "g_orphan_t *" Va orphan 78f827ccb9SPawel Jakub DawidekPointer to a function used to inform about orphaned consumer. 79f827ccb9SPawel Jakub Dawidek.It Vt "g_ioctl_t *" Va ioctl 80f827ccb9SPawel Jakub DawidekPointer to a function used for handling ioctl requests. 81f827ccb9SPawel Jakub Dawidek.It Vt "void *" Va softc 82f827ccb9SPawel Jakub DawidekField for private use. 83f827ccb9SPawel Jakub Dawidek.El 84f827ccb9SPawel Jakub Dawidek.Sh RESTRICTIONS/CONDITIONS 85f827ccb9SPawel Jakub DawidekIf you intend to use providers in this geom you must set field 86f827ccb9SPawel Jakub Dawidek.Va start 87f827ccb9SPawel Jakub Dawidekof your geom. 88f827ccb9SPawel Jakub Dawidek.Pp 89f827ccb9SPawel Jakub DawidekIf you are planning to use consumers in your geom you must set fields 90f827ccb9SPawel Jakub Dawidek.Va orphan 91f827ccb9SPawel Jakub Dawidekand 92f827ccb9SPawel Jakub Dawidek.Va access 93f827ccb9SPawel Jakub Dawidekfor it. 94f827ccb9SPawel Jakub Dawidek.Pp 95f827ccb9SPawel Jakub Dawidek.Fn g_new_geomf : 96f827ccb9SPawel Jakub Dawidek.Bl -item -offset indent 97f827ccb9SPawel Jakub Dawidek.It 98f827ccb9SPawel Jakub DawidekClass 99f827ccb9SPawel Jakub Dawidek.Fa mp 100f827ccb9SPawel Jakub Dawidekmust be valid (registered in GEOM). 101f827ccb9SPawel Jakub Dawidek.It 102f827ccb9SPawel Jakub DawidekThe topology lock has to be held. 103f827ccb9SPawel Jakub Dawidek.El 104f827ccb9SPawel Jakub Dawidek.Pp 105f827ccb9SPawel Jakub Dawidek.Fn g_destroy_geom : 106f827ccb9SPawel Jakub Dawidek.Bl -item -offset indent 107f827ccb9SPawel Jakub Dawidek.It 108f827ccb9SPawel Jakub DawidekThe geom can not posses any providers. 109f827ccb9SPawel Jakub Dawidek.It 110f827ccb9SPawel Jakub DawidekThe geom can not posses any consumers. 111f827ccb9SPawel Jakub Dawidek.It 112f827ccb9SPawel Jakub DawidekThe topology lock has to be held. 113f827ccb9SPawel Jakub Dawidek.El 114f827ccb9SPawel Jakub Dawidek.Sh RETURN VALUES 115f827ccb9SPawel Jakub Dawidek.Fn g_new_geomf 11606bb88dcSPawel Jakub Dawidekreturns a pointer to the newly created geom. 117f827ccb9SPawel Jakub Dawidek.Sh EXAMPLES 118f827ccb9SPawel Jakub DawidekCreate an example geom. 119f827ccb9SPawel Jakub Dawidek.Bd -literal -offset indent 120f827ccb9SPawel Jakub Dawidekstatic struct geom * 121f827ccb9SPawel Jakub Dawidekg_example_start(struct bio *bp) 122f827ccb9SPawel Jakub Dawidek{ 123f827ccb9SPawel Jakub Dawidek 124f827ccb9SPawel Jakub Dawidek [...] 125f827ccb9SPawel Jakub Dawidek} 126f827ccb9SPawel Jakub Dawidek 127f827ccb9SPawel Jakub Dawidekstatic void 128f827ccb9SPawel Jakub Dawidekg_example_orphan(struct g_consumer *cp) 129f827ccb9SPawel Jakub Dawidek{ 130f827ccb9SPawel Jakub Dawidek 131f827ccb9SPawel Jakub Dawidek g_topology_assert(); 132f827ccb9SPawel Jakub Dawidek 133f827ccb9SPawel Jakub Dawidek [...] 134f827ccb9SPawel Jakub Dawidek} 135f827ccb9SPawel Jakub Dawidek 136f827ccb9SPawel Jakub Dawidekstatic void 137f827ccb9SPawel Jakub Dawidekg_example_spoiled(struct g_consumer *cp) 138f827ccb9SPawel Jakub Dawidek{ 139f827ccb9SPawel Jakub Dawidek 140f827ccb9SPawel Jakub Dawidek g_topology_assert(); 141f827ccb9SPawel Jakub Dawidek 142f827ccb9SPawel Jakub Dawidek [...] 143f827ccb9SPawel Jakub Dawidek} 144f827ccb9SPawel Jakub Dawidek 145f827ccb9SPawel Jakub Dawidekstatic void 146f827ccb9SPawel Jakub Dawidekg_example_access(struct g_provider *pp, int dr, int dw, int de) 147f827ccb9SPawel Jakub Dawidek{ 148f827ccb9SPawel Jakub Dawidek 149f827ccb9SPawel Jakub Dawidek [...] 150f827ccb9SPawel Jakub Dawidek} 151f827ccb9SPawel Jakub Dawidek 152f827ccb9SPawel Jakub Dawidekstatic struct g_geom * 153f827ccb9SPawel Jakub Dawidekcreate_example_geom(struct g_class *myclass) 154f827ccb9SPawel Jakub Dawidek{ 155f827ccb9SPawel Jakub Dawidek struct g_geom *gp; 156f827ccb9SPawel Jakub Dawidek 157f827ccb9SPawel Jakub Dawidek g_topology_lock(); 158f827ccb9SPawel Jakub Dawidek gp = g_new_geomf(myclass, "example_geom"); 159f827ccb9SPawel Jakub Dawidek g_topology_unlock(); 160f827ccb9SPawel Jakub Dawidek gp->start = g_example_start; 161f827ccb9SPawel Jakub Dawidek gp->orphan = g_example_orphan; 162f827ccb9SPawel Jakub Dawidek gp->spoiled = g_example_spoiled; 163f827ccb9SPawel Jakub Dawidek gp->access = g_example_access; 164f827ccb9SPawel Jakub Dawidek gp->softc = NULL; 165f827ccb9SPawel Jakub Dawidek 166f827ccb9SPawel Jakub Dawidek return (gp); 167f827ccb9SPawel Jakub Dawidek} 168f827ccb9SPawel Jakub Dawidek 169f827ccb9SPawel Jakub Dawidekstatic int 170f827ccb9SPawel Jakub Dawidekdestroy_example_geom(struct g_geom *gp) 171f827ccb9SPawel Jakub Dawidek{ 172f827ccb9SPawel Jakub Dawidek 173f827ccb9SPawel Jakub Dawidek g_topology_lock(); 174f827ccb9SPawel Jakub Dawidek if (!LIST_EMPTY(&gp->provider) || 175f827ccb9SPawel Jakub Dawidek !LIST_EMPTY(&gp->consumer)) { 176f827ccb9SPawel Jakub Dawidek g_topology_unlock(); 177f827ccb9SPawel Jakub Dawidek return (EBUSY); 178f827ccb9SPawel Jakub Dawidek } 179f827ccb9SPawel Jakub Dawidek g_destroy_geom(gp); 180f827ccb9SPawel Jakub Dawidek g_topology_unlock(); 181f827ccb9SPawel Jakub Dawidek 182f827ccb9SPawel Jakub Dawidek return (0); 183f827ccb9SPawel Jakub Dawidek} 184f827ccb9SPawel Jakub Dawidek.Ed 185f827ccb9SPawel Jakub Dawidek.Sh SEE ALSO 186f827ccb9SPawel Jakub Dawidek.Xr geom 4 , 1871c85060aSRuslan Ermilov.Xr DECLARE_GEOM_CLASS 9 , 1888217df6dSPawel Jakub Dawidek.Xr g_access 9 , 189f827ccb9SPawel Jakub Dawidek.Xr g_attach 9 , 190f827ccb9SPawel Jakub Dawidek.Xr g_bio 9 , 191f827ccb9SPawel Jakub Dawidek.Xr g_consumer 9 , 192f827ccb9SPawel Jakub Dawidek.Xr g_data 9 , 193f827ccb9SPawel Jakub Dawidek.Xr g_event 9 , 194f827ccb9SPawel Jakub Dawidek.Xr g_provider 9 , 195f827ccb9SPawel Jakub Dawidek.Xr g_provider_by_name 9 , 196f827ccb9SPawel Jakub Dawidek.Xr g_wither_geom 9 197f827ccb9SPawel Jakub Dawidek.Sh AUTHORS 198f827ccb9SPawel Jakub Dawidek.An -nosplit 199f827ccb9SPawel Jakub DawidekThis manual page was written by 200f827ccb9SPawel Jakub Dawidek.An Pawel Jakub Dawidek Aq pjd@FreeBSD.org . 201