libgeom(3)

NAME

geom_stats_open, geom_stats_close, geom_stats_resync, geom_stats_snapshot_get, geom_stats_snapshot_free, geom_stats_snapshot_timestamp, geom_stats_snapshot_reset, geom_stats_snapshot_next, gctl_get_handle, gctl_ro_param,
gctl_rw_param,
gctl_issue, gctl_free, gctl_dump - userland API library for
kernel GEOM
subsystem

LIBRARY

library ``libgeom''

SYNOPSIS

#include <libgeom.h>
Statistics Functions
void
geom_stats_close(void);
int
geom_stats_open(void);
void
geom_stats_resync(void);
void *
geom_stats_snapshot_get(void);
void
geom_stats_snapshot_free(void *arg);
void
geom_stats_snapshot_timestamp(void  *arg,  struct   timespec
*tp);
void
geom_stats_snapshot_reset(void *arg);
struct g_stat *
geom_stats_snapshot_next(void *arg);
Control Functions
struct gctl_req *
gctl_get_handle(void);
void
gctl_ro_param(struct  gctl_req  *req,  const char *name, int
len,
        const void *value);
void
gctl_rw_param(struct gctl_req *req, const  char  *name,  int
len,
        void *value);
const char *
gctl_issue(struct gctl_req *req);
void
gctl_free(struct gctl_req *req);
void
gctl_dump(struct gctl_req *req, FILE *f);

DESCRIPTION

The geom library contains the official and publicized API
for interacting
with the GEOM subsystem in the kernel.
Statistics Functions
GEOM collects statistics data for all consumers and
providers, but does
not perform any normalization or presentation on the raw da
ta, this is
left as an excercize for user-land presentation utilities.
The geom_stats_open() and geom_stats_close() functions open
and close the
necessary pathways to access the raw statistics information
in the kernel. These functions are likely to open one or more files
and cache the
file descriptors locally. The geom_stats_open() function
returns zero on
success, and sets errno if not.
The geom_stats_resync() function will check if more statis
tics collection
points have been added in the kernel since geom_stats_open()
or the previous call to geom_stats_resync().
The geom_stats_snapshot_get() function will acquire a snap
shot of the raw
data from the kernel, and while a reasonable effort is made
to make this
snapshot as atomic and consistent as possible, no guarantee
is given that
it will actually be so. The snapshot must be freed again
using the
geom_stats_snapshot_free() function. The
geom_stats_snapshot_get() function returns NULL on failure.
The geom_stats_snapshot_timestamp() function provides access
to the
timestamp acquired in the snapshot.
The geom_stats_snapshot_reset() and
geom_stats_snapshot_next() functions provide an iterator over the statistics slots in the snap
shot. The
geom_stats_snapshot_reset() function forces the internal
pointer in the
snapshot back to before the first item. The
geom_stats_snapshot_next()
function returns the next item, and NULL if there are no
more items in
the snapshot.
Control Functions
The gctl_*() functions are used to send requests to GEOM
classes. In
order for a GEOM class to actually be able to receive these
requests, it
must have defined a "ctlreq" method.
A struct gctl_req *, obtained with gctl_get_handle(), can
hold any number
of parameters, which must be added to it with
gctl_ro_param() (for readonly parameters) or gctl_rw_param() (for read/write parame
ters).
Both gctl_ro_param() and gctl_rw_param() take a string name,
which is
used to identify the parameter, and a value, which contains,
in the readonly case, the data to be passed to the GEOM class, or, in
the read/write
case, a pointer to preallocated memory that the GEOM class
should fill
with the desired data. If len is negative, it is assumed
that value is
an ASCII string and the actual length is taken from the
string length of
value; otherwise it must hold the size of value.
A parameter with a name containing the string "class" is
mandatory for
each request, and the corresponding value must hold the name
of the GEOM
class where the request should be sent to.
Also mandatory for each request is a parameter with a name
called "verb",
and the corresponding value needs to hold the command string
that the
GEOM class should react upon.
Once all desired parameters are filled in, the request must
be sent to
the GEOM subsystem with gctl_issue(), which returns NULL on
success, or a
string containing the error message on failure.
After the request is finished, the allocated memory should
be released
with gctl_free().
The gctl_dump() function can be used to format the contents
of req to the
open file handle pointed to by f, for debugging purposes.
Error handling for the control functions is postponed until
the call to
gctl_issue(), which returns NULL on success, or an error
message corresponding to the first error which happened.

EXAMPLES

Create a request that is to be sent to the CCD class, and
tell it to
destroy a specific geom:

H = gctl_get_handle();
gctl_ro_param(H, "verb", -1, "destroy geom");
gctl_ro_param(H, "class", -1, "CCD");
sprintf(buf, "ccd%d", ccd);
gctl_ro_param(H, "geom", -1, buf);
errstr = gctl_issue(H);
if (errstr != NULL)
err(1, "could not destroy ccd: %s", errstr);
gctl_free(H);

SEE ALSO

http://ezine.daemonnews.org/200308/blueprints.html

HISTORY

The geom library appeared in FreeBSD 5.1.

AUTHORS

Poul-Henning Kamp <phk@FreeBSD.org>
Lukas Ertl <le@FreeBSD.org>
BSD March 7, 2004
Copyright © 2010-2025 Platon Technologies, s.r.o.           Home | Man pages | tLDP | Documents | Utilities | About
Design by styleshout