Blame SOURCES/0215-RHBZ-1444194-fix-check-partitions.patch

d88bf6
---
d88bf6
 libmultipath/devmapper.c |   53 +++++++++++++++++++++--------------------------
d88bf6
 1 file changed, 24 insertions(+), 29 deletions(-)
d88bf6
d88bf6
Index: multipath-tools-130222/libmultipath/devmapper.c
d88bf6
===================================================================
d88bf6
--- multipath-tools-130222.orig/libmultipath/devmapper.c
d88bf6
+++ multipath-tools-130222/libmultipath/devmapper.c
d88bf6
@@ -466,42 +466,35 @@ uuidout:
d88bf6
 extern int
d88bf6
 dm_get_uuid(char *name, char *uuid)
d88bf6
 {
d88bf6
-	char uuidtmp[WWID_SIZE];
d88bf6
-
d88bf6
-	if (dm_get_prefixed_uuid(name, uuidtmp))
d88bf6
+	if (dm_get_prefixed_uuid(name, uuid))
d88bf6
 		return 1;
d88bf6
 
d88bf6
-	if (!strncmp(uuidtmp, UUID_PREFIX, UUID_PREFIX_LEN))
d88bf6
-		strcpy(uuid, uuidtmp + UUID_PREFIX_LEN);
d88bf6
-	else
d88bf6
-		strcpy(uuid, uuidtmp);
d88bf6
-
d88bf6
+	if (!strncmp(uuid, UUID_PREFIX, UUID_PREFIX_LEN))
d88bf6
+		memmove(uuid, uuid + UUID_PREFIX_LEN,
d88bf6
+			strlen(uuid + UUID_PREFIX_LEN) + 1);
d88bf6
 	return 0;
d88bf6
 }
d88bf6
 
d88bf6
-/*
d88bf6
- * returns:
d88bf6
- *    0 : if both uuids end with same suffix which starts with UUID_PREFIX
d88bf6
- *    1 : otherwise
d88bf6
- */
d88bf6
-int
d88bf6
-dm_compare_uuid(const char* mapname1, const char* mapname2)
d88bf6
+static int
d88bf6
+is_mpath_part(const char *part_name, const char *map_name)
d88bf6
 {
d88bf6
-	char *p1, *p2;
d88bf6
-	char uuid1[WWID_SIZE], uuid2[WWID_SIZE];
d88bf6
+	char *p;
d88bf6
+	char part_uuid[WWID_SIZE], map_uuid[WWID_SIZE];
d88bf6
 
d88bf6
-	if (dm_get_prefixed_uuid(mapname1, uuid1))
d88bf6
-		return 1;
d88bf6
+	if (dm_get_prefixed_uuid(part_name, part_uuid))
d88bf6
+		return 0;
d88bf6
 
d88bf6
-	if (dm_get_prefixed_uuid(mapname2, uuid2))
d88bf6
-		return 1;
d88bf6
+	if (dm_get_prefixed_uuid(map_name, map_uuid))
d88bf6
+		return 0;
d88bf6
 
d88bf6
-	p1 = strstr(uuid1, UUID_PREFIX);
d88bf6
-	p2 = strstr(uuid2, UUID_PREFIX);
d88bf6
-	if (p1 && p2 && !strcmp(p1, p2))
d88bf6
+	if (strncmp(part_uuid, "part", 4) != 0)
d88bf6
 		return 0;
d88bf6
 
d88bf6
-	return 1;
d88bf6
+	p = strstr(part_uuid, UUID_PREFIX);
d88bf6
+	if (p && !strcmp(p, map_uuid))
d88bf6
+		return 1;
d88bf6
+
d88bf6
+	return 0;
d88bf6
 }
d88bf6
 
d88bf6
 extern int
d88bf6
@@ -1143,6 +1136,7 @@ do_foreach_partmaps (const char * mapnam
d88bf6
 	unsigned long long size;
d88bf6
 	char dev_t[32];
d88bf6
 	int r = 1;
d88bf6
+	char *p;
d88bf6
 
d88bf6
 	if (!(dmt = dm_task_create(DM_DEVICE_LIST)))
d88bf6
 		return 1;
d88bf6
@@ -1171,10 +1165,10 @@ do_foreach_partmaps (const char * mapnam
d88bf6
 		    (dm_type(names->name, TGT_PART) > 0) &&
d88bf6
 
d88bf6
 		    /*
d88bf6
-		     * and both uuid end with same suffix starting
d88bf6
-		     * at UUID_PREFIX
d88bf6
+		     * and the uuid of the target is a partition of the
d88bf6
+		     * uuid of the multipath device
d88bf6
 		     */
d88bf6
-		    (!dm_compare_uuid(names->name, mapname)) &&
d88bf6
+		    is_mpath_part(names->name, mapname) &&
d88bf6
 
d88bf6
 		    /*
d88bf6
 		     * and we can fetch the map table from the kernel
d88bf6
@@ -1184,7 +1178,8 @@ do_foreach_partmaps (const char * mapnam
d88bf6
 		    /*
d88bf6
 		     * and the table maps over the multipath map
d88bf6
 		     */
d88bf6
-		    strstr(params, dev_t)
d88bf6
+		    (p = strstr(params, dev_t)) &&
d88bf6
+		    !isdigit(*(p + strlen(dev_t)))
d88bf6
 		   ) {
d88bf6
 			if (partmap_func(names->name, data) != 0)
d88bf6
 				goto out;