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