![]() |
![]() |
![]() |
libblockdev Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
#include <utils.h> void (*BDUtilsLogFunc) (gint level
,gchar *msg
); GQuark bd_utils_exec_error_quark (void
); #define BD_UTILS_EXEC_ERROR enum BDUtilsExecError; gboolean bd_utils_exec_and_report_error (gchar **argv
,GError **error
); gboolean bd_utils_exec_and_capture_output (gchar **argv
,gchar **output
,GError **error
); gboolean bd_utils_init_logging (BDUtilsLogFunc new_log_func
,GError **error
); #define BD_UTILS_SIZE_ERROR enum BDUtilsSizeError; gchar * bd_utils_size_human_readable (guint64 size
); guint64 bd_utils_size_from_spec (gchar *spec
,GError **error
); gboolean bd_utils_check_util_version (gchar *util
,gchar *version
,gchar *version_arg
,gchar *version_regexp
,GError **error
); gint bd_utils_version_cmp (gchar *ver_string1
,gchar *ver_string2
,GError **error
); #define EXBIBYTE #define EiB #define GIBIBYTE #define GiB #define KIBIBYTE #define KiB #define MEBIBYTE #define MiB #define PEBIBYTE #define PiB #define TEBIBYTE #define TiB
void (*BDUtilsLogFunc) (gint level
,gchar *msg
);
Function type for logging function used by the libblockdev's exec utils to log the information about program executing.
|
log level (as understood by syslog(3)) |
|
log message |
typedef enum { BD_UTILS_EXEC_ERROR_FAILED, BD_UTILS_EXEC_ERROR_NOOUT, BD_UTILS_EXEC_ERROR_INVAL_VER, BD_UTILS_EXEC_ERROR_UTIL_UNAVAILABLE, BD_UTILS_EXEC_ERROR_UTIL_UNKNOWN_VER, BD_UTILS_EXEC_ERROR_UTIL_LOW_VER, } BDUtilsExecError;
gboolean bd_utils_exec_and_report_error (gchar **argv
,GError **error
);
|
the argv array for the call. [array zero-terminated=1] |
|
place to store error (if any). [out] |
Returns : |
whether the argv was successfully executed (no error and exit code 0) or not |
gboolean bd_utils_exec_and_capture_output (gchar **argv
,gchar **output
,GError **error
);
|
the argv array for the call. [array zero-terminated=1] |
|
variable to store output to. [out] |
|
place to store error (if any). [out] |
Returns : |
whether the argv was successfully executed capturing the output or not |
gboolean bd_utils_init_logging (BDUtilsLogFunc new_log_func
,GError **error
);
|
logging function to use or
NULL to reset to default. [allow-none][scope notified]
|
|
place to store error (if any). [out] |
Returns : |
whether logging was successfully initialized or not |
gchar * bd_utils_size_human_readable (guint64 size
);
|
size to get human readable representation of |
Returns : |
human readable representation of the given size
|
guint64 bd_utils_size_from_spec (gchar *spec
,GError **error
);
|
human readable size specification (e.g. "512 MiB") |
|
place to store error (if any). [out] |
Returns : |
number of bytes equal to the size specification rounded to bytes, if
0, error ) may be set in case of error |
gboolean bd_utils_check_util_version (gchar *util
,gchar *version
,gchar *version_arg
,gchar *version_regexp
,GError **error
);
|
name of the utility to check |
|
minimum required version of the utility or NULL
if no version is required. [allow-none]
|
|
argument to use with the util to get version
info or NULL to use "--version". [allow-none]
|
|
regexp to extract version from the version
info or NULL if only version is printed by "$ util version_arg ". [allow-none]
|
|
place to store error (if any). [out] |
Returns : |
whether the util is available in a version >= version or not
(error is set in such case). |
gint bd_utils_version_cmp (gchar *ver_string1
,gchar *ver_string2
,GError **error
);
|
first version string |
|
second version string |
|
place to store error (if any). [out] |
Returns : |
-1, 0 or 1 if ver_string1 is lower, the same or higher version as
ver_string2 respectively. If an error occurs, returns -2 and error
is set.
**ONLY SUPPORTS VERSION STRINGS OF FORMAT X[.Y[.Z[.Z2[.Z3...[-R]]]]] where all components
are natural numbers!** |