xref: /freebsd/share/man/man9/g_provider.9 (revision 62cfcf62f627e5093fb37026a6d8c98e4d2ef04c)
1.\"
2.\" Copyright (c) 2004 Pawel Jakub Dawidek <pjd@FreeBSD.org>
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
15.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
18.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24.\"
25.\" $FreeBSD$
26.\"
27.Dd January 16, 2004
28.Dt G_PROVIDER 9
29.Os
30.Sh NAME
31.Nm g_new_providerf ,
32.Nm g_destroy_provider ,
33.Nm g_error_provider
34.Nd "GEOM providers management"
35.Sh SYNOPSIS
36.In geom/geom.h
37.Ft "struct g_provider *"
38.Fn g_new_providerf "struct g_geom *gp" "const char *fmt" ...
39.Ft void
40.Fn g_destroy_provider "struct g_provider *pp"
41.Ft void
42.Fn g_error_provider "struct g_provider *pp" "int error"
43.Sh DESCRIPTION
44A GEOM provider is the front gate at which a geom offers service.
45A provider is
46.Dq a disk-like thing which appears in Pa /dev
47\[en] a logical disk in other words.
48All providers have three main properties: name, sectorsize and size.
49.Pp
50The
51.Fn g_new_providerf
52function creates a new provider on given geom
53.Fa gp .
54The name of the provider, which will appear as device in
55.Xr devfs 5 ,
56is created
57in a
58.Xr printf 3 Ns
59-like way from the rest of
60the arguments.
61After creation, the caller has to set the provider's
62.Va mediasize
63and
64.Va sectorsize ,
65as well as other desired initializations, and then call
66.Fn g_error_provider
67to reset the provider's error, which is initially set to
68.Er ENXIO .
69.Pp
70The
71.Fn g_destroy_provider
72function destroys the given provider, cancels all related pending events and
73removes the corresponding devfs entry.
74.Pp
75The
76.Fn g_error_provider
77function is used to set the provider's error value.
78If set to a nonzero, all I/O requests will be denied,
79as well as increasing its access count will not be possible (error
80.Fa error
81will be returned).
82.Sh RESTRICTIONS/CONDITIONS
83.Fn g_new_provider :
84.Bl -item -offset indent
85.It
86The provider name should be unique, but this is not enforced by GEOM.
87If the name is not unique, one will end up with two (or more) files
88with the same name, which is a programmer error.
89.It
90The geom
91.Fa gp
92has to have a
93.Fa start
94method defined.
95.It
96The topology lock has to be held.
97.El
98.Pp
99.Fn g_destroy_provider :
100.Bl -item -offset indent
101.It
102The provider must not have consumers attached.
103.It
104The access count has to be 0.
105.It
106The topology lock has to be held.
107.El
108.Sh RETURN VALUES
109The
110.Fn g_new_providerf
111function returns a pointer to the newly created provider.
112.Sh EXAMPLES
113Create an example provider, set its parameters and make it usable.
114.Bd -literal -offset indent
115struct g_provider *
116create_example_provider(struct g_geom *gp)
117{
118	struct g_provider *pp;
119
120	g_topology_lock();
121	pp = g_new_providerf(gp, "example_provider");
122	g_topology_unlock();
123	pp->mediasize = 65536;
124	pp->sectorsize = 512;
125	g_error_provider(pp, 0);
126
127	return (pp);
128}
129.Ed
130.Sh SEE ALSO
131.Xr geom 4 ,
132.Xr DECLARE_GEOM_CLASS 9 ,
133.Xr g_access 9 ,
134.Xr g_attach 9 ,
135.Xr g_bio 9 ,
136.Xr g_consumer 9 ,
137.Xr g_data 9 ,
138.Xr g_event 9 ,
139.Xr g_geom 9 ,
140.Xr g_provider_by_name 9 ,
141.Xr g_wither_geom 9
142.Sh AUTHORS
143.An -nosplit
144This manual page was written by
145.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org .
146