Signed-off-by: Martin Wilck <[email protected]>
Reviewed-by: Benjamin Marzinski <[email protected]>
---
libmultipath/devmapper.c | 14 ++++++++++++++
libmultipath/devmapper.h | 3 +++
2 files changed, 17 insertions(+)
diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
index 4ad84dd..e51c2f0 100644
--- a/libmultipath/devmapper.c
+++ b/libmultipath/devmapper.c
@@ -79,6 +79,20 @@ static void libmp_udev_wait(unsigned int c)
}
#endif
+const char *dmp_errstr(int rc)
+{
+ static const char *str[] = {
+ [DMP_ERR] = "generic error",
+ [DMP_OK] = "success",
+ [DMP_NOT_FOUND] = "not found",
+ [DMP_NO_MATCH] = "target type mismatch",
+ [__DMP_LAST__] = "**invalid**",
+ };
+ if (rc < 0 || rc > __DMP_LAST__)
+ rc = __DMP_LAST__;
+ return str[rc];
+}
+
int libmp_dm_task_run(struct dm_task *dmt)
{
int r;
diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h
index a10821f..7231a98 100644
--- a/libmultipath/devmapper.h
+++ b/libmultipath/devmapper.h
@@ -34,8 +34,11 @@ enum {
DMP_OK,
DMP_NOT_FOUND,
DMP_NO_MATCH,
+ __DMP_LAST__,
};
+const char* dmp_errstr(int rc);
+
/**
* enum mapinfo_flags: input flags for libmp_mapinfo()
*/
--
2.45.2