xref: /freebsd/lib/libgeom/libgeom.3 (revision 31dff47f01b77cae4dde508ea46945a49228d528)
1e13db587SPoul-Henning Kamp.\" Copyright (c) 2003 Poul-Henning Kamp
2fbda685dSPawel Jakub Dawidek.\" Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org>
3e13db587SPoul-Henning Kamp.\" All rights reserved.
4e13db587SPoul-Henning Kamp.\"
5e13db587SPoul-Henning Kamp.\" Redistribution and use in source and binary forms, with or without
6e13db587SPoul-Henning Kamp.\" modification, are permitted provided that the following conditions
7e13db587SPoul-Henning Kamp.\" are met:
8e13db587SPoul-Henning Kamp.\" 1. Redistributions of source code must retain the above copyright
9e13db587SPoul-Henning Kamp.\"    notice, this list of conditions and the following disclaimer.
10e13db587SPoul-Henning Kamp.\" 2. Redistributions in binary form must reproduce the above copyright
11e13db587SPoul-Henning Kamp.\"    notice, this list of conditions and the following disclaimer in the
12e13db587SPoul-Henning Kamp.\"    documentation and/or other materials provided with the distribution.
13e13db587SPoul-Henning Kamp.\" 3. The names of the authors may not be used to endorse or promote
14e13db587SPoul-Henning Kamp.\"    products derived from this software without specific prior written
15e13db587SPoul-Henning Kamp.\"    permission.
16e13db587SPoul-Henning Kamp.\"
17e13db587SPoul-Henning Kamp.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18e13db587SPoul-Henning Kamp.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19e13db587SPoul-Henning Kamp.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20e13db587SPoul-Henning Kamp.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21e13db587SPoul-Henning Kamp.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22e13db587SPoul-Henning Kamp.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23e13db587SPoul-Henning Kamp.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24e13db587SPoul-Henning Kamp.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25e13db587SPoul-Henning Kamp.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26e13db587SPoul-Henning Kamp.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27e13db587SPoul-Henning Kamp.\" SUCH DAMAGE.
28e13db587SPoul-Henning Kamp.\"
29e13db587SPoul-Henning Kamp.\" $FreeBSD$
30e13db587SPoul-Henning Kamp.\"
3131dff47fSUlf Lilleengen.Dd September 8, 2008
32e13db587SPoul-Henning Kamp.Dt LIBGEOM 3
33e13db587SPoul-Henning Kamp.Os
34e13db587SPoul-Henning Kamp.Sh NAME
35e13db587SPoul-Henning Kamp.Nm geom_stats_open ,
36e13db587SPoul-Henning Kamp.Nm geom_stats_close ,
37e13db587SPoul-Henning Kamp.Nm geom_stats_resync ,
38e13db587SPoul-Henning Kamp.Nm geom_stats_snapshot_get ,
39e13db587SPoul-Henning Kamp.Nm geom_stats_snapshot_free ,
40e13db587SPoul-Henning Kamp.Nm geom_stats_snapshot_timestamp ,
41e13db587SPoul-Henning Kamp.Nm geom_stats_snapshot_reset ,
425e5bfe77SPoul-Henning Kamp.Nm geom_stats_snapshot_next ,
435e5bfe77SPoul-Henning Kamp.Nm gctl_get_handle ,
445e5bfe77SPoul-Henning Kamp.Nm gctl_ro_param ,
455e5bfe77SPoul-Henning Kamp.Nm gctl_rw_param ,
465e5bfe77SPoul-Henning Kamp.Nm gctl_issue ,
475e5bfe77SPoul-Henning Kamp.Nm gctl_free ,
48fbda685dSPawel Jakub Dawidek.Nm gctl_dump ,
49fbda685dSPawel Jakub Dawidek.Nm g_open ,
50fbda685dSPawel Jakub Dawidek.Nm g_close ,
51fbda685dSPawel Jakub Dawidek.Nm g_mediasize ,
52fbda685dSPawel Jakub Dawidek.Nm g_sectorsize ,
53fbda685dSPawel Jakub Dawidek.Nm g_flush ,
54fbda685dSPawel Jakub Dawidek.Nm g_delete ,
5531dff47fSUlf Lilleengen.Nm g_device_path ,
56fbda685dSPawel Jakub Dawidek.Nm g_get_ident ,
57fbda685dSPawel Jakub Dawidek.Nm g_get_name ,
5831dff47fSUlf Lilleengen.Nm g_open_by_ident ,
5931dff47fSUlf Lilleengen.Nm g_providername
603fe5cc64SAlexey Zelkin.Nd userland API library for kernel GEOM subsystem
61e13db587SPoul-Henning Kamp.Sh LIBRARY
623fe5cc64SAlexey Zelkin.Lb libgeom
63e13db587SPoul-Henning Kamp.Sh SYNOPSIS
64e13db587SPoul-Henning Kamp.In libgeom.h
65ace5be68SRuslan Ermilov.Ss "Statistics Functions"
66e13db587SPoul-Henning Kamp.Ft void
67e13db587SPoul-Henning Kamp.Fn geom_stats_close void
68e13db587SPoul-Henning Kamp.Ft int
69e13db587SPoul-Henning Kamp.Fn geom_stats_open void
70e13db587SPoul-Henning Kamp.Ft void
71e13db587SPoul-Henning Kamp.Fn geom_stats_resync void
72ace5be68SRuslan Ermilov.Ft "void *"
73e13db587SPoul-Henning Kamp.Fn geom_stats_snapshot_get void
74e13db587SPoul-Henning Kamp.Ft void
75e13db587SPoul-Henning Kamp.Fn geom_stats_snapshot_free "void *arg"
76e13db587SPoul-Henning Kamp.Ft void
77e13db587SPoul-Henning Kamp.Fn geom_stats_snapshot_timestamp "void *arg" "struct timespec *tp"
78e13db587SPoul-Henning Kamp.Ft void
79e13db587SPoul-Henning Kamp.Fn geom_stats_snapshot_reset "void *arg"
8070b07749SRuslan Ermilov.Ft "struct devstat *"
81e13db587SPoul-Henning Kamp.Fn geom_stats_snapshot_next "void *arg"
825e5bfe77SPoul-Henning Kamp.Ss "Control Functions"
835e5bfe77SPoul-Henning Kamp.Ft "struct gctl_req *"
845e5bfe77SPoul-Henning Kamp.Fn gctl_get_handle "void"
855e5bfe77SPoul-Henning Kamp.Ft void
865e5bfe77SPoul-Henning Kamp.Fn gctl_ro_param "struct gctl_req *req" "const char *name" "int len" "const void *value"
875e5bfe77SPoul-Henning Kamp.Ft void
885e5bfe77SPoul-Henning Kamp.Fn gctl_rw_param "struct gctl_req *req" "const char *name" "int len" "void *value"
895e5bfe77SPoul-Henning Kamp.Ft "const char *"
905e5bfe77SPoul-Henning Kamp.Fn gctl_issue "struct gctl_req *req"
915e5bfe77SPoul-Henning Kamp.Ft void
925e5bfe77SPoul-Henning Kamp.Fn gctl_free "struct gctl_req *req"
935e5bfe77SPoul-Henning Kamp.Ft void
945e5bfe77SPoul-Henning Kamp.Fn gctl_dump "struct gctl_req *req" "FILE *f"
95fbda685dSPawel Jakub Dawidek.Ss "Utility Functions"
96fbda685dSPawel Jakub Dawidek.Ft int
979ac6b8aeSPawel Jakub Dawidek.Fn g_open "const char *name" "int dowrite"
98fbda685dSPawel Jakub Dawidek.Ft int
99fbda685dSPawel Jakub Dawidek.Fn g_close "int fd"
100fbda685dSPawel Jakub Dawidek.Ft off_t
101fbda685dSPawel Jakub Dawidek.Fn g_mediasize "int fd"
102fbda685dSPawel Jakub Dawidek.Ft ssize_t
103fbda685dSPawel Jakub Dawidek.Fn g_sectorsize "int fd"
104fbda685dSPawel Jakub Dawidek.Ft int
105fbda685dSPawel Jakub Dawidek.Fn g_flush "int fd"
106fbda685dSPawel Jakub Dawidek.Ft int
107fbda685dSPawel Jakub Dawidek.Fn g_delete "int fd" "off_t offset" "off_t length"
10831dff47fSUlf Lilleengen.Ft "char *"
10931dff47fSUlf Lilleengen.Fn g_device_path "const char *devpath"
110fbda685dSPawel Jakub Dawidek.Ft int
111fbda685dSPawel Jakub Dawidek.Fn g_get_ident "int fd" "char *ident" "size_t size"
112fbda685dSPawel Jakub Dawidek.Ft int
113fbda685dSPawel Jakub Dawidek.Fn g_get_name "const char *ident" "char *name" "size_t size"
114fbda685dSPawel Jakub Dawidek.Ft int
1159ac6b8aeSPawel Jakub Dawidek.Fn g_open_by_ident "const char *ident" "int dowrite" "char *name" "size_t size"
11631dff47fSUlf Lilleengen.Ft "char *"
11731dff47fSUlf Lilleengen.Fn g_providername "int fd"
118e13db587SPoul-Henning Kamp.Sh DESCRIPTION
119ace5be68SRuslan ErmilovThe
120ace5be68SRuslan Ermilov.Nm geom
121ace5be68SRuslan Ermilovlibrary contains the official and publicized API for
122e13db587SPoul-Henning Kampinteracting with the GEOM subsystem in the kernel.
123ace5be68SRuslan Ermilov.Ss "Statistics Functions"
124e13db587SPoul-Henning KampGEOM collects statistics data for all consumers and providers, but does
125e13db587SPoul-Henning Kampnot perform any normalization or presentation on the raw data, this is
126cbb0775dSAndrew Thompsonleft as an exercise for user-land presentation utilities.
127e13db587SPoul-Henning Kamp.Pp
128e13db587SPoul-Henning KampThe
1293fe5cc64SAlexey Zelkin.Fn geom_stats_open
130e13db587SPoul-Henning Kampand
1313fe5cc64SAlexey Zelkin.Fn geom_stats_close
132ace5be68SRuslan Ermilovfunctions open and close the necessary pathways to access the raw
133ace5be68SRuslan Ermilovstatistics information in the kernel.
134ace5be68SRuslan ErmilovThese functions are likely to
135e13db587SPoul-Henning Kampopen one or more files and cache the file descriptors locally.
136b160a51eSPhilippe CharnierThe
1373fe5cc64SAlexey Zelkin.Fn geom_stats_open
138b160a51eSPhilippe Charnierfunction returns zero on success, and sets
139ace5be68SRuslan Ermilov.Va errno
140ace5be68SRuslan Ermilovif not.
141e13db587SPoul-Henning Kamp.Pp
142e13db587SPoul-Henning KampThe
1433fe5cc64SAlexey Zelkin.Fn geom_stats_resync
144e13db587SPoul-Henning Kampfunction will check if more statistics collection points have been
145e13db587SPoul-Henning Kampadded in the kernel since
1463fe5cc64SAlexey Zelkin.Fn geom_stats_open
147e13db587SPoul-Henning Kampor the previous call to
1483fe5cc64SAlexey Zelkin.Fn geom_stats_resync .
149e13db587SPoul-Henning Kamp.Pp
150ace5be68SRuslan ErmilovThe
1513fe5cc64SAlexey Zelkin.Fn geom_stats_snapshot_get
152ace5be68SRuslan Ermilovfunction
153ace5be68SRuslan Ermilovwill acquire a snapshot of the raw data from the kernel, and while a
154e13db587SPoul-Henning Kampreasonable effort is made to make this snapshot as atomic and consistent
155e13db587SPoul-Henning Kampas possible, no guarantee is given that it will actually be so.
156e13db587SPoul-Henning KampThe snapshot must be freed again using the
1573fe5cc64SAlexey Zelkin.Fn geom_stats_snapshot_free
158e13db587SPoul-Henning Kampfunction.
159b160a51eSPhilippe CharnierThe
1603fe5cc64SAlexey Zelkin.Fn geom_stats_snapshot_get
161b160a51eSPhilippe Charnierfunction returns
162ace5be68SRuslan Ermilov.Dv NULL
163ace5be68SRuslan Ermilovon failure.
164e13db587SPoul-Henning Kamp.Pp
165ace5be68SRuslan ErmilovThe
1663fe5cc64SAlexey Zelkin.Fn geom_stats_snapshot_timestamp
167ace5be68SRuslan Ermilovfunction
168ace5be68SRuslan Ermilovprovides access to the timestamp acquired in the snapshot.
169e13db587SPoul-Henning Kamp.Pp
170ace5be68SRuslan ErmilovThe
1713fe5cc64SAlexey Zelkin.Fn geom_stats_snapshot_reset
172e13db587SPoul-Henning Kampand
1733fe5cc64SAlexey Zelkin.Fn geom_stats_snapshot_next
174ace5be68SRuslan Ermilovfunctions
175ace5be68SRuslan Ermilovprovide an iterator over the statistics slots in the snapshot.
176ace5be68SRuslan ErmilovThe
1773fe5cc64SAlexey Zelkin.Fn geom_stats_snapshot_reset
178ace5be68SRuslan Ermilovfunction
179e13db587SPoul-Henning Kampforces the internal pointer in the snapshot back to before the first item.
180ace5be68SRuslan ErmilovThe
1813fe5cc64SAlexey Zelkin.Fn geom_stats_snapshot_next
182ace5be68SRuslan Ermilovfunction
183ace5be68SRuslan Ermilovreturns the next item, and
184ace5be68SRuslan Ermilov.Dv NULL
185ace5be68SRuslan Ermilovif there are no more items in the snapshot.
1865e5bfe77SPoul-Henning Kamp.Ss "Control Functions"
1875e5bfe77SPoul-Henning KampThe
1885e5bfe77SPoul-Henning Kamp.Fn gctl_*
189862b46f6SRuslan Ermilovfunctions are used to send requests to GEOM classes.
190862b46f6SRuslan ErmilovIn order for a GEOM
1915e5bfe77SPoul-Henning Kampclass to actually be able to receive these requests, it must have defined a
1925e5bfe77SPoul-Henning Kamp"ctlreq" method.
1935e5bfe77SPoul-Henning Kamp.Pp
1945e5bfe77SPoul-Henning KampA
195862b46f6SRuslan Ermilov.Vt "struct gctl_req *" ,
1965e5bfe77SPoul-Henning Kampobtained with
1975e5bfe77SPoul-Henning Kamp.Fn gctl_get_handle ,
1985e5bfe77SPoul-Henning Kampcan hold any number of parameters, which must be added to it with
1995e5bfe77SPoul-Henning Kamp.Fn gctl_ro_param
2005e5bfe77SPoul-Henning Kamp(for read-only parameters) or
2015e5bfe77SPoul-Henning Kamp.Fn gctl_rw_param
2025e5bfe77SPoul-Henning Kamp(for read/write parameters).
2035e5bfe77SPoul-Henning Kamp.Pp
2045e5bfe77SPoul-Henning KampBoth
2055e5bfe77SPoul-Henning Kamp.Fn gctl_ro_param
2065e5bfe77SPoul-Henning Kampand
2075e5bfe77SPoul-Henning Kamp.Fn gctl_rw_param
2085e5bfe77SPoul-Henning Kamptake a string
209862b46f6SRuslan Ermilov.Fa name ,
2105e5bfe77SPoul-Henning Kampwhich is used to identify the parameter, and a
211862b46f6SRuslan Ermilov.Fa value ,
212862b46f6SRuslan Ermilovwhich contains, in the read-only case, the data to be passed to the
213862b46f6SRuslan ErmilovGEOM class, or, in the read/write case, a pointer to preallocated memory
214862b46f6SRuslan Ermilovthat the GEOM class should fill with the desired data.
215862b46f6SRuslan ErmilovIf
216862b46f6SRuslan Ermilov.Fa len
2175e5bfe77SPoul-Henning Kampis negative, it is assumed that
218862b46f6SRuslan Ermilov.Fa value
219862b46f6SRuslan Ermilovis an
220862b46f6SRuslan Ermilov.Tn ASCII
221862b46f6SRuslan Ermilovstring and the actual length is taken from the string length of
222862b46f6SRuslan Ermilov.Fa value ;
2235e5bfe77SPoul-Henning Kampotherwise it must hold the size of
224862b46f6SRuslan Ermilov.Fa value .
2255e5bfe77SPoul-Henning Kamp.Pp
2265e5bfe77SPoul-Henning KampA parameter with a
227862b46f6SRuslan Ermilov.Fa name
228862b46f6SRuslan Ermilovcontaining the string
229862b46f6SRuslan Ermilov.Qq Li class
230862b46f6SRuslan Ermilovis mandatory for each request, and the
2315e5bfe77SPoul-Henning Kampcorresponding
232862b46f6SRuslan Ermilov.Fa value
2335e5bfe77SPoul-Henning Kampmust hold the name of the GEOM class where the request should be sent to.
2345e5bfe77SPoul-Henning Kamp.Pp
2355e5bfe77SPoul-Henning KampAlso mandatory for each request is a parameter with a
236862b46f6SRuslan Ermilov.Fa name
237862b46f6SRuslan Ermilovcalled
238862b46f6SRuslan Ermilov.Qq Li verb ,
239862b46f6SRuslan Ermilovand the corresponding
240862b46f6SRuslan Ermilov.Fa value
2415e5bfe77SPoul-Henning Kampneeds to hold the command string that the GEOM class should react upon.
2425e5bfe77SPoul-Henning Kamp.Pp
2435e5bfe77SPoul-Henning KampOnce all desired parameters are filled in, the request must be sent to
2445e5bfe77SPoul-Henning Kampthe GEOM subsystem with
2455e5bfe77SPoul-Henning Kamp.Fn gctl_issue ,
246862b46f6SRuslan Ermilovwhich returns
247862b46f6SRuslan Ermilov.Dv NULL
248862b46f6SRuslan Ermilovon success, or a string containing the error message
2495e5bfe77SPoul-Henning Kampon failure.
2505e5bfe77SPoul-Henning Kamp.Pp
2515e5bfe77SPoul-Henning KampAfter the request is finished, the allocated memory should be released with
2525e5bfe77SPoul-Henning Kamp.Fn gctl_free .
2535e5bfe77SPoul-Henning Kamp.Pp
254862b46f6SRuslan ErmilovThe
2555e5bfe77SPoul-Henning Kamp.Fn gctl_dump
256862b46f6SRuslan Ermilovfunction
2575e5bfe77SPoul-Henning Kampcan be used to format the contents of
258862b46f6SRuslan Ermilov.Fa req
2595e5bfe77SPoul-Henning Kampto the open file handle pointed to by
260862b46f6SRuslan Ermilov.Fa f ,
2615e5bfe77SPoul-Henning Kampfor debugging purposes.
2625e5bfe77SPoul-Henning Kamp.Pp
2635e5bfe77SPoul-Henning KampError handling for the control functions is postponed until the call
2645e5bfe77SPoul-Henning Kampto
265862b46f6SRuslan Ermilov.Fn gctl_issue ,
266862b46f6SRuslan Ermilovwhich returns
267862b46f6SRuslan Ermilov.Dv NULL
268862b46f6SRuslan Ermilovon success, or an error message corresponding to the
2695e5bfe77SPoul-Henning Kampfirst error which happened.
270fbda685dSPawel Jakub Dawidek.Ss "Utility Functions"
271fbda685dSPawel Jakub DawidekThe
272fbda685dSPawel Jakub Dawidek.Fn g_*
273fbda685dSPawel Jakub Dawidekfunctions are used to communicate with GEOM providers.
274fbda685dSPawel Jakub Dawidek.Pp
275fbda685dSPawel Jakub DawidekThe
276fbda685dSPawel Jakub Dawidek.Fn g_open
277fbda685dSPawel Jakub Dawidekfunction opens the given provider and returns file descriptor number, which can
278fbda685dSPawel Jakub Dawidekbe used with other functions.
279fbda685dSPawel Jakub DawidekThe
2809ac6b8aeSPawel Jakub Dawidek.Fa dowrite
281fbda685dSPawel Jakub Dawidekargument indicates if operations that modify the provider (like
282fbda685dSPawel Jakub Dawidek.Fn g_flush
283fbda685dSPawel Jakub Dawidekor
284fbda685dSPawel Jakub Dawidek.Fn g_delete )
285fbda685dSPawel Jakub Dawidekare going to be called.
286fbda685dSPawel Jakub Dawidek.Pp
287fbda685dSPawel Jakub DawidekThe
288fbda685dSPawel Jakub Dawidek.Fn g_close
289fbda685dSPawel Jakub Dawidekfunction closes the provider.
290fbda685dSPawel Jakub Dawidek.Pp
291fbda685dSPawel Jakub DawidekThe
292fbda685dSPawel Jakub Dawidek.Fn g_mediasize
293fbda685dSPawel Jakub Dawidekfunction returns size of the given provider.
294fbda685dSPawel Jakub Dawidek.Pp
295fbda685dSPawel Jakub DawidekThe
296fbda685dSPawel Jakub Dawidek.Fn g_sectorsize
297fbda685dSPawel Jakub Dawidekfunction returns sector size of the given provider.
298fbda685dSPawel Jakub Dawidek.Pp
299fbda685dSPawel Jakub DawidekThe
300fbda685dSPawel Jakub Dawidek.Fn g_flush
301fbda685dSPawel Jakub Dawidekfunction sends
302fbda685dSPawel Jakub Dawidek.Dv BIO_FLUSH
303fbda685dSPawel Jakub Dawidekrequest to flush write cache of the provider.
304fbda685dSPawel Jakub Dawidek.Pp
305fbda685dSPawel Jakub DawidekThe
306fbda685dSPawel Jakub Dawidek.Fn g_delete
307fbda685dSPawel Jakub Dawidekfunction tells the provider that the given data range is no longer used.
308fbda685dSPawel Jakub Dawidek.Pp
309fbda685dSPawel Jakub DawidekThe
31031dff47fSUlf Lilleengen.Fn g_device_path
31131dff47fSUlf Lilleengenfunction returns the full path to a provider given a partial or full path to the
31231dff47fSUlf Lilleengendevice node.
31331dff47fSUlf LilleengenIf the device can not be found or is not a valid geom provider, NULL is
31431dff47fSUlf Lilleengenreturned.
31531dff47fSUlf Lilleengen.Pp
31631dff47fSUlf LilleengenThe
317fbda685dSPawel Jakub Dawidek.Fn g_get_ident
318fbda685dSPawel Jakub Dawidekfunction returns provider's fixed and unique identifier.
319fbda685dSPawel Jakub DawidekThe
320fbda685dSPawel Jakub Dawidek.Fa ident
321fbda685dSPawel Jakub Dawidekargument should be at least
322fbda685dSPawel Jakub Dawidek.Dv DISK_IDENT_SIZE
323fbda685dSPawel Jakub Dawidekbig.
324fbda685dSPawel Jakub Dawidek.Pp
325fbda685dSPawel Jakub DawidekThe
326fbda685dSPawel Jakub Dawidek.Fn g_get_name
327fbda685dSPawel Jakub Dawidekfunction returns name of the provider, which identifier is equal to the
328fbda685dSPawel Jakub Dawidek.Fa ident
329fbda685dSPawel Jakub Dawidekstring.
330fbda685dSPawel Jakub Dawidek.Pp
331fbda685dSPawel Jakub DawidekThe
332fbda685dSPawel Jakub Dawidek.Fn g_open_by_ident
333fbda685dSPawel Jakub Dawidekfunction opens provider using its ident, unlike
334fbda685dSPawel Jakub Dawidek.Fn g_open
335fbda685dSPawel Jakub Dawidekwhich uses provider's name.
336fbda685dSPawel Jakub DawidekIf the
337fbda685dSPawel Jakub Dawidek.Fa name
338fbda685dSPawel Jakub Dawidekargument is not
339fbda685dSPawel Jakub Dawidek.Dv NULL ,
340fbda685dSPawel Jakub Dawidekthe function will store provider's name there.
341fbda685dSPawel Jakub Dawidek.Pp
34231dff47fSUlf LilleengenThe
34331dff47fSUlf Lilleengen.Fn g_providername
34431dff47fSUlf Lilleengenfunction returns the provider name of an open file descriptor.
34531dff47fSUlf LilleengenIf the file descriptor does not point to a valid geom provider, NULL is
34631dff47fSUlf Lilleengenreturned.
34731dff47fSUlf Lilleengen.Pp
34831dff47fSUlf LilleengenAll functions except
34931dff47fSUlf Lilleengen.Fn g_providername
35031dff47fSUlf Lilleengenand
35131dff47fSUlf Lilleengen.Fn g_device_path
35231dff47fSUlf Lilleengenreturn a value greater than or equal to
353fbda685dSPawel Jakub Dawidek.Va 0
354fbda685dSPawel Jakub Dawidekon success or
355fbda685dSPawel Jakub Dawidek.Va -1
356fbda685dSPawel Jakub Dawidekon failure.
3575e5bfe77SPoul-Henning Kamp.Sh EXAMPLES
358862b46f6SRuslan ErmilovCreate a request that is to be sent to the CCD class, and tell
3595e5bfe77SPoul-Henning Kampit to destroy a specific geom:
3605e5bfe77SPoul-Henning Kamp.Bd -literal -offset indent
3615e5bfe77SPoul-Henning KampH = gctl_get_handle();
3625e5bfe77SPoul-Henning Kampgctl_ro_param(H, "verb", -1, "destroy geom");
3635e5bfe77SPoul-Henning Kampgctl_ro_param(H, "class", -1, "CCD");
3645e5bfe77SPoul-Henning Kampsprintf(buf, "ccd%d", ccd);
3655e5bfe77SPoul-Henning Kampgctl_ro_param(H, "geom", -1, buf);
3665e5bfe77SPoul-Henning Kamperrstr = gctl_issue(H);
3675e5bfe77SPoul-Henning Kampif (errstr != NULL)
368862b46f6SRuslan Ermilov    err(1, "could not destroy ccd: %s", errstr);
3695e5bfe77SPoul-Henning Kampgctl_free(H);
3705e5bfe77SPoul-Henning Kamp.Ed
3715e5bfe77SPoul-Henning Kamp.Sh SEE ALSO
372862b46f6SRuslan Ermilov.Pa http://ezine.daemonnews.org/200308/blueprints.html
373e13db587SPoul-Henning Kamp.Sh HISTORY
374ace5be68SRuslan ErmilovThe
375e13db587SPoul-Henning Kamp.Nm geom
376ace5be68SRuslan Ermilovlibrary appeared in
377e13db587SPoul-Henning Kamp.Fx 5.1 .
3785e5bfe77SPoul-Henning Kamp.Sh AUTHORS
3795e5bfe77SPoul-Henning Kamp.An Poul-Henning Kamp Aq phk@FreeBSD.org
3805e5bfe77SPoul-Henning Kamp.An Lukas Ertl Aq le@FreeBSD.org
381fbda685dSPawel Jakub Dawidek.An Pawel Jakub Dawidek pjd@FreeBSD.org
382