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_provider 9 29f827ccb9SPawel Jakub Dawidek.Os 30f827ccb9SPawel Jakub Dawidek.Sh NAME 31f827ccb9SPawel Jakub Dawidek.Nm g_new_providerf , 32f827ccb9SPawel Jakub Dawidek.Nm g_destroy_provider , 33f827ccb9SPawel Jakub Dawidek.Nm g_error_provider 34f827ccb9SPawel Jakub Dawidek.Nd "GEOM providers management" 35f827ccb9SPawel Jakub Dawidek.Sh SYNOPSIS 36f827ccb9SPawel Jakub Dawidek.In geom/geom.h 37f827ccb9SPawel Jakub Dawidek.Ft "struct g_provider *" 38f827ccb9SPawel Jakub Dawidek.Fn g_new_providerf "struct g_geom *gp" "const char *fmt" ... 39f827ccb9SPawel Jakub Dawidek.Ft void 40f827ccb9SPawel Jakub Dawidek.Fn g_destroy_provider "struct g_provider *pp" 41f827ccb9SPawel Jakub Dawidek.Ft void 42f827ccb9SPawel Jakub Dawidek.Fn g_error_provider "struct g_provider *pp" "int error" 43f827ccb9SPawel Jakub Dawidek.Sh DESCRIPTION 44f827ccb9SPawel Jakub DawidekThe GEOM provider is the front gate at which a geom offers service. 45f827ccb9SPawel Jakub DawidekA provider is 46f827ccb9SPawel Jakub Dawidek.Dq a disk\-like thing which appears in Pa /dev 47f827ccb9SPawel Jakub Dawidek\- a logical disk in other words. 48f827ccb9SPawel Jakub DawidekAll providers have three main properties: name, sectorsize and size. 49f827ccb9SPawel Jakub Dawidek.Pp 50f827ccb9SPawel Jakub DawidekThe 51f827ccb9SPawel Jakub Dawidek.Fn g_new_providerf 52f827ccb9SPawel Jakub Dawidekfunction creates a new provider and attaches it to geom 53f827ccb9SPawel Jakub Dawidek.Fa gp . 54f827ccb9SPawel Jakub DawidekThe provider name is created in a printf\-like way from the rest of 55f827ccb9SPawel Jakub Dawidekthe arguments. 56f827ccb9SPawel Jakub DawidekAfter creation, the provider is unusable, because 57f827ccb9SPawel Jakub Dawidek.Fn g_new_providerf 58f827ccb9SPawel Jakub Dawideksets its error to 59f827ccb9SPawel Jakub Dawidek.Er ENXIO . 60f827ccb9SPawel Jakub DawidekThe function 61f827ccb9SPawel Jakub Dawidek.Fn g_error_provider 62f827ccb9SPawel Jakub Dawidekshould be used to reset this error, but before it is called, two 63f827ccb9SPawel Jakub Dawidekfields should be set in the provider structure: 64f827ccb9SPawel Jakub Dawidek.Va mediasize 65f827ccb9SPawel Jakub Dawidekand 66f827ccb9SPawel Jakub Dawidek.Va sectorsize 67f827ccb9SPawel Jakub Dawidekas well as other initialization things should be done first. 68f827ccb9SPawel Jakub Dawidek.Pp 69f827ccb9SPawel Jakub DawidekThe 70f827ccb9SPawel Jakub Dawidek.Fn g_destroy_provider 71f827ccb9SPawel Jakub Dawidekfunction destroys the given provider, cancels all related pending events and 72f827ccb9SPawel Jakub Dawidekremoves corresponding devfs entry. 73f827ccb9SPawel Jakub Dawidek.Pp 74f827ccb9SPawel Jakub DawidekThe 75f827ccb9SPawel Jakub Dawidek.Fn g_error_provider 76f827ccb9SPawel Jakub Dawidekfunction is used to set a provider error value. 77f827ccb9SPawel Jakub DawidekIf it set to a nonzero value, all I/O requests will be denied, 78f827ccb9SPawel Jakub Dawidekincreasing its access count will not be possible (error 79f827ccb9SPawel Jakub Dawidek.Fa error 80f827ccb9SPawel Jakub Dawidekwill be returned). 81f827ccb9SPawel Jakub Dawidek.Sh RESTRICTIONS/CONDITIONS 82f827ccb9SPawel Jakub Dawidek.Fn g_new_provider : 83f827ccb9SPawel Jakub Dawidek.Bl -item -offset indent 84f827ccb9SPawel Jakub Dawidek.It 85f827ccb9SPawel Jakub DawidekThe provider name should be unique, but this is not enforced by GEOM. 86f827ccb9SPawel Jakub DawidekIf the name is not unique, one will end up with two (or more) files 87f827ccb9SPawel Jakub Dawidekwith the same name, which is programmer error. 88f827ccb9SPawel Jakub Dawidek.It 89f827ccb9SPawel Jakub DawidekThe geom related to the created provider must have 90f827ccb9SPawel Jakub Dawidek.Fa start 91f827ccb9SPawel Jakub Dawidekfield defined. 92f827ccb9SPawel Jakub Dawidek.It 93f827ccb9SPawel Jakub DawidekThe topology lock has to be held. 94f827ccb9SPawel Jakub Dawidek.El 95f827ccb9SPawel Jakub Dawidek.Pp 96f827ccb9SPawel Jakub Dawidek.Fn g_destroy_provider : 97f827ccb9SPawel Jakub Dawidek.Bl -item -offset indent 98f827ccb9SPawel Jakub Dawidek.It 99f827ccb9SPawel Jakub DawidekNo consumers have to be attached. 100f827ccb9SPawel Jakub Dawidek.It 101f827ccb9SPawel Jakub DawidekThe access count has to be 0. 102f827ccb9SPawel Jakub Dawidek.It 103f827ccb9SPawel Jakub DawidekThe topology lock has to be held. 104f827ccb9SPawel Jakub Dawidek.El 105f827ccb9SPawel Jakub Dawidek.Sh RETURN VALUES 106f827ccb9SPawel Jakub Dawidek.Fn g_new_providerf 10706bb88dcSPawel Jakub Dawidekreturns a pointer to the newly created provider. 108f827ccb9SPawel Jakub Dawidek.Sh EXAMPLES 109f827ccb9SPawel Jakub DawidekCreate an example provider, set its parameters and make it usable. 110f827ccb9SPawel Jakub Dawidek.Bd -literal -offset indent 111f827ccb9SPawel Jakub Dawidekstruct g_provider * 112f827ccb9SPawel Jakub Dawidekcreate_example_provider(struct g_geom *gp) 113f827ccb9SPawel Jakub Dawidek{ 114f827ccb9SPawel Jakub Dawidek struct g_provider *pp; 115f827ccb9SPawel Jakub Dawidek 116f827ccb9SPawel Jakub Dawidek g_topology_lock(); 117f827ccb9SPawel Jakub Dawidek pp = g_new_providerf(gp, "example_provider"); 118030f6f35SPawel Jakub Dawidek g_topology_unlock(); 119f827ccb9SPawel Jakub Dawidek pp->mediasize = 65536; 120f827ccb9SPawel Jakub Dawidek pp->sectorsize = 512; 121f827ccb9SPawel Jakub Dawidek g_error_provider(pp, 0); 122f827ccb9SPawel Jakub Dawidek 123f827ccb9SPawel Jakub Dawidek return (pp); 124f827ccb9SPawel Jakub Dawidek} 125f827ccb9SPawel Jakub Dawidek.Ed 126f827ccb9SPawel Jakub Dawidek.Sh SEE ALSO 127f827ccb9SPawel Jakub Dawidek.Xr DECLARE_GEOM_CLASS 9 , 128f827ccb9SPawel Jakub Dawidek.Xr geom 4 , 1298217df6dSPawel Jakub Dawidek.Xr g_access 9 , 130f827ccb9SPawel Jakub Dawidek.Xr g_attach 9 , 131f827ccb9SPawel Jakub Dawidek.Xr g_bio 9 , 132f827ccb9SPawel Jakub Dawidek.Xr g_consumer 9 , 133f827ccb9SPawel Jakub Dawidek.Xr g_data 9 , 134f827ccb9SPawel Jakub Dawidek.Xr g_event 9 , 135f827ccb9SPawel Jakub Dawidek.Xr g_geom 9 , 136f827ccb9SPawel Jakub Dawidek.Xr g_provider_by_name 9 , 137f827ccb9SPawel Jakub Dawidek.Xr g_wither_geom 9 138f827ccb9SPawel Jakub Dawidek.Sh AUTHORS 139f827ccb9SPawel Jakub Dawidek.An -nosplit 140f827ccb9SPawel Jakub DawidekThis manual page was written by 141f827ccb9SPawel Jakub Dawidek.An Pawel Jakub Dawidek Aq pjd@FreeBSD.org . 142