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