summaryrefslogtreecommitdiffstats
path: root/bindings_file.patch
blob: 209ad614ffc056d4daf7e2ae6ea0a504fe3a0c38 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
Add the ability to change the location of the user_friendly_names
binding file.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 libmultipath/config.c      |   11 ++++++++---
 libmultipath/dict.c        |   24 ++++++++++++++++++++++++
 multipath.conf.annotated   |    9 +++++++++
 multipath.conf.defaults    |    1 +
 multipath/main.c           |    4 +++-
 multipath/multipath.conf.5 |    8 ++++++--
 6 files changed, 51 insertions(+), 6 deletions(-)

Index: multipath-tools-090513/libmultipath/config.c
===================================================================
--- multipath-tools-090513.orig/libmultipath/config.c
+++ multipath-tools-090513/libmultipath/config.c
@@ -405,6 +405,9 @@ free_config (struct config * conf)
 	if (conf->checker_name)
 		FREE(conf->checker_name);
 
+	if (conf->bindings_file)
+		FREE(conf->bindings_file);
+
 	free_blacklist(conf->blist_devnode);
 	free_blacklist(conf->blist_wwid);
 	free_blacklist_device(conf->blist_device);
@@ -437,7 +440,6 @@ load_config (char * file)
 	conf->dev_type = DEV_NONE;
 	conf->minio = 1000;
 	conf->max_fds = 0;
-	conf->bindings_file = DEFAULT_BINDINGS_FILE;
 	conf->multipath_dir = set_default(DEFAULT_MULTIPATHDIR);
 	conf->flush_on_last_del = 0;
 	conf->attribute_flags = 0;
@@ -535,9 +537,12 @@ load_config (char * file)
 	if (conf->hwhandler == NULL)
 		conf->hwhandler = set_default(DEFAULT_HWHANDLER);
 
+	if (conf->bindings_file == NULL)
+		conf->bindings_file = set_default(DEFAULT_BINDINGS_FILE);
+
 	if (!conf->selector  || !conf->udev_dir || !conf->multipath_dir ||
-	    !conf->getuid    || !conf->features ||
-	    !conf->hwhandler)
+	    !conf->getuid    || !conf->features || !conf->hwhandler ||
+	    !conf->bindings_file)
 		goto out;
 
 	if (!conf->prio_name)
Index: multipath-tools-090513/libmultipath/dict.c
===================================================================
--- multipath-tools-090513.orig/libmultipath/dict.c
+++ multipath-tools-090513/libmultipath/dict.c
@@ -423,6 +423,17 @@ names_handler(vector strvec)
 	return 0;
 }
 
+static int
+def_bindings_file_handler(vector strvec)
+{
+	conf->bindings_file = set_value(strvec);
+
+	if (!conf->bindings_file)
+		return 1;
+
+	return 0;
+}
+
 /*
  * blacklist block handlers
  */
@@ -1920,6 +1931,18 @@ snprint_def_user_friendly_names (char * 
 }
 
 static int
+snprint_def_bindings_file(char * buff, int len, void * data)
+{
+	if (conf->bindings_file == NULL)
+		return 0;
+	if (strlen(conf->bindings_file) == strlen(DEFAULT_BINDINGS_FILE) &&
+	    !strcmp(conf->bindings_file, DEFAULT_BINDINGS_FILE))
+		return 0;
+
+	return snprintf(buff, len, "%s", conf->bindings_file);
+}
+
+static int
 snprint_ble_simple (char * buff, int len, void * data)
 {
 	struct blentry * ble = (struct blentry *)data;
@@ -1969,6 +1992,7 @@ init_keywords(void)
 	install_keyword("pg_timeout", &def_pg_timeout_handler, &snprint_def_pg_timeout);
 	install_keyword("flush_on_last_del", &def_flush_on_last_del_handler, &snprint_def_flush_on_last_del);
 	install_keyword("user_friendly_names", &names_handler, &snprint_def_user_friendly_names);
+	install_keyword("bindings_file", &def_bindings_file_handler, &snprint_def_bindings_file);
 	install_keyword("mode", &def_mode_handler, &snprint_def_mode);
 	install_keyword("uid", &def_uid_handler, &snprint_def_uid);
 	install_keyword("gid", &def_gid_handler, &snprint_def_gid);
Index: multipath-tools-090513/multipath.conf.annotated
===================================================================
--- multipath-tools-090513.orig/multipath.conf.annotated
+++ multipath-tools-090513/multipath.conf.annotated
@@ -198,6 +198,15 @@
 #	# default : determined by the process
 #	gid disk
 #
+#	#
+#	# name    : bindings_file
+#	# scope   : multipath
+#	# desc    : The location of the bindings file that is used with
+#	            the user_friendly_names option
+#	# values  : <full_pathname>
+#	# default : "/var/lib/multipath/bindings"
+#	bindings_file "/etc/multipath_bindings"
+#
 #}
 #	
 ##
Index: multipath-tools-090513/multipath.conf.defaults
===================================================================
--- multipath-tools-090513.orig/multipath.conf.defaults
+++ multipath-tools-090513/multipath.conf.defaults
@@ -14,6 +14,7 @@
 #	failback		manual
 #	no_path_retry		fail
 #	user_friendly_names	no
+#	bindings_file		"/var/lib/multipath/bindings"
 #}
 #
 #blacklist {
Index: multipath-tools-090513/multipath/main.c
===================================================================
--- multipath-tools-090513.orig/multipath/main.c
+++ multipath-tools-090513/multipath/main.c
@@ -362,7 +362,9 @@ main (int argc, char *argv[])
 			conf->verbosity = atoi(optarg);
 			break;
 		case 'b':
-			conf->bindings_file = optarg;
+			if (conf->bindings_file)
+				FREE(conf->bindings_file);
+			conf->bindings_file = STRDUP(optarg);
 			break;
 		case 'd':
 			conf->dry_run = 1;
Index: multipath-tools-090513/multipath/multipath.conf.5
===================================================================
--- multipath-tools-090513.orig/multipath/multipath.conf.5
+++ multipath-tools-090513/multipath/multipath.conf.5
@@ -221,8 +221,7 @@ for never stop queueing. Default is 0.
 .B user_friendly_names
 If set to 
 .I yes
-, using the bindings file
-.I /var/lib/multipath/bindings
+, using the bindings file (by default \fI/var/lib/multipath/bindings\fR)
 to assign a persistent and unique alias to the multipath, in the form of mpath<n>.
 If set to 
 .I no
@@ -231,6 +230,11 @@ be overriden by any specific aliases in 
 Default is
 .I no
 .TP
+.B bindings_file
+Specify the location of the bindings file used by the user_friendly_names
+option. Default is
+.I /var/lib/multipath/bindings
+.TP
 .B max_fds
 Specify the maximum number of file descriptors that can be opened by multipath
 and multipathd.  This is equivalent to ulimit -n. A value of \fImax\fR will set