Blame SOURCES/0094-RHBZ-1086825-cleanup-remap.patch

1eb31d
---
1eb31d
 libmultipath/alias.c   |   31 +++++++++++++++----------------
1eb31d
 libmultipath/propsel.c |    4 ++--
1eb31d
 2 files changed, 17 insertions(+), 18 deletions(-)
1eb31d
1eb31d
Index: multipath-tools-130222/libmultipath/alias.c
1eb31d
===================================================================
1eb31d
--- multipath-tools-130222.orig/libmultipath/alias.c
1eb31d
+++ multipath-tools-130222/libmultipath/alias.c
1eb31d
@@ -149,13 +149,11 @@ rlookup_binding(FILE *f, char *buff, cha
1eb31d
 {
1eb31d
 	char line[LINE_MAX];
1eb31d
 	unsigned int line_nr = 0;
1eb31d
-	int id = 0;
1eb31d
 
1eb31d
 	buff[0] = '\0';
1eb31d
 
1eb31d
 	while (fgets(line, LINE_MAX, f)) {
1eb31d
 		char *c, *alias, *wwid;
1eb31d
-		int curr_id;
1eb31d
 
1eb31d
 		line_nr++;
1eb31d
 		c = strpbrk(line, "#\n\r");
1eb31d
@@ -164,9 +162,6 @@ rlookup_binding(FILE *f, char *buff, cha
1eb31d
 		alias = strtok(line, " \t");
1eb31d
 		if (!alias) /* blank line */
1eb31d
 			continue;
1eb31d
-		curr_id = scan_devname(alias, prefix);
1eb31d
-		if (curr_id >= id)
1eb31d
-			id = curr_id + 1;
1eb31d
 		wwid = strtok(NULL, " \t");
1eb31d
 		if (!wwid){
1eb31d
 			condlog(3,
1eb31d
@@ -184,16 +179,12 @@ rlookup_binding(FILE *f, char *buff, cha
1eb31d
 				"\nSetting wwid to %s", alias, wwid);
1eb31d
 			strncpy(buff, wwid, WWID_SIZE);
1eb31d
 			buff[WWID_SIZE - 1] = '\0';
1eb31d
-			return id;
1eb31d
+			return 0;
1eb31d
 		}
1eb31d
 	}
1eb31d
 	condlog(3, "No matching alias [%s] in bindings file.", map_alias);
1eb31d
 
1eb31d
-	/* Get the theoretical id for this map alias.
1eb31d
-	 * Used by use_existing_alias
1eb31d
-	 */
1eb31d
-	id = scan_devname(map_alias, prefix);
1eb31d
-	return id;
1eb31d
+	return -1;
1eb31d
 }
1eb31d
 
1eb31d
 static char *
1eb31d
@@ -264,9 +255,7 @@ use_existing_alias (char *wwid, char *fi
1eb31d
 	/* lookup the binding. if it exsists, the wwid will be in buff
1eb31d
 	 * either way, id contains the id for the alias
1eb31d
 	 */
1eb31d
-	id = rlookup_binding(f , buff,  alias_old, prefix);
1eb31d
-	if (id < 0)
1eb31d
-		goto out;
1eb31d
+	rlookup_binding(f, buff, alias_old, prefix);
1eb31d
 
1eb31d
 	if (strlen(buff) > 0) {
1eb31d
 		/* if buff is our wwid, it's already
1eb31d
@@ -279,11 +268,21 @@ use_existing_alias (char *wwid, char *fi
1eb31d
 			condlog(0, "alias %s already bound to wwid %s, cannot reuse",
1eb31d
 				alias_old, buff);
1eb31d
 		}
1eb31d
-		goto out;	
1eb31d
+		goto out;
1eb31d
 	}
1eb31d
 
1eb31d
 	/* allocate the existing alias in the bindings file */
1eb31d
-	if (can_write && id && !bindings_read_only) {
1eb31d
+	id = scan_devname(alias_old, prefix);
1eb31d
+	if (id <= 0)
1eb31d
+		goto out;
1eb31d
+
1eb31d
+	if (fflush(f) != 0) {
1eb31d
+		condlog(0, "cannot fflush bindings file stream : %s",
1eb31d
+			strerror(errno));
1eb31d
+		goto out;
1eb31d
+	}
1eb31d
+
1eb31d
+	if (can_write && !bindings_read_only) {
1eb31d
 		alias = allocate_binding(fd, wwid, id, prefix);
1eb31d
 		condlog(0, "Allocated existing binding [%s] for WWID [%s]",
1eb31d
 			alias, wwid);
1eb31d
Index: multipath-tools-130222/libmultipath/propsel.c
1eb31d
===================================================================
1eb31d
--- multipath-tools-130222.orig/libmultipath/propsel.c
1eb31d
+++ multipath-tools-130222/libmultipath/propsel.c
1eb31d
@@ -263,13 +263,13 @@ select_alias (struct multipath * mp)
1eb31d
 		goto out;
1eb31d
 
1eb31d
 	select_alias_prefix(mp);
1eb31d
-	
1eb31d
+
1eb31d
 	if (strlen(mp->alias_old) > 0) {
1eb31d
 		mp->alias = use_existing_alias(mp->wwid, conf->bindings_file,
1eb31d
 				mp->alias_old, mp->alias_prefix,
1eb31d
 				conf->bindings_read_only);
1eb31d
 		memset (mp->alias_old, 0, WWID_SIZE);
1eb31d
-	} 
1eb31d
+	}
1eb31d
 
1eb31d
 	if (mp->alias == NULL)
1eb31d
 		mp->alias = get_user_friendly_alias(mp->wwid,