xref: /freebsd/share/man/man9/g_provider.9 (revision d37ea99837e6ad50837fd9fe1771ddf1c3ba6002)
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\- 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 devfs, is created
55in a printf-like way from the rest of
56the arguments.
57After creation, the caller has to set the provider's
58.Va mediasize
59and
60.Va sectorsize ,
61as well as other desired initializations, and then call
62.Fn g_error_provider
63to reset the provider's error, which is initially set to
64.Er ENXIO .
65.Pp
66The
67.Fn g_destroy_provider
68function destroys the given provider, cancels all related pending events and
69removes the corresponding devfs entry.
70.Pp
71The
72.Fn g_error_provider
73function is used to set the provider's error value.
74If set to a nonzero, all I/O requests will be denied,
75as well as increasing its access count will not be possible (error
76.Fa error
77will be returned).
78.Sh RESTRICTIONS/CONDITIONS
79.Fn g_new_provider :
80.Bl -item -offset indent
81.It
82The provider name should be unique, but this is not enforced by GEOM.
83If the name is not unique, one will end up with two (or more) files
84with the same name, which is a programmer error.
85.It
86The geom
87.Fa gp
88has to have a
89.Fa start
90method defined.
91.It
92The topology lock has to be held.
93.El
94.Pp
95.Fn g_destroy_provider :
96.Bl -item -offset indent
97.It
98The provider must not have consumers attached.
99.It
100The access count has to be 0.
101.It
102The topology lock has to be held.
103.El
104.Sh RETURN VALUES
105The
106.Fn g_new_providerf
107function returns a pointer to the newly created provider.
108.Sh EXAMPLES
109Create an example provider, set its parameters and make it usable.
110.Bd -literal -offset indent
111struct g_provider *
112create_example_provider(struct g_geom *gp)
113{
114	struct g_provider *pp;
115
116	g_topology_lock();
117	pp = g_new_providerf(gp, "example_provider");
118	g_topology_unlock();
119	pp->mediasize = 65536;
120	pp->sectorsize = 512;
121	g_error_provider(pp, 0);
122
123	return (pp);
124}
125.Ed
126.Sh SEE ALSO
127.Xr DECLARE_GEOM_CLASS 9 ,
128.Xr geom 4 ,
129.Xr g_access 9 ,
130.Xr g_attach 9 ,
131.Xr g_bio 9 ,
132.Xr g_consumer 9 ,
133.Xr g_data 9 ,
134.Xr g_event 9 ,
135.Xr g_geom 9 ,
136.Xr g_provider_by_name 9 ,
137.Xr g_wither_geom 9
138.Sh AUTHORS
139.An -nosplit
140This manual page was written by
141.An Pawel Jakub Dawidek Aq pjd@FreeBSD.org .
142