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

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