| 1 |
#include <glib.h> |
| 2 |
#include <blockdev/utils.h> |
| 3 |
|
| 4 |
#ifndef BD_DM_API |
| 5 |
#define BD_DM_API |
| 6 |
|
| 7 |
GQuark bd_dm_error_quark (void) { |
| 8 |
return g_quark_from_static_string ("g-bd-dm-error-quark"); |
| 9 |
} |
| 10 |
|
| 11 |
#define BD_DM_ERROR bd_dm_error_quark () |
| 12 |
typedef enum { |
| 13 |
BD_DM_ERROR_TECH_UNAVAIL, |
| 14 |
BD_DM_ERROR_SYS, |
| 15 |
BD_DM_ERROR_NOT_ROOT, |
| 16 |
BD_DM_ERROR_TASK, |
| 17 |
BD_DM_ERROR_RAID_FAIL, |
| 18 |
BD_DM_ERROR_RAID_NO_DEVS, |
| 19 |
BD_DM_ERROR_RAID_NO_EXIST, |
| 20 |
BD_DM_ERROR_DEVICE_NOEXIST, |
| 21 |
} BDDMError; |
| 22 |
|
| 23 |
typedef enum { |
| 24 |
BD_DM_TECH_MAP = 0, |
| 25 |
} BDDMTech; |
| 26 |
|
| 27 |
typedef enum { |
| 28 |
BD_DM_TECH_MODE_CREATE_ACTIVATE = 1 << 0, |
| 29 |
BD_DM_TECH_MODE_REMOVE_DEACTIVATE = 1 << 1, |
| 30 |
BD_DM_TECH_MODE_QUERY = 1 << 2, |
| 31 |
} BDDMTechMode; |
| 32 |
|
| 33 |
/** |
| 34 |
* bd_dm_is_tech_avail: |
| 35 |
* @tech: the queried tech |
| 36 |
* @mode: a bit mask of queried modes of operation (#BDDMTechMode) for @tech |
| 37 |
* @error: (out) (optional): place to store error (details about why the @tech-@mode combination is not available) |
| 38 |
* |
| 39 |
* Returns: whether the @tech-@mode combination is available -- supported by the |
| 40 |
* plugin implementation and having all the runtime dependencies available |
| 41 |
*/ |
| 42 |
gboolean bd_dm_is_tech_avail (BDDMTech tech, guint64 mode, GError **error); |
| 43 |
|
| 44 |
/** |
| 45 |
* bd_dm_create_linear: |
| 46 |
* @map_name: name of the map |
| 47 |
* @device: device to create map for |
| 48 |
* @length: length of the mapping in sectors |
| 49 |
* @uuid: (nullable): UUID for the new dev mapper device or %NULL if not specified |
| 50 |
* @error: (out) (optional): place to store error (if any) |
| 51 |
* |
| 52 |
* Returns: whether the new linear mapping @map_name was successfully created |
| 53 |
* for the @device or not |
| 54 |
* |
| 55 |
* Tech category: %BD_DM_TECH_MAP-%BD_DM_TECH_MODE_CREATE_ACTIVATE |
| 56 |
*/ |
| 57 |
gboolean bd_dm_create_linear (const gchar *map_name, const gchar *device, guint64 length, const gchar *uuid, GError **error); |
| 58 |
|
| 59 |
/** |
| 60 |
* bd_dm_remove: |
| 61 |
* @map_name: name of the map to remove |
| 62 |
* @error: (out) (optional): place to store error (if any) |
| 63 |
* |
| 64 |
* Returns: whether the @map_name map was successfully removed or not |
| 65 |
* |
| 66 |
* Tech category: %BD_DM_TECH_MAP-%BD_DM_TECH_MODE_REMOVE_DEACTIVATE |
| 67 |
*/ |
| 68 |
gboolean bd_dm_remove (const gchar *map_name, GError **error); |
| 69 |
|
| 70 |
/** |
| 71 |
* bd_dm_name_from_node: |
| 72 |
* @dm_node: name of the DM node (e.g. "dm-0") |
| 73 |
* @error: (out) (optional): place to store error (if any) |
| 74 |
* |
| 75 |
* Returns: map name of the map providing the @dm_node device or %NULL |
| 76 |
* (@error) contains the error in such cases |
| 77 |
* |
| 78 |
* Tech category: %BD_DM_TECH_MAP-%BD_DM_TECH_MODE_QUERY |
| 79 |
*/ |
| 80 |
gchar* bd_dm_name_from_node (const gchar *dm_node, GError **error); |
| 81 |
|
| 82 |
/** |
| 83 |
* bd_dm_node_from_name: |
| 84 |
* @map_name: name of the queried DM map |
| 85 |
* @error: (out) (optional): place to store error (if any) |
| 86 |
* |
| 87 |
* Returns: DM node name for the @map_name map or %NULL (@error) contains |
| 88 |
* the error in such cases |
| 89 |
* |
| 90 |
* Tech category: %BD_DM_TECH_MAP-%BD_DM_TECH_MODE_QUERY |
| 91 |
*/ |
| 92 |
gchar* bd_dm_node_from_name (const gchar *map_name, GError **error); |
| 93 |
|
| 94 |
/** |
| 95 |
* bd_dm_get_subsystem_from_name: |
| 96 |
* @device_name: name of the device |
| 97 |
* @error: (out) (optional): place to store error (if any) |
| 98 |
* |
| 99 |
* Returns: subsystem of the given device |
| 100 |
* |
| 101 |
* Tech category: %BD_DM_TECH_MAP-%BD_DM_TECH_MODE_QUERY |
| 102 |
*/ |
| 103 |
gchar* bd_dm_get_subsystem_from_name (const gchar *device_name, GError **error); |
| 104 |
|
| 105 |
/** |
| 106 |
* bd_dm_map_exists: |
| 107 |
* @map_name: name of the queried map |
| 108 |
* @live_only: whether to go through the live maps only or not |
| 109 |
* @active_only: whether to ignore suspended maps or not |
| 110 |
* @error: (out) (optional): place to store error (if any) |
| 111 |
* |
| 112 |
* Returns: whether the given @map_name exists (and is live if @live_only is |
| 113 |
* %TRUE (and is active if @active_only is %TRUE)). If %FALSE is returned, |
| 114 |
* @error indicates whether error appeared (non-%NULL) or not (%NULL). |
| 115 |
* |
| 116 |
* Tech category: %BD_DM_TECH_MAP-%BD_DM_TECH_MODE_QUERY |
| 117 |
*/ |
| 118 |
gboolean bd_dm_map_exists (const gchar *map_name, gboolean live_only, gboolean active_only, GError **error); |
| 119 |
|
| 120 |
#endif /* BD_DM_API */ |