xref: /freebsd/share/man/man9/g_provider.9 (revision 2008043f386721d58158e37e0d7e50df8095942d)
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.Dd January 16, 2004
26.Dt G_PROVIDER 9
27.Os
28.Sh NAME
29.Nm g_new_providerf ,
30.Nm g_destroy_provider ,
31.Nm g_error_provider
32.Nd "GEOM providers management"
33.Sh SYNOPSIS
34.In geom/geom.h
35.Ft "struct g_provider *"
36.Fn g_new_providerf "struct g_geom *gp" "const char *fmt" ...
37.Ft void
38.Fn g_destroy_provider "struct g_provider *pp"
39.Ft void
40.Fn g_error_provider "struct g_provider *pp" "int error"
41.Sh DESCRIPTION
42A GEOM provider is the front gate at which a geom offers service.
43A provider is
44.Dq a disk-like thing which appears in Pa /dev
45\[en] a logical disk in other words.
46All providers have three main properties: name, sectorsize and size.
47.Pp
48The
49.Fn g_new_providerf
50function creates a new provider on given geom
51.Fa gp .
52The name of the provider, which will appear as device in
53.Xr devfs 5 ,
54is created
55in a
56.Xr printf 3 Ns
57-like way from the rest of
58the arguments.
59After creation, the caller has to set the provider's
60.Va mediasize
61and
62.Va sectorsize ,
63as well as other desired initializations, and then call
64.Fn g_error_provider
65to reset the provider's error, which is initially set to
66.Er ENXIO .
67.Pp
68The
69.Fn g_destroy_provider
70function destroys the given provider, cancels all related pending events and
71removes the corresponding devfs entry.
72.Pp
73The
74.Fn g_error_provider
75function is used to set the provider's error value.
76If set to a nonzero, all I/O requests will be denied,
77as well as increasing its access count will not be possible (error
78.Fa error
79will be returned).
80.Sh RESTRICTIONS/CONDITIONS
81.Fn g_new_provider :
82.Bl -item -offset indent
83.It
84The provider name should be unique, but this is not enforced by GEOM.
85If the name is not unique, one will end up with two (or more) files
86with the same name, which is a programmer error.
87.It
88The geom
89.Fa gp
90has to have a
91.Fa start
92method defined.
93.It
94The topology lock has to be held.
95.El
96.Pp
97.Fn g_destroy_provider :
98.Bl -item -offset indent
99.It
100The provider must not have consumers attached.
101.It
102The access count has to be 0.
103.It
104The topology lock has to be held.
105.El
106.Sh RETURN VALUES
107The
108.Fn g_new_providerf
109function returns a pointer to the newly created provider.
110.Sh EXAMPLES
111Create an example provider, set its parameters and make it usable.
112.Bd -literal -offset indent
113struct g_provider *
114create_example_provider(struct g_geom *gp)
115{
116	struct g_provider *pp;
117
118	g_topology_lock();
119	pp = g_new_providerf(gp, "example_provider");
120	g_topology_unlock();
121	pp->mediasize = 65536;
122	pp->sectorsize = 512;
123	g_error_provider(pp, 0);
124
125	return (pp);
126}
127.Ed
128.Sh SEE ALSO
129.Xr geom 4 ,
130.Xr DECLARE_GEOM_CLASS 9 ,
131.Xr g_access 9 ,
132.Xr g_attach 9 ,
133.Xr g_bio 9 ,
134.Xr g_consumer 9 ,
135.Xr g_data 9 ,
136.Xr g_event 9 ,
137.Xr g_geom 9 ,
138.Xr g_provider_by_name 9 ,
139.Xr g_wither_geom 9
140.Sh AUTHORS
141.An -nosplit
142This manual page was written by
143.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org .
144