]>
Commit | Line | Data |
---|---|---|
289c5516 MT |
1 | --- |
2 | libmultipath/alias.c | 31 +++++++++++++++---------------- | |
3 | libmultipath/propsel.c | 4 ++-- | |
4 | 2 files changed, 17 insertions(+), 18 deletions(-) | |
5 | ||
6 | Index: multipath-tools-130222/libmultipath/alias.c | |
7 | =================================================================== | |
8 | --- multipath-tools-130222.orig/libmultipath/alias.c | |
9 | +++ multipath-tools-130222/libmultipath/alias.c | |
10 | @@ -149,13 +149,11 @@ rlookup_binding(FILE *f, char *buff, cha | |
11 | { | |
12 | char line[LINE_MAX]; | |
13 | unsigned int line_nr = 0; | |
14 | - int id = 0; | |
15 | ||
16 | buff[0] = '\0'; | |
17 | ||
18 | while (fgets(line, LINE_MAX, f)) { | |
19 | char *c, *alias, *wwid; | |
20 | - int curr_id; | |
21 | ||
22 | line_nr++; | |
23 | c = strpbrk(line, "#\n\r"); | |
24 | @@ -164,9 +162,6 @@ rlookup_binding(FILE *f, char *buff, cha | |
25 | alias = strtok(line, " \t"); | |
26 | if (!alias) /* blank line */ | |
27 | continue; | |
28 | - curr_id = scan_devname(alias, prefix); | |
29 | - if (curr_id >= id) | |
30 | - id = curr_id + 1; | |
31 | wwid = strtok(NULL, " \t"); | |
32 | if (!wwid){ | |
33 | condlog(3, | |
34 | @@ -184,16 +179,12 @@ rlookup_binding(FILE *f, char *buff, cha | |
35 | "\nSetting wwid to %s", alias, wwid); | |
36 | strncpy(buff, wwid, WWID_SIZE); | |
37 | buff[WWID_SIZE - 1] = '\0'; | |
38 | - return id; | |
39 | + return 0; | |
40 | } | |
41 | } | |
42 | condlog(3, "No matching alias [%s] in bindings file.", map_alias); | |
43 | ||
44 | - /* Get the theoretical id for this map alias. | |
45 | - * Used by use_existing_alias | |
46 | - */ | |
47 | - id = scan_devname(map_alias, prefix); | |
48 | - return id; | |
49 | + return -1; | |
50 | } | |
51 | ||
52 | static char * | |
53 | @@ -264,9 +255,7 @@ use_existing_alias (char *wwid, char *fi | |
54 | /* lookup the binding. if it exsists, the wwid will be in buff | |
55 | * either way, id contains the id for the alias | |
56 | */ | |
57 | - id = rlookup_binding(f , buff, alias_old, prefix); | |
58 | - if (id < 0) | |
59 | - goto out; | |
60 | + rlookup_binding(f, buff, alias_old, prefix); | |
61 | ||
62 | if (strlen(buff) > 0) { | |
63 | /* if buff is our wwid, it's already | |
64 | @@ -279,11 +268,21 @@ use_existing_alias (char *wwid, char *fi | |
65 | condlog(0, "alias %s already bound to wwid %s, cannot reuse", | |
66 | alias_old, buff); | |
67 | } | |
68 | - goto out; | |
69 | + goto out; | |
70 | } | |
71 | ||
72 | /* allocate the existing alias in the bindings file */ | |
73 | - if (can_write && id && !bindings_read_only) { | |
74 | + id = scan_devname(alias_old, prefix); | |
75 | + if (id <= 0) | |
76 | + goto out; | |
77 | + | |
78 | + if (fflush(f) != 0) { | |
79 | + condlog(0, "cannot fflush bindings file stream : %s", | |
80 | + strerror(errno)); | |
81 | + goto out; | |
82 | + } | |
83 | + | |
84 | + if (can_write && !bindings_read_only) { | |
85 | alias = allocate_binding(fd, wwid, id, prefix); | |
86 | condlog(0, "Allocated existing binding [%s] for WWID [%s]", | |
87 | alias, wwid); | |
88 | Index: multipath-tools-130222/libmultipath/propsel.c | |
89 | =================================================================== | |
90 | --- multipath-tools-130222.orig/libmultipath/propsel.c | |
91 | +++ multipath-tools-130222/libmultipath/propsel.c | |
92 | @@ -263,13 +263,13 @@ select_alias (struct multipath * mp) | |
93 | goto out; | |
94 | ||
95 | select_alias_prefix(mp); | |
96 | - | |
97 | + | |
98 | if (strlen(mp->alias_old) > 0) { | |
99 | mp->alias = use_existing_alias(mp->wwid, conf->bindings_file, | |
100 | mp->alias_old, mp->alias_prefix, | |
101 | conf->bindings_read_only); | |
102 | memset (mp->alias_old, 0, WWID_SIZE); | |
103 | - } | |
104 | + } | |
105 | ||
106 | if (mp->alias == NULL) | |
107 | mp->alias = get_user_friendly_alias(mp->wwid, |