summaryrefslogtreecommitdiffstats
path: root/0058-RHBZ-601665-assemble-features.patch
blob: aecd84537df670e3745be1b6e2c67d41fc3f5fee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---
 libmultipath/dmparser.c |   37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

Index: multipath-tools/libmultipath/dmparser.c
===================================================================
--- multipath-tools.orig/libmultipath/dmparser.c
+++ multipath-tools/libmultipath/dmparser.c
@@ -6,6 +6,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <ctype.h>
 
 #include "checkers.h"
 #include "vector.h"
@@ -44,6 +45,40 @@ merge_words (char ** dst, char * word, i
 	return 0;
 }
 
+char *
+assemble_features (struct multipath *mp)
+{
+	static char features[PARAMS_SIZE];
+	unsigned int nr_features;
+	char *ptr;
+
+	if (!conf->daemon || mp->no_path_retry == NO_PATH_RETRY_UNDEF ||
+	    mp->no_path_retry == NO_PATH_RETRY_FAIL ||
+	    strstr(mp->features, "queue_if_no_path"))
+		return mp->features;
+	if (18 > PARAMS_SIZE - 1 - strlen(mp->features)) {
+		fprintf(stderr, "not enough size to modify features\n");
+		return mp->features;
+	}
+	if (sscanf(mp->features, "%u", &nr_features) != 1) {
+		fprintf(stderr, "can't find number of features\n");
+		return mp->features;
+	}
+	ptr = mp->features;
+	while (isspace(*ptr))
+		ptr++;
+	if (*ptr == '\0') {
+		fprintf(stderr, "features is empty\n");
+		return mp->features;
+	}
+	while(*ptr != '\0' && !isspace(*ptr))
+		ptr++;
+
+	snprintf(features, PARAMS_SIZE, "%u%s queue_if_no_path",
+		 nr_features + 1, ptr);
+	return features;
+}
+
 /*
  * Transforms the path group vector into a proper device map string
  */
@@ -62,7 +97,7 @@ assemble_map (struct multipath * mp)
 	freechar = sizeof(mp->params);
 
 	shift = snprintf(p, freechar, "%s %s %i %i",
-			 mp->features, mp->hwhandler,
+			 assemble_features(mp), mp->hwhandler,
 			 VECTOR_SIZE(mp->pg), mp->bestpg);
 
 	if (shift >= freechar) {