@@ -86,6 +86,7 @@ const char *dmp_errstr(int rc)
[DMP_OK] = "success",
[DMP_NOT_FOUND] = "not found",
[DMP_NO_MATCH] = "target type mismatch",
+ [DMP_EMPTY] = "no target",
[DMP_LAST__] = "**invalid**",
};
if (rc < 0 || rc > DMP_LAST__)
@@ -747,9 +748,9 @@ static int libmp_mapinfo__(int flags, mapid_t id, mapinfo_t info, const char *ma
condlog(lvl, "%s: map %s has multiple targets", fname__, map_id);
return DMP_NO_MATCH;
}
- if (!params) {
+ if (!params || !target_type) {
condlog(lvl, "%s: map %s has no targets", fname__, map_id);
- return DMP_NOT_FOUND;
+ return DMP_EMPTY;
}
if (flags & MAPINFO_TGT_TYPE__) {
const char *tgt_type = flags & MAPINFO_MPATH_ONLY ? TGT_MPATH : TGT_PART;
@@ -873,6 +874,7 @@ int dm_is_mpath(const char *name)
return DM_IS_MPATH_YES;
case DMP_NOT_FOUND:
case DMP_NO_MATCH:
+ case DMP_EMPTY:
return DM_IS_MPATH_NO;
case DMP_ERR:
default:
@@ -35,6 +35,7 @@ enum {
DMP_OK,
DMP_NOT_FOUND,
DMP_NO_MATCH,
+ DMP_EMPTY,
DMP_LAST__,
};
@@ -105,7 +106,11 @@ typedef struct libmp_map_info {
* @returns:
* DMP_OK if successful.
* DMP_NOT_FOUND if the map wasn't found, or has no or multiple targets.
- * DMP_NO_MATCH if the map didn't match @tgt_type (see above).
+ * DMP_NO_MATCH if the map didn't match @tgt_type (see above) or didn't
+ * have a multipath uuid prefix.
+ * DMP_EMPTY if the map has no table. Note. The check for matching uuid
+ * prefix will happen first, but the check for matching
+ * tgt_type will happen afterwards.
* DMP_ERR if some other error occurred.
*
* This function obtains the requested information for the device-mapper map
if libmp_mapinfo() is run on a device that has no active table, it will now return with a new exit code, DMP_EMPTY, to signal this. Currently all code paths treat this identically to DMP_NOT_FOUND. Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> --- libmultipath/devmapper.c | 6 ++++-- libmultipath/devmapper.h | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-)