---
name: "libdmmp.h"
section: "3"
platform: "linux"
package: "multipath-tools"
version: "0.15.1-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libdmmp.h"
---

# libdmmp.h(3)

Device Mapper Multipath API.

## NAME

libdmmp.h - Device Mapper Multipath API.

## SYNOPSIS

\#include \<libdmmp/libdmmp.h\>

## DESCRIPTION

All the libdmmp public functions ships its own man pages. Use 'man 3 \<function\_name\>' to check the detail usage.

## USAGE

To use libdmmp in your project, we suggest to use the 'pkg-config' way:

 \* Add this line into your configure.ac:

    PKG\_CHECK\_MODULES(\[LIBDMMP\], \[libdmmp\])

 \* Add these lines into your Makefile.am:

    foo\_LDFLAGS += $(LIBDMMP\_LIBS)\
     foo\_CFLAGS += $(LIBDMMP\_CFLAGS)

## LOG HANDLING

The log handler function could be set via 'dmmp\_context\_log\_func\_set()'. The log priority could be set via 'dmmp\_context\_log\_priority\_set()'.

By default, the log priorities is 'DMMP\_LOG\_PRIORITY\_WARNING'. By default, the log handler is print log to STDERR, and its code is listed below in case you want to create 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

    \#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/1.md);\
         exit(0);\
     }

## LICENSE

GPLv2+

## BUG

Please report bug to \<dm-devel@lists.linux.dev\>
