Blame SOURCES/0081-RHBZ-1066264-check-prefix-on-rename.patch

38852f
---
38852f
 libmultipath/devmapper.c |   12 ++++++++++--
38852f
 1 file changed, 10 insertions(+), 2 deletions(-)
38852f
38852f
Index: multipath-tools-130222/libmultipath/devmapper.c
38852f
===================================================================
38852f
--- multipath-tools-130222.orig/libmultipath/devmapper.c
38852f
+++ multipath-tools-130222/libmultipath/devmapper.c
38852f
@@ -1151,6 +1151,8 @@ dm_rename_partmaps (char * old, char * n
38852f
 	unsigned long long size;
38852f
 	char dev_t[32];
38852f
 	int r = 1;
38852f
+	int offset;
38852f
+	char *delim;
38852f
 
38852f
 	if (!(dmt = dm_task_create(DM_DEVICE_LIST)))
38852f
 		return 1;
38852f
@@ -1171,6 +1173,11 @@ dm_rename_partmaps (char * old, char * n
38852f
 	if (dm_dev_t(old, &dev_t[0], 32))
38852f
 		goto out;
38852f
 
38852f
+	if (isdigit(new[strlen(new)-1]))
38852f
+		delim = "p";
38852f
+	else
38852f
+		delim = "";
38852f
+
38852f
 	do {
38852f
 		if (
38852f
 		    /*
38852f
@@ -1198,8 +1205,9 @@ dm_rename_partmaps (char * old, char * n
38852f
 				 * then it's a kpartx generated partition.
38852f
 				 * Rename it.
38852f
 				 */
38852f
-				snprintf(buff, PARAMS_SIZE, "%s%s",
38852f
-					 new, names->name + strlen(old));
38852f
+				for (offset = strlen(old); names->name[offset] && !(isdigit(names->name[offset])); offset++); /* do nothing */
38852f
+				snprintf(buff, PARAMS_SIZE, "%s%s%s",
38852f
+					 new, delim, names->name + offset);
38852f
 				dm_rename(names->name, buff);
38852f
 				condlog(4, "partition map %s renamed",
38852f
 					names->name);