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 g_open g_close g_mediasize g_sectorsize g_flush g_delete g_get_ident g_get_name g_open_by_ident - userland API library for kernel GEOM subsystem
Lb libgeom
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 statistics 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 snapshot 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 snapshot.
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.
A
Vt 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 read-only parameters) or
gctl_rw_param ();
(for read/write parameters).
Both
gctl_ro_param ();
and
gctl_rw_param ();
take a string
Fa name ,
which is used to identify the parameter, and a
Fa value ,
which contains, in the read-only 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
Fa len
is negative, it is assumed that
Fa value
is an
ASCII
string and the actual length is taken from the string length of
Fa value ;
otherwise it must hold the size of
Fa value .
A parameter with a Fa name containing the string Qq Li class is mandatory for each request, and the corresponding Fa 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 Fa name called Qq Li verb , and the corresponding Fa 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
Fa req
to the open file handle pointed to by
Fa 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.
The
g_open ();
function opens the given provider and returns file descriptor number, which can
be used with other functions.
The
Fa write
argument indicates if operations that modify the provider (like
g_flush ();
or
g_delete ());
are going to be called.
The
g_close ();
function closes the provider.
The
g_mediasize ();
function returns size of the given provider.
The
g_sectorsize ();
function returns sector size of the given provider.
The
g_flush ();
function sends
BIO_FLUSH
request to flush write cache of the provider.
The
g_delete ();
function tells the provider that the given data range is no longer used.
The
g_get_ident ();
function returns provider's fixed and unique identifier.
The
Fa ident
argument should be at least
DISK_IDENT_SIZE
big.
The
g_get_name ();
function returns name of the provider, which identifier is equal to the
Fa ident
string.
The
g_open_by_ident ();
function opens provider using its ident, unlike
g_open ();
which uses provider's name.
If the
Fa name
argument is not
NULL
the function will store provider's name there.
All functions return value greater than or equal to 0 on success or -1 on failure.
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);
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |