Imported Upstream version 0.8.9
[platform/upstream/multipath-tools.git] / libmultipath / devmapper.h
1 #ifndef _DEVMAPPER_H
2 #define _DEVMAPPER_H
3
4 #include "structs.h"
5
6 #define TGT_MPATH       "multipath"
7 #define TGT_PART        "linear"
8
9 #ifdef DM_SUBSYSTEM_UDEV_FLAG0
10 #define MPATH_UDEV_RELOAD_FLAG DM_SUBSYSTEM_UDEV_FLAG0
11 #else
12 #define MPATH_UDEV_RELOAD_FLAG 0
13 #endif
14
15 #ifdef DM_SUBSYSTEM_UDEV_FLAG1
16 #define MPATH_UDEV_NO_KPARTX_FLAG DM_SUBSYSTEM_UDEV_FLAG1
17 #else
18 #define MPATH_UDEV_NO_KPARTX_FLAG 0
19 #endif
20
21 #ifdef DM_SUBSYSTEM_UDEV_FLAG2
22 #define MPATH_UDEV_NO_PATHS_FLAG DM_SUBSYSTEM_UDEV_FLAG2
23 #else
24 #define MPATH_UDEV_NO_PATHS_FLAG 0
25 #endif
26
27 #define UUID_PREFIX "mpath-"
28 #define UUID_PREFIX_LEN (sizeof(UUID_PREFIX) - 1)
29
30 enum {
31         DMP_ERR,
32         DMP_OK,
33         DMP_NOT_FOUND,
34 };
35
36 int dm_prereq(unsigned int *v);
37 void skip_libmp_dm_init(void);
38 void libmp_dm_exit(void);
39 void libmp_udev_set_sync_support(int on);
40 struct dm_task *libmp_dm_task_create(int task);
41 int dm_simplecmd_flush (int, const char *, uint16_t);
42 int dm_simplecmd_noflush (int, const char *, uint16_t);
43 int dm_addmap_create (struct multipath *mpp, char *params);
44 int dm_addmap_reload (struct multipath *mpp, char *params, int flush);
45 int dm_map_present (const char *);
46 int dm_map_present_by_uuid(const char *uuid);
47 int dm_get_map(const char *, unsigned long long *, char **);
48 int dm_get_status(const char *, char **);
49 int dm_type(const char *, char *);
50 int dm_is_mpath(const char *);
51 int _dm_flush_map (const char *, int, int, int, int);
52 int dm_flush_map_nopaths(const char * mapname, int deferred_remove);
53 #define dm_flush_map(mapname) _dm_flush_map(mapname, 1, 0, 0, 0)
54 #define dm_flush_map_nosync(mapname) _dm_flush_map(mapname, 0, 0, 0, 0)
55 #define dm_suspend_and_flush_map(mapname, retries) \
56         _dm_flush_map(mapname, 1, 0, 1, retries)
57 int dm_cancel_deferred_remove(struct multipath *mpp);
58 int dm_flush_maps (int need_suspend, int retries);
59 int dm_fail_path(const char * mapname, char * path);
60 int dm_reinstate_path(const char * mapname, char * path);
61 int dm_queue_if_no_path(const char *mapname, int enable);
62 int dm_switchgroup(const char * mapname, int index);
63 int dm_enablegroup(const char * mapname, int index);
64 int dm_disablegroup(const char * mapname, int index);
65 int dm_get_maps (vector mp);
66 int dm_geteventnr (const char *name);
67 int dm_is_suspended(const char *name);
68 int dm_get_major_minor (const char *name, int *major, int *minor);
69 char * dm_mapname(int major, int minor);
70 int dm_remove_partmaps (const char * mapname, int need_sync,
71                         int deferred_remove);
72 int dm_get_uuid(const char *name, char *uuid, int uuid_len);
73 bool has_dm_info(const struct multipath *mpp);
74 int dm_get_info (const char * mapname, struct dm_info *dmi);
75 int dm_rename (const char * old, char * new, char * delim, int skip_kpartx);
76 int dm_reassign(const char * mapname);
77 int dm_reassign_table(const char *name, char *old, char *new);
78 int dm_setgeometry(struct multipath *mpp);
79 struct multipath *dm_get_multipath(const char *name);
80
81 #define VERSION_GE(v, minv) ( \
82         (v[0] > minv[0]) || \
83         ((v[0] == minv[0]) && (v[1] > minv[1])) || \
84         ((v[0] == minv[0]) && (v[1] == minv[1]) && (v[2] >= minv[2])) \
85 )
86
87 #ifndef LIBDM_API_GET_ERRNO
88 #include <errno.h>
89 #define dm_task_get_errno(x) errno
90 #endif
91 enum {
92         DM_LIBRARY_VERSION,
93         DM_KERNEL_VERSION,
94         DM_MPATH_TARGET_VERSION,
95         MULTIPATH_VERSION
96 };
97 int libmp_get_version(int which, unsigned int version[3]);
98 struct dm_task;
99 int libmp_dm_task_run(struct dm_task *dmt);
100
101 #define dm_log_error(lvl, cmd, dmt)                           \
102         condlog(lvl, "%s: libdm task=%d error: %s", __func__, \
103                 cmd, strerror(dm_task_get_errno(dmt)))        \
104
105 #endif /* _DEVMAPPER_H */