libdmmp.h(3)
π libdmmp.h β the Device Mapper Multipath API π
okay bestie, welcome to libdmmp.h(3) β yes, that's section 3, the Library Functions Manual, we're in the big leagues now β¨
πΈ NAME πΈ
libdmmp.h β the Device Mapper Multipath API. that's it, that's the vibe π
π¦ SYNOPSIS π¦
#include <libdmmp/libdmmp.h>
β¨ DESCRIPTION β¨
every single one of the public libdmmp functions ships with its own little man page, bestie. iconic behavior honestly. so if you wanna know the deets on how to actually use one, just run:
man 3 <function_name>
and the whole detailed usage is right there waiting for you π
π USAGE π
so you wanna put libdmmp in your project? periodt. the way we suggest you do it is the pkg-config way, no cap:
- drop this line into your
configure.ac:
PKG_CHECK_MODULES([LIBDMMP], [libdmmp])
- then add these lines into your
Makefile.am:
foo_LDFLAGS += $(LIBDMMP_LIBS)
foo_CFLAGS += $(LIBDMMP_CFLAGS)
that's the whole setup, slay π
π«Ά LOG HANDLING π«Ά
okay so logging, listen up. you can set the log handler function with dmmp_context_log_func_set(), and you can set the log priority with dmmp_context_log_priority_set(). two little besties doing two different jobs, we love that for them π
by default? the log priority is DMMP_LOG_PRIORITY_WARNING. and by default the log handler just prints the log straight to STDERR. the code for that default handler is listed below, in case you're feeling crafty and wanna build your own log handler π
static int _DMMP_LOG_STRERR_ALIGN_WIDTH = 80;
static void _log_stderr(struct dmmp_context *ctx,
enum dmmp_log_priority priority,
const char *file, int line,
const char *func_name,
const char *format, va_list args)
{
int printed_bytes = 0;
printed_bytes += fprintf(stderr, "libdmmp %s: ",
dmmp_log_priority_str(priority));
printed_bytes += vfprintf(stderr, format, args);
userdata = dmmp_context_userdata_get(ctx);
if (userdata != NULL)
fprintf(stderr, "(with user data at memory address %p)",
userdata);
if (printed_bytes < _DMMP_LOG_STRERR_ALIGN_WIDTH) {
fprintf(stderr, "%*s # %s:%s():%d0,
_DMMP_LOG_STRERR_ALIGN_WIDTH - printed_bytes,
"", file,
func_name, line);
} else {
fprintf(stderr, " # %s:%s():%d0, file, func_name, line);
}
}
π SAMPLE CODE π
here's a whole lil program, bestie. read it, run it, become the main character of your own multipath journey π
#include <libdmmp/libdmmp.h>
int main(int argc, char *argv[]) {
struct dmmp_context *ctx = NULL;
struct dmmp_mpath **dmmp_mps = NULL;
struct dmmp_path_group **dmmp_pgs = NULL;
struct dmmp_path **dmmp_ps = NULL;
uint32_t dmmp_mp_count = 0;
uint32_t dmmp_pg_count = 0;
uint32_t dmmp_p_count = 0;
const char *name = NULL;
const char *wwid = NULL;
uint32_t i = 0;
int rc = DMMP_OK;
ctx = dmmp_context_new();
dmmp_context_log_priority_set(ctx, DMMP_LOG_PRIORITY_DEBUG);
// By default, log will be printed to STDERR, you could
// change that via dmmp_context_log_func_set()
rc = dmmp_mpath_array_get(ctx, &dmmp_mps, &dmmp_mp_count);
if (rc != DMMP_OK) {
printf("dmmp_mpath_array_get() failed with %d: %s", rc,
dmmp_strerror(rc));
goto out;
}
for (i = 0; i < dmmp_mp_count; ++i) {
name = dmmp_mpath_name_get(dmmp_mps[i]);
wwid = dmmp_mpath_wwid_get(dmmp_mps[i]);
printf("dmmp_mpath_array_get(): Got mpath: %s %s0, name,
wwid);
// You could use dmmp_path_group_array_get() to retrieve
// path group information and then invoke
dmmp_path_array_get()
// for path information.
}
out:
dmmp_context_free(ctx);
dmmp_mpath_array_free(dmmp_mps, dmmp_mp_count);
if (rc != DMMP_OK)
exit(1);
exit(0);
}
π LICENSE π
GPLv2+ β yeah bestie, that's the one, go forth and share the love (respectfully, per the license) π
π BUG π
found a bug? don't be shy, don't suffer in silence. please report it to <dm-devel@lists.linux.dev> π«Ά
and that's a wrap on libdmmp.h(3), the Device Mapper Multipath API page, born way back in January 2016 and still serving looks in the Library Functions Manual. mwah, go write some slay code π
β¨π¦
π¦ where this page comes from
- alpine 3.22: multipath-tools-doc 0.11.1-r2 Β· LGPL-2.0-only
- alpine 3.23: multipath-tools-doc 0.13.0-r0 Β· LGPL-2.0-only
- alpine 3.24: multipath-tools-doc 0.13.0-r0 Β· LGPL-2.0-only
- arch rolling: multipath-tools 0.15.1-1 Β· GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-2.0-or-later AND LGPL-2.1-or-later
- fedora 43: libdmmp-devel 0.11.1-2.fc43 Β· GPL-2.0-only AND GPL-3.0-only
- fedora 43: libdmmp-devel 0.11.1-2.fc43 Β· GPL-2.0-only AND GPL-3.0-only
- fedora 44: libdmmp-devel 0.13.1-1.fc44 Β· GPL-2.0-only AND GPL-3.0-only
- fedora 44: libdmmp-devel 0.13.1-1.fc44 Β· GPL-2.0-only AND GPL-3.0-only
- nixos 26.05: multipath-tools 0.14.1
- nixpkgs unstable: multipath-tools 0.14.3
- opensuse-leap 16.0: libdmmp-devel 0.12.4+278+suse.9cf9c5c-160000.1.1 Β· GPL-3.0-or-later
- opensuse-leap 16.0: libdmmp-devel 0.12.4+278+suse.9cf9c5c-160000.1.1 Β· GPL-3.0-or-later
- opensuse-leap 16.0: libdmmp-devel 0.12.4+278+suse.9cf9c5c-160000.1.1 Β· GPL-3.0-or-later
- opensuse-leap 16.0: libdmmp-devel 0.12.4+278+suse.9cf9c5c-160000.1.1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms