-
Notifications
You must be signed in to change notification settings - Fork 61
/
DECLARE_GEOM_CLASS.9
177 lines (165 loc) · 4.57 KB
/
DECLARE_GEOM_CLASS.9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
.\"
.\" Copyright (c) 2004 Pawel Jakub Dawidek <[email protected]>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd August 13, 2007
.Dt DECLARE_GEOM_CLASS 9
.Os
.Sh NAME
.Nm DECLARE_GEOM_CLASS
.Nd "GEOM class declaration macro"
.Sh SYNOPSIS
.In geom/geom.h
.Fn DECLARE_GEOM_CLASS "class" "mod_name"
.Sh DESCRIPTION
The
.Fn DECLARE_GEOM_CLASS
macro registers a GEOM class in GEOM.
A GEOM class itself implements one particular kind of transformation.
Typical examples are: MBR disk partition,
.Bx
disklabel and RAID5 classes.
.Fn DECLARE_GEOM_CLASS
can be used both for compiled in and loaded as
.Xr kld 4
modules GEOM classes and it is the only official way for class registration.
.Pp
The arguments to
.Fn DECLARE_GEOM_CLASS
are:
.Bl -tag -offset indent -width Fa
.It Fa class
The
.Vt g_class
structure which describes a GEOM class.
.It Fa mod_name
A kernel module name (not a class name!).
.El
.Pp
Structure
.Vt g_class
contains data describing the class.
They are:
.Bl -tag -offset indent -width indent
.It Vt "const char *" Va name
Class name.
.It Vt "g_taste_t *" Va taste
Pointer to function used for taste event handling.
If it is
.Pf non- Dv NULL
it is called in three situations:
.Pp
.Bl -dash -compact
.It
On class activation, all existing providers are offered for tasting.
.It
When new provider is created it is offered for tasting.
.It
After last write access to a provider is closed it is offered for retasting
(on first write open event
.Dq spoil
was sent).
.El
.It Vt "g_config_t *" Va config
This field is not used anymore, its functionality was replaced by the
.Va ctlreq
field.
.It Vt "g_ctl_req_t *" Va ctlreq
Pointer to function used for handling events from userland applications.
.It Vt "g_init_t *" Va init
Pointer to function which is called right after class registration.
.It Vt "g_fini_t *" Va fini
Pointer to function which is called right before class deregistration.
.It Vt "g_ctl_destroy_geom_t *" Va destroy_geom
Pointer to a function which is called for every geom on class unload.
If this field is not set, the class can not be unloaded.
.El
.Pp
Only a
.Fa name
field is required; the rest are optional.
.Sh RESTRICTIONS/CONDITIONS
The fields of
.Vt g_class
should always be initialized using C99-style field naming
(see the initialization of
.Va example_class
below).
.Sh EXAMPLES
Example class declaration.
.Bd -literal -offset indent
static struct g_geom *
g_example_taste(struct g_class *mp, struct g_provider *pp,
int flags __unused)
{
g_topology_assert();
[...]
}
static void
g_example_ctlreq(struct gctl_req *req, struct g_class *cp,
char const *verb)
{
[...]
}
static int
g_example_destroy_geom(struct gctl_req *req, struct g_class *cp,
struct g_geom *gp)
{
g_topology_assert();
[...]
}
static void
g_example_init(struct g_class *mp)
{
[...]
}
static void
g_example_fini(struct g_class *mp)
{
[...]
}
struct g_class example_class = {
.name = "EXAMPLE",
.taste = g_example_taste,
.ctlreq = g_example_ctlreq,
.init = g_example_init,
.fini = g_example_fini,
.destroy_geom = g_example_destroy_geom
};
DECLARE_GEOM_CLASS(example_class, g_example);
.Ed
.Sh SEE ALSO
.Xr geom 4 ,
.Xr g_attach 9 ,
.Xr g_bio 9 ,
.Xr g_consumer 9 ,
.Xr g_data 9 ,
.Xr g_event 9 ,
.Xr g_geom 9 ,
.Xr g_provider 9 ,
.Xr g_provider_by_name 9 ,
.Xr g_wither_geom 9
.Sh AUTHORS
.An -nosplit
This manual page was written by
.An Pawel Jakub Dawidek Aq Mt [email protected] .