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

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