Signed-off-by: Martin Wilck <mwilck@xxxxxxxx> --- libmultipath/devmapper.c | 14 ++++++++++++++ libmultipath/devmapper.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index d321041..f7ad7a8 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 a2b2837..ed5e866 100644 --- a/libmultipath/devmapper.h +++ b/libmultipath/devmapper.h @@ -33,8 +33,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