1libdmmp.h(3)               Library Functions Manual               libdmmp.h(3)
2
3
4

NAME

6       libdmmp.h - Device Mapper Multipath API.
7
8

SYNOPSIS

10       #include <libdmmp/libdmmp.h>
11
12

DESCRIPTION

14       All  the  libdmmp public functions ships its own man pages.  Use 'man 3
15       <function_name>' to check the detail usage.
16
17

USAGE

19       To use libdmmp in your project, we suggest to use the 'pkg-config' way:
20
21        * Add this line into your configure.ac:
22
23           PKG_CHECK_MODULES([LIBDMMP], [libdmmp])
24
25        * Add these lines into your Makefile.am:
26
27           foo_LDFLAGS += $(LIBDMMP_LIBS)
28           foo_CFLAGS += $(LIBDMMP_CFLAGS)
29
30

LOG HANDLING

32       The   log   handler   function   could   be    set    via    'dmmp_con‐
33       text_log_func_set()'.   The  log  priority  could be set via 'dmmp_con‐
34       text_log_priority_set()'.
35
36       By default, the  log  priorities  is  'DMMP_LOG_PRIORITY_WARNING'.   By
37       default, the log handler is print log to STDERR, and its code is listed
38       below in case you want to create your own log handler.
39
40               static int _DMMP_LOG_STRERR_ALIGN_WIDTH = 80;
41
42               static void _log_stderr(struct dmmp_context *ctx,
43                                       enum dmmp_log_priority priority,
44                                       const char *file, int line,
45                                       const char *func_name,
46                                       const char *format, va_list args)
47               {
48                   int printed_bytes = 0;
49
50                   printed_bytes += fprintf(stderr, "libdmmp %s: ",
51                                            dmmp_log_priority_str(priority));
52                   printed_bytes += vfprintf(stderr, format, args);
53                   userdata = dmmp_context_userdata_get(ctx);
54                   if (userdata != NULL)
55                       fprintf(stderr, "(with  user  data  at  memory  address
56       %p)",
57                               userdata);
58
59                   if (printed_bytes < _DMMP_LOG_STRERR_ALIGN_WIDTH) {
60                       fprintf(stderr, "%*s # %s:%s():%d0,
61                               _DMMP_LOG_STRERR_ALIGN_WIDTH  -  printed_bytes,
62       "", file,
63                               func_name, line);
64                   } else {
65                       fprintf(stderr,  "  #  %s:%s():%d0,  file,   func_name,
66       line);
67                   }
68               }
69
70
71

SAMPLE CODE

73           #include <libdmmp/libdmmp.h>
74
75           int main(int argc, char *argv[]) {
76               struct dmmp_context *ctx = NULL;
77               struct dmmp_mpath **dmmp_mps = NULL;
78               struct dmmp_path_group **dmmp_pgs = NULL;
79               struct dmmp_path **dmmp_ps = NULL;
80               uint32_t dmmp_mp_count = 0;
81               uint32_t dmmp_pg_count = 0;
82               uint32_t dmmp_p_count = 0;
83               const char *name = NULL;
84               const char *wwid = NULL;
85               uint32_t i = 0;
86               int rc = DMMP_OK;
87
88               ctx = dmmp_context_new();
89               dmmp_context_log_priority_set(ctx, DMMP_LOG_PRIORITY_DEBUG);
90               // By default, log will be printed to STDERR, you could
91               // change that via dmmp_context_log_func_set()
92               rc = dmmp_mpath_array_get(ctx, &dmmp_mps, &dmmp_mp_count);
93               if (rc != DMMP_OK) {
94                   printf("dmmp_mpath_array_get() failed with %d: %s", rc,
95                          dmmp_strerror(rc));
96                   goto out;
97               }
98               for (i = 0; i < dmmp_mp_count; ++i) {
99                       name = dmmp_mpath_name_get(dmmp_mps[i]);
100                       wwid = dmmp_mpath_wwid_get(dmmp_mps[i]);
101                       printf("dmmp_mpath_array_get():   Got  mpath:  %s  %s0,
102       name,
103                              wwid);
104                       //  You  could   use   dmmp_path_group_array_get()   to
105       retrieve
106                       //    path    group   information   and   then   invoke
107       dmmp_path_array_get()
108                       // for path information.
109               }
110
111            out:
112               dmmp_context_free(ctx);
113               dmmp_mpath_array_free(dmmp_mps, dmmp_mp_count);
114               if (rc != DMMP_OK)
115                   exit(1);
116               exit(0);
117           }
118
119

LICENSE

121       GPLv2+
122
123

BUG

125       Please report bug to <dm-devel@redhat.com>
126
127
128
129Device Mapper Multipath API - libdJmamnpuaMraynu2a0l16                     libdmmp.h(3)
Impressum